Omron CX-PROGRAMMER V8.1 Operation Manual page 89

Function blocks/ structured text
Table of Contents

Advertisement

Function Block Applications Guidelines
Application Examples
Saving the Index Register Value before Using Index Register
Store IR0 temporarily in backup buffer
Using Index Registers
1) Setting the value in the Index Register. (Stores the real I/O memory
address for first CIO Area word n.)
Calculate offset address from unit number
64
The following examples are for using Index Registers IR0 to IR15 within func-
tion blocks.
Example
Details
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).
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
Section 2-5
×
×
&25).

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Sysmac ws02-cxpc1-v8Sysmac cx-programmer 8.1

Table of Contents