Page top

Lead Contents

FAQ02260 of Programmable Controllers FAQ

FAQ No. FAQ02260

Primary Contents


The address does not update correctly with IR1 in a program using the index register as shown in Figure 1. Why?


Ladder Program Operation Specifications

Before explaining the problems with the ladder program, we will explain the system operation specifications.

*When one of the pushbutton switches from 1 to 32 is pressed, the two words of input data (4-digit BCD data) will be stored in D100 to D131 as shown in the following example.

Programming: CS1/CJ1-series Programmable Controllers

Figure 1

The Problem with the Ladder Program

So what is the problem with the ladder program?

To get to the point, there is a problem in the usage of the auto increment option/,IR1+ in --[MOV 2,IR1+] on rung number 10 of the ladder program.

What is the ,IR1[]+ auto increment option?

,IR[]+: The contents of IR[] will be incremented by 1 immediately after accessing the contents of the address that IR[] points to.

The ladder program in Figure 1 works like this. Immediately after the -- [MOV 2 ,IR+1] instruction on rung 10 is executed, the address in IR[] is incremented by 1. In this program, when the --| |--,IR0+ input condition is OFF, the MOV instruction will not be executed. Therefore the auto-increment process will also not be executed. This is the reason why the address update process using IR1 does not function properly.

Note:This problem will not occur with instructions that are executed each scan regardless of the execution condition, such as with --||-- ,IR0+ or with -- (,IR[]+) OUT (which does not appear here).

Example of Program in Which the IR1 Address Is Updated Every Scan

Programming: CS1/CJ1-series Programmable Controllers

Figure 2


1.Remove the "+" option from the -- [MOV 2 ,IR1+] instruction to change the instruction to -- [MOV 2 ,IR1] as shown in Figure 2.

2.By using a NO input condition for the Always ON Flag (P_On) together with -- [++L IR1], the address in IR[] will be incremented for every scan of the FOR-NEXT loop.

++L instruction

DOUBLE INCREMENT BINARY instruction. Increments the 8-digit hexadecimal content of two words of data by 1.

*Here, the address (32 bits) stored in IR1 is incremented by 1.