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
Содержание SYSMAC CX-Programmer 9
Страница 2: ......
Страница 4: ...iv ...
Страница 6: ...vi ...
Страница 8: ......
Страница 16: ...xvi ...
Страница 20: ...xx ...
Страница 26: ...xxvi Application Precautions 4 ...
Страница 27: ...Part 1 Function Blocks ...
Страница 28: ......
Страница 154: ...128 Procedures Section 3 2 ...
Страница 155: ...Part 2 Structured Text ST ...
Страница 156: ......
Страница 160: ...134 CX Programmer Specifications Section 4 2 ...
Страница 206: ...180 Procedures Section 6 1 ...
Страница 208: ...182 System defined external variables supported in function blocks Appendix A ...
Страница 230: ...204 Revision History ...
Страница 231: ......