![background image](http://html1.mh-extra.com/html/omron/sysmac-cx-programmer-9/sysmac-cx-programmer-9_operation-manual_744241090.webp)
64
Function Block Applications Guidelines
Section 2-5
Application Examples
The following examples are for using Index Registers IR0 to IR15 within func-
tion blocks.
Example
Details
Saving the Index Register Value before Using Index Register
When Index Registers are used within this
function block, processing to save the Index
Register value is performed when the func-
tion starts (or before the Index Register is
used) to enable the value to be returned to
the original Index Register value after the
function block is completed (or after the
Index Register is used).
Example: Save the contents of Index Regis-
ter IR0 by storing it in
SaveIR[0]
(internal
variable, data type DINT, 1 array element).
Using Index Registers
1) Setting the value in the Index Register. (Stores the real I/O memory
address for first CIO Area word n.)
Example: The real I/O memory address for
the first word of CIO 1500 + unit number
×
25 allocated in the CPU Bus Unit allocation
area based on the CPU Bus Unit’s unit
number (&0 to &15) passed from the func-
tion block is stored in IR0.
Procedure:
Assumes that unit numbers &0 to &15 have
already been input (from outside the func-
tion block) in
UnitNo
(input variables, INT
data type).
1. Multiple
UnitNo
by
&25
, and store in
Off-
set
(internal variable, DINT data type)
2. Store the real I/O memory address for
SCPU_Relay
(internal variable, WORD
data type, (if required, specify the array as
400 elements (see note), AT setting =
1500)) in Index Register IR0.
Note
Specifying an array for SCPU_relay,
such as
SCPU_relay [2]
, for example,
enables the address CIO 1500 +
(
UnitNo
×
&25) + 2 to be specified.
This also applies in example 2 below.
3. Increment the real I/O memory address
in Index Register IR0 by the value for the
variable
Offset
(variable
UnitNo
×
&25).
Store IR0 temporarily in backup buffer
Calculate offset address from unit number
Summary of Contents for SYSMAC CX-Programmer 9
Page 2: ......
Page 4: ...iv ...
Page 6: ...vi ...
Page 8: ......
Page 16: ...xvi ...
Page 20: ...xx ...
Page 26: ...xxvi Application Precautions 4 ...
Page 27: ...Part 1 Function Blocks ...
Page 28: ......
Page 154: ...128 Procedures Section 3 2 ...
Page 155: ...Part 2 Structured Text ST ...
Page 156: ......
Page 160: ...134 CX Programmer Specifications Section 4 2 ...
Page 206: ...180 Procedures Section 6 1 ...
Page 208: ...182 System defined external variables supported in function blocks Appendix A ...
Page 230: ...204 Revision History ...
Page 231: ......