Application Examples For Address Offsets - Omron CP1E CPU UNIT SOFTWARE User Manual

Cp1e cpu unit software
Table of Contents

Advertisement

Program so that the memory area of the start address is not exceeded when using a
word address or symbol for the offset.
For example, write the program so that processing is executed only when the indirect
specification does not cause the final address to exceed the memory area by using
an input comparison instruction or other instruction.
If an indirect specification causes the address to exceed the area of the start address,
the system will access data in other area, and unexpected operation may occur.
4-5-2

Application Examples for Address Offsets

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, execution can be performed by increasing the address by incrementing the value in the
brackets and using only one instruction.
Ladder Program Example
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 the sums are output to D230 to D299.
Set the value of W0 to the offset word (W1) using the MOV instruction.
Use the operand of the addition instruction to specify and execute D0[W1] +
D100[W1] = D200[W1].
Increment W1 to increase the offset.
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
CP1E CPU Unit Software User's Manual(W480)
Caution
<
W1
&100
4 Understanding Programming
Repeat this process
100 times.
When execution condition a (upwardly
MOV
differentiated) turns ON, the value of W0 is
W0
set to W1.
W1
FOR
Starts FOR loop
&100
If execution condition a is ON and the
+
value of W1 is less than &100, the data
D0[W1]
from the start position until D99 and
D100[W1]
the data until D199 are added, and the
sum for each is output until D299.
D200[W1]
While execution condition a is ON, W0 is
++
incremented.
W1
NEXT
Returns to FOR
4
4-21

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the CP1E CPU UNIT SOFTWARE and is the answer not in the manual?

Questions and answers

Subscribe to Our Youtube Channel

Table of Contents

Save PDF