简体   繁体   中英

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. I never had a programming course in KRL so i am missing a basic step to use my code. 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. You can also just call statuskey() from a submit in case you do not want to move the code.

Keep in mind to never put waits or similar in sps.sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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