The "Important Note" on page 16 less clear than it could perhaps be regarding the unique behavior of output (OUTnn) bits.
Output bits may be changed (SET or RST) anywhere in the PLC program; but when PLC logic reads the value of the output, it will see the value the output had at the beginning of that scan. Any changes are not "written" to the output until the scan is complete.
This is probably illustrated better with an example, than with any amount of description.
Code: Select all
GreenButton IS INP12
YellowButton IS INP13
GreenLight IS OUT23
YellowLight IS OUT24
OpMode_M IS MEM34
GreenButtonPD IS PD56
YellowButtonPD IS PD57
; Toggle the green light on or off with each press of the green button
IF GreenButton THEN (GreenButtonPD)
IF GreenButtonPD && GreenLight THEN RST GreenLight ; [1]
IF GreenButtonPD && !GreenLight THEN SET GreenLight ; [2]
; Toggle operating mode on or off with each press of the yellow button,
; and display operating mode status with the yellow light
IF YellowButton THEN (YellowButtonPD)
IF YellowButtonPD && OpMode_M THEN RST OpMode_M ; [3]
IF YellowButtonPD && !OpMode_M THEN SET OpMode_M ; [4]
IF OpMode_M THEN (YellowLight)
In the example above, the green button / green light controls would work correctly, but the yellow button / operating mode / yellow light controls would not.
That is because GreenLight is an OUT, while OpMode_M is a MEM.
If the green light is on, and the green button is pressed to turn it off:
On the line marked [1], the "image" of the outputs is updated to turn OUT23 off. However, that change will not take effect until the PLC scan is complete. Therefore, when the logic on the line marked [2] is evaluated, the value of "GreenLight" will still be on (1, true), so that line will not take any action.
If "OpMode_M" is on, and the yellow button is pressed to turn it off:
On the line marked [3], the memory bit itself is turned off (RST). That change takes effect immediately. Therefore, when the logic on the line marked [4] is evaluated, it sees that the button was pressed and OpMode_M is now off (0, false), and so that line will turn the memory bit back on (SET). As a result, once OpMode_M and the yellow light are on, it will be impossible to turn them off.