Omron CJ2 CPU - REV 10-2010 User Manual page 180

Cj2 cpu unit software
Table of Contents

Advertisement

5 Understanding Programming
The input condition is OFF (P_Off is the Always OFF Flag), so the OUT instruction sets CIO 0.13,
which is indirectly addressed by IR0, to OFF. The OUT instruction is executed, so IR0 is incre-
mented. As a result, the PLC memory address CIO 0.14, which was incremented by +1 in the IR0, is
stored. Therefore, in the following cycle the OUT instruction turns OFF CIO 0.14.
Example 2
Ladder Program:
LD P_Off
SET, IR0+
Operation: When the PLC memory address CIO 0.13 is stored in IR0.
The input condition is OFF (P_Off is the Always OFF Flag), so the SET instruction is not executed.
Therefore, IR0 is not incremented and the value stored in IR0 remains PLC memory address CIO
0.13.
Precautions for Correct Use
Precautions for Correct Use
• When Index Registers IR0 to IR15 are used within function blocks, using the same Index Reg-
ister within other function blocks or in the program outside of function blocks will create compe-
tition between the two instances and the program will not execute properly. Therefore, when
using Index Registers (IR0 to IR15), always save the value of the Index Register at the point
when the function block starts (or before the Index Register is used), and when the function
block is completed (or after the Index Register has been used), incorporate processing in the
program to return the Index Register to the saved value.
Example: Starting function block (or before using Index Register):
1.
Save the value of IR (e.g., A).
Within function block:
2.
Use IR.
At start of function block (or before Index Register is used):
3.
Return IR to saved value (e.g., A).
• Always set the value before using Index Registers. Operation will not be stable if Index Regis-
ters are used without the values being set.
5-88
Value A
Value A
IR0
Value B
IR0
Value A
Value A
IR0
P_On
[MOVL IR0
Symbol for saving]
P_On
[MOVL
Symbol for saving IR0]
CJ2 CPU Unit Software User's Manual

Advertisement

Table of Contents
loading

Table of Contents