繁体   English   中英

KRL:我想使用 KRC4 平板电脑的状态键发送输出

[英]KRL: I want to use the Status Keys of the KRC4 Tablet to send outputs

我已经有了我的代码,如果我错了,请纠正我。 但是代码不是我的问题...我不知道在 KRC4 界面中的何处以及如何使用它不能那样工作。 我从来没有在 KRL 上过编程课程,所以我错过了使用我的代码的基本步骤。 代码:

DEF StatusKey()

;FOLD +> Status Key detection
; check if status key is pressed

  $FLAG[11]=is_key_pressed(14)
  $FLAG[12]=is_key_pressed(15)
  $FLAG[13]=is_key_pressed(16)
  $FLAG[14]=is_key_pressed(17)

; detect rising edge of the button press
; by comparing current and remembered state

  $FLAG[1] = $FLAG[11] AND NOT $FLAG[15]
  $FLAG[2] = $FLAG[12] AND NOT $FLAG[16]
  $FLAG[3] = $FLAG[13] AND NOT $FLAG[17]
  $FLAG[4] = $FLAG[14] AND NOT $FLAG[18]

; remember previous state of the button

  $FLAG[15]=$FLAG[11]
  $FLAG[16]=$FLAG[12]
  $FLAG[17]=$FLAG[13]
  $FLAG[18]=$FLAG[14]

;ENDFOLD

;FOLD +> Status Key control
; allow status keys to control some outputs
; but only if in T1 and drives are enables

IF $T1 AND $PERI_RDY AND $USER_SAF AND NOT $PRO_ACT THEN
 
; for momentary state change (toggle) use flags 1..4

  IF $FLAG[1] THEN
    $OUT[1] = True
  ENDIF

  IF $FLAG[2] THEN
    $OUT[1] = False
  ENDIF

; for continuous outputs use flags 11..14  

  ; $OUT[1] = $FLAG[11] ; already used for output 1
  ; $OUT[2] = $FLAG[12] ; already used for output 1
  ; $OUT[3] = $FLAG[13]
  ; $OUT[4] = $FLAG[14] 

ENDIF

;ENDFOLD
END

您需要将其放在 *.sub 中,以便循环评估。 如果您不想移动代码,也可以从提交中调用 statuskey()。

请记住不要在 sps.sub 中放置等待或类似内容

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM