Specifying Addresses Allocated To Special I/O Units - Omron CX-PROGRAMMER 5.0-FUNCTION BLOCK OPERATION Operation Manual

Function blocks
Table of Contents

Advertisement

Function Block Applications Guidelines
Division Using Integer
Array Variables (Ladder
Programming Only)
Note
2-4-5

Specifying Addresses Allocated to Special I/O Units

Note
1,2,3...
Handling Control Data in Multiple Words
In this example, an array contains the number of words and first source word
(operand S1) for an FREAD instruction.
• Variable table
Internal variable, data type = DINT, array setting with 3 elements, variable
names = read_num[0] to read_num[9]
• Ladder programming
MOVL &100 read_num[0] (No._of_words)
MOVL &0 read_num[1] (1st_source_word)
FREAD (omitted) read_num[0] (omitted) (omitted)
Handling a Block of Read Data in Multiple Words
The allowed amount of read data must be determined in advance and an
array must be prepared that can handle the maximum amount of data. In this
example, an array receives the FREAD instruction's read data (operand D).
• Variable table
Internal variable, data type = WORD, array setting with 100 elements,
variable names = read_data[0] to read_data[99]
• Ladder programming
FREAD (omitted) (omitted) (omitted) read_data[0]
A two-element array can be used to store the result from a ladder program's
SIGNED BINARY DIVIDE (/) instruction. The result from the instruction is D
(quotient) and D+1 (remainder). This method can be used to obtain the remain-
der from a division operation in ladder programming.
When ST language is used, it isn't necessary to use an array to receive the
result of a division operation. Also, the remainder can't be calculated directly
in ST language. The remainder must be calculated as follows:
Remainder = Dividend − (Divisor × Quotient)
Use Index Registers IR0 to IR15 (indirectly specified constant offset) to spec-
ify addresses allocated to Special I/O Units based on the value passed for the
unit number as an input parameter within the function block definition as
shown in the following examples.
For details on using Index Registers in function blocks, refer to 2-4-6 Using
Index Registers.
Examples
Example 1: Specifying the CIO Area within a Function Block (Same for DM
Area)
Special I/O Units
Variables: Use the unit number as an input variable, and specifying the first
allocation address as an internal variable with the AT set to CIO 2000.
Programs: Use the following procedure.
1. Multiply the unit number (input variable) by &10, and create the unit num-
ber offset (internal variable, DINT data type).
2. Use the MOVR(560) (MOVE TO REGISTER) instruction to store the real I/
O memory address for the first allocation address (internal variable, AT =
CIO 2000) in the Index Register (e.g., IR0).
Set data in each array element.
Specify the first element of the array
in the instruction operand.
Section 2-4
45

Hide quick links:

Advertisement

Table of Contents
loading

This manual is also suitable for:

Cx-programmer 5.0Sysmac ws02-cxpc1-e-v50Cs1-hCj1-hCj1m

Table of Contents