4 Understanding Programming
4-28
CP2E CPU Unit Software User’s Manual(W614)
The input condition is OFF (P_Off is the Always OFF Flag), so the SET instruction is not exe-
cuted. Therefore, IR0 is not incremented and the value stored in IR0 remains PLC memory
address CIO 0.13.
• The following instructions are executed even when the interlock is active. Therefore, when indi-
rect memory addresses are specified using auto-incrementing or auto-decrementing (,IR+ or
,IR-) in an operand of any of these instructions, the value in the Index Register (IR) is
refreshed each cycle regardless of the input condition (increases or decreases one every
cycle). This must be considered when writing a program.
Precautions for Correct UsePrecautions 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.
• Always set the value before using Index Registers. Operation will not be stable if Index Regis-
ters are used without the values being set.
Precautions for Correct UsePrecautions for Correct Use
Precaution for Indirect Register Addressing with Index Registers
Do not use indirect register addressing to access areas outside of the I/O memory or areas
reserved by the system. An Illegal Access Error will occur if access is attempted.
Refer to A-4 Memory Map of PLC Memory Addresses for details on the limits of PLC memory
addresses.
Instruction group Instructions
Sequence output instructions OUT, OUT NOT
Timer and counter instructions TIM/TIMX, TIMH/TIMHX, TMHH/TMHHX, and
TIML/TIMLX
IR0
IR0
IR0
P_On
P_On
Example: Starting function block (or before using Index Register):
1.
Save the value of IR (e.g., A).
Value A
Value 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).
Value A
Value A
Value B
Symbol for saving] [MOVL IR0
Symbol for saving IR0] [MOVL