[英]KRL: I want to use the Status Keys of the KRC4 Tablet to send outputs
i already have my code and if i am wrong please correct me.我已经有了我的代码,如果我错了,请纠正我。 But the code isnt my problem... i dont know where and how i use it in the KRC4 interface i thought a.src file would be enough inside of the KRC -> R1 -> System Folder... but guess what it does not work like that.
但是代码不是我的问题...我不知道在 KRC4 界面中的何处以及如何使用它不能那样工作。 I never had a programming course in KRL so i am missing a basic step to use my code.
我从来没有在 KRL 上过编程课程,所以我错过了使用我的代码的基本步骤。 CODE:
代码:
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
You need to put this in a *.sub for it to evaluate cyclically.您需要将其放在 *.sub 中,以便循环评估。 You can also just call statuskey() from a submit in case you do not want to move the code.
如果您不想移动代码,也可以从提交中调用 statuskey()。
Keep in mind to never put waits or similar in sps.sub请记住不要在 sps.sub 中放置等待或类似内容
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.