Page top

Lead Contents

FAQ02836 of Programmable Controllers FAQ

FAQ No. FAQ02836

Primary Contents

Question

Can the same DM address be used for the first and third, or second and third operand in a math instruction?

Answer



Yes. As shown in Figure 1, in a differentiated program where processing is completed with a single scan by turning ON the add command bit (CIO 0.00), there is no problem if the first (or second) operand are the same as the third operand, but after processing, the augend data stored in D100 will be deleted. For easy debugging or software maintenance, it is recommended to use a different DM Area address for the third operand.

Programming: CS1/CJ1-series Programmable Controllers

Figure 1

Explanation of Figure 1

Initially, the value 123 (BCD) is stored in D100, but when add command bit (CIO 0.00) turns ON, the addition process given below is executing in a single scan, and the value stored in D100 will be changed from 123 to 246.

123 (D100) + 123 (constant) = 246 (D100)

Note:The instruction in Figure 1 will execute each cycle. So when you want to perform the operation A + B = C in realtime when the add command bit (CIO 0.00) is turned ON, the DM address of C must be different from that of A and B. If the same address is used, the result data will be updated as many times as the instruction is scanned causing an incorrect value to be stored in the third operand.