3. Instruction Set
2. When the instruction MC is executed, the previous state of the switch contact is put onto the
top of the stack inside the PLC. The stack is controlled by the PLC, and can not be changed by
users. When the instruction MCR is executed, the previous state of the switch contact is
popped from the top of the stack. Under the conditions listed in (b), (d), and (e) above, the
number of times the items are pushed onto the stack may be different from the number of
times the items are popped from the stack. When this situation occurs, at most 32 items can
be pushed onto the stack, and the items can be popped form the stack until the stack is empty.
Therefore, when CJ or CJP is used with MC and MCR, users have to be careful of the pushing
of the item onto the stack and the popping of the item from the stack.
Program example 3:
The table explains the device status in the ladder diagram below.
Device
Contact state
before CJ execution
Contact state
during CJ execution
Output coil state
during CJ execution
Y, M, S
M1, M2, M3 OFF
→
Y1
*1
, M20, S1 OFF
M1, M2, M3 ON
Y1
*1
, M20, S1 ON
10ms,
100ms
Timer
*2
M4 ON M4 ON→OFF
Timer T0 immediately stops and
is latched. When M0 ON ï‚’ OFF,
100ms
accumulative
Timer T240 is not activated
M6 ON M6 ON→OFF
Timer T240 immediately stops
and is latched. When M0 ON ï‚’
OFF, T240 will still be latched.
C0~C234
*3
M7, M10 OFF
Counter C0 stops
M7 OFF, M10 is
ON/OFF triggered
M10 is ON/OFF
triggered
Counter C0 stops and latched.
When M0 is OFF, C0 resumes
Application
instruction
M11 OFF M11 OFF→ON
Application instructions will not
be executed.
M11 ON M11 ON→OFF
instruction will not be executed
but API 53~59, API 157~159
*1: Y1 is dual output. When M0 is OFF, it is controlled by M1. When M0 is ON, M12 will control Y1
*2: When timer that subroutine used (T184~T199) executes first and then CJ instruction is
executed, the timer will keep counting. After the timer reaches the set value, output contact of
timer will be ON.
*3: When high-speed counters (C235~C254) executes first and then CJ instruction is executed,
the counter will keep counting and its associated output status remains.