61
Function Block Applications Guidelines
Section 2-5
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
Input-output variable or internal variable, data type = WORD, array setting
with 100 elements, variable names = read_data[0] to read_data[99]
• Data Settings and Internal Function Block Processing
• Input-output variables:
Set the input parameter to the address of the first word in the read data
(example: D200).
• Internal variables:
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-5-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-5-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).
3.
Add the unit number offset to the real I/O memory address within the Index
Register (e.g., IR0).
Example 2: Specifying the Designated Bit in the CIO Area (e.g., CIO Word
n+a, Bit b)
Programs: Use either of the following methods.
FREAD (
omitted
) (
omitted
) (
omitted
) read_data[0]
FREAD (
omitted
) (
omitted
) (
omitted
) read_data[0]
Содержание 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: ......