Download SYSMAC CX-Programmer Ver. 9._ OPERATION MANUAL
Transcript
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). FREAD (omitted) (omitted) (omitted) read_data[0] • Internal variables: FREAD (omitted) (omitted) (omitted) read_data[0] Division Using Integer Array Variables (Ladder Programming Only) Note 2-5-5 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 remainder 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) Specifying Addresses Allocated to Special I/O Units Use Index Registers IR0 to IR15 (indirectly specified constant offset) to specify 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 number 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. 63