Examples Of Address Offset Application - Omron CJ2 CPU UNIT SOFTWARE User Manual

Cj2 cpu unit software
Hide thumbs Also See for CJ2 CPU UNIT SOFTWARE:
Table of Contents

Advertisement

5-8-2

Examples of Address Offset Application

It is possible to dynamically specify the offset by specifying a word address in I/O memory for the offset
in the brackets. The contents of the specified word address will be used as the offset. For example, exe-
cution can be performed by increasing the address by incrementing the value in the brackets and using
only one instruction.
Example of Ladder Programming
In this example, two areas of consecutive data are used: D0 to D99 and D100 to D199. The contents
of corresponding words are added starting from the specified starting point, W0, to the end of the
areas and the sums are output to D200 to D299 starting from the specified offset from D200. For
example, if W0 is 30, the corresponding words from D30 to D99 and D130 to D199 are added, and
output the sums are output to D230 to D299.
The offset, W1, is set to the value of W0 using a MOV instruction.
Execution is performed by specifying D0[W1] + D100[W1] = D200[W1]
using an ADD instruction.
The offset (W1) is incremented.
Each process is performed with an input comparison instruction (<) as the execution condition so
that W1 does not exceed &100 to make sure that the upper limit of the indirect addressing range is
not exceeded.
Execution condition
a
Execution condition
a
CJ2 CPU Unit Software User's Manual
<
W1
&100
5 Understanding Programming
100 repetitions max.
MOV
When execution condition a
(upwardly differentiated) turns
W0
ON, the value of W0 is set to W1.
W1
FOR
Starts FOR loop
&100
If execution condition a is ON and
+
the value of W1 is less than &100,
D0[W1]
the data from the start position until
D100[W1]
D99 and the data until D199 is
D200[W1]
added, and the sum for each is
output until D299.
+
While execution condition a is ON,
+
W0 is incremented.
W1
NEXT
Return from FOR loop
5
5-97

Advertisement

Table of Contents
loading

Table of Contents