|
Electrical
& Software Control Systems for Safe Rides & Shows |
(407) 290-2000 |
Push-On, Push-Off Toggle
Coding for an operator interface often requires a push-on, push-off toggle function. In a typical scenario, the panel has a simple lighted pushbutton, but the user interface design requires a push-on, push-off button. The simpler momentary switch is usually more desirable, both because it is cheaper, and because the PLC can choose to override the basic push-on, push-off behavior.
Although a simple function, Ive seen (and written) some suprising complex implementations of this basic operation. Here is the simplest one Ive found yet:
Given BUTTON, an input, and LIGHT, an output:
Construct a strobe, BUT_STB from the button. Strobe is high for
one-scan on rising edge of button press.
![]()
Invert the LIGHT each time BUT_STB pops on for a scan. Set the
light to the XOR of the old light and the strobe.

The relationship between the new light and the old light is
clearer in this Karnaugh map:
| L | L | ||
|---|---|---|---|
| S | 0 | 1 | old Light |
| 0 | 0 | 1 | no change to light when strobe is OFF |
| 1 | 1 | 0 | light invertes when strobe is ON |
L = (L and (not S)) or ((not L) and S)
L = L xor S
L = L _ S
The same technique works well for constructing a blinker bit from a self resetting timer:
Reset a timer with its own Done bit to obtain a done bit which
periodically pops ON for one scan.
![]()
Use the strobing Done bit to toggle a blinker bit.

It is the simplest way in ladder I have seen for making a T flip-flop. The blink circuit is good when you want to flash a light at an interval that is readliy observable and editable by accessing the timer preset. I often use a bit from the free running clock (S:4) to be my flasher instruction. If you dont care that the flash period is a little odd, say 1.28 seconds, then you can simply use an XIC instruction with the address S:4/6 to utilize the 7th bit of the free running clock and label it FLASHER. If you want a faster or slower flash rate, then use a lower or higher bit of the clock.
| www.birket.com | P.O. Box 610190, Ocoee, FL 34761-0190 | fax (407) 654-2150 |