Ken M said:Code:A #TRIGGER FP #ONESHOT X #TOGGLE AN #INHIBIT = #TOGGLE
Stick this in a Siemens FC with TRIGGER, ONESHOT and INHIBIT as BOOL IN parameters, and TOGGLE as the BOOL OUT parameter. This gives you a flip-flop plus an inhibit switch, all in six lines of code. Take out the inhibit if you don't want it, and now we are five.
The secret's in the 'X'.
Regards
Ken
InOut InOut
---| |------|NOT|-----( )
FC??
Button Bit ---------
---| |----|P]------| Tog |
| |
InOut| |
---------