![background image](http://html1.mh-extra.com/html/omron/cs1-h-series/cs1-h-series_operation-manual_742526060.webp)
45
Function Block Applications Guidelines
Section 2-4
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
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
Division Using Integer
Array Variables (Ladder
Programming Only)
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.
Note
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)
2-4-5
Specifying Addresses Allocated to Special I/O Units
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.
Note
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,2,3...
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.
FREAD (
omitted
) read_num[0] (
omitted
) (
omitted
)
MOVL &100 read_num[0] (
No._of_words
)
MOVL &0 read_num[1] (
1st_source_word
)
FREAD (
omitted
) (
omitted
) (
omitted
) read_data[0]
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...