48
Function Block Applications Guidelines
Section 2-4
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 CS1-H Series
Page 3: ...iv...
Page 5: ...vi...
Page 7: ...viii TABLE OF CONTENTS...
Page 15: ...xvi Application Precautions 4...
Page 151: ...136 Procedures Section 3 2...
Page 153: ...138 Data Types Appendix A...
Page 177: ...162 External Variables Appendix C...
Page 181: ...166 Revision History...