Instruction Set
S: The destination pointer P of the conditional jump Explanations:
1. If users need to skip a particular part of PLC program in order to shorten the scan time and execute dual outputs, CJ instruction or CJP instruction can be adopted.
2. When the program designated by pointer P is prior to CJ instruction, WDT timeout will occur and PLC will stop running. Please use it carefully.
3. CJ instruction can designate the same pointer P repeatedly. However, CJ and CALL cannot designate the same pointer P; otherwise operation error will occur
4. Actions of all devices while conditional jump is being executed:
a) Y, M and S remain their previous status before the conditional jump takes place. b) 10ms and 100ms timer that is executing stops.
c) Timer T192 ~ T199 that execute the subroutine program will continue and the output contact executes normally.
d) The high-speed counter that is executing the counting continues counting and the output contact executes normally.
e) General counters stop executing.
f) If timer is reset before CJ instruction executes, the timer will still be in the reset status while CJ instruction is being executed.
g) The application instructions that are being executed, i.e. DHSCS, DHSCR, DHSZ, SPD, PLSY, PWM, PLSR, PLSV, DRVI, DRVA, continue being executed.
Program example 1:
When X0 = ON, the program will skip from address 0 to N (Pointer P1) automatically and keep on executing. Instructions between address 0 and N will be skipped..
When X0 = OFF, program flow will proceed with the row immediately after the CJ instruction.
X0 X1 X2 CJ P1 Y1 Y2 0 N P1 P*** (CJ instruction) Program example 2:
1. The instruction CJ between the instruction MC and the instruction MCR can be used in the five conditions below.
a). The execution of the program jumps from the part of the program outside one MC/MCR loop to the part of the program outside another MC/MCR loop.
b). The execution of the program jumps from the part of the program outside the MC/MCR loop to the part of the program inside the MC/MCR loop.
c). The execution of the program jumps from the part of the program inside the MC/MCR loop to the part of the program inside the MC/MCR loop.
d). The execution of the program jumps from the part of the program inside the MC/MCR loop to the part of the program outside the MC/MCR loop.
e). The execution of the program jumps from the part of the program inside one the MC/MCR loop to the part of the program inside another the MC/MCR loop.
X0 MC N0 X2 X3 X1 M1000 M1000 P1 P0 CJ CJ MC N1 N1 N0 P1 P0 Y1 Y0 MCR MCR
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
M1, M2, M3 OFF M1, M2, M3 OFFON Y1 *1, M20, S1 OFF Y, M, S
M1, M2, M3 ON M1, M2, M3 ONOFF Y1 *1, M20, S1 ON
M4 OFF M4 OFFON Timer is not activated
10ms, 100ms
Timer*2 M4 ON M4 ONOFF
Timer T0 immediately stops and is latched. When M0 ON OFF, T0 will be reset.
M6 OFF M6 OFFON Timer T240 is not activated
1ms,10ms, 100ms accumulative Timer
M6 ON M6 ONOFF
Timer T240 immediately stops and is latched. When M0 ON OFF, T240 will still be latched.
M7, M10 OFF M10 is ON/OFF
triggered Counter C0 stops
C0~C234 *3
M7 OFF, M10 is ON/OFF triggered
M10 is ON/OFF triggered
Counter C0 stops and latched. When M0 is OFF, C0 resumes counting.
M11 OFF M11 OFFON Application instructions will not
be executed. Application
instruction
M11 ON M11 ONOFF
The skipped application instruction will not be executed but API 53~59, API 157~159 keep executing.
*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.
Y1 is a dual output. When M0 = OFF, Y1 is controlled by M1. M0 = ON, Y1 is controlled by M12. CJ P0 M0 M1 M2 M4 M5 M6 M7 M10 M11 M0 M12 M13 END RST T240 RST C0 RST D0 Y1 CJ P63 S1 TMR T0 K10 RST T240 RST C0 MOV K3 D0 CNT C0 K20 Y1 M20 TMR T240 K1000 P0 P63 M3
API Mnemonic Operands Function
01 CALL P Call Subroutine
Controllers ES2/EX2 SS2 SA2
SE SX2
OP Valid Range Program Steps
P0~P255 CALL, CALLP: 3 steps
PULSE 16-bit 32-bit ES2/EX2 SS2 SA2 SE SX2 ES2/EX2 SS2 SA2 SE SX2 ES2/EX2 SS2 SA2 SE SX2 Operands:
S: The destination pointer P of the call subroutine.