Omron CX-PROGRAMMER V8.1 Operation Manual page 85

Function blocks/ structured text
Table of Contents

Advertisement

Function Block Applications Guidelines
60
Note Make sure that the data size to be processed by the instruction is
the same as the number of elements. For details on the data sizes
processed by each instruction, refer to 2-7 Instruction Support and
Operand Restrictions.
2. Set the data in each of the array elements using the MOV instruction in the
function block definition.
3. Specify the first (or last) element of the array variable for the operand. This
enables specification of the first (or last) address in a range of words.
Examples are provided below.
Handling a Single String of Data in Multiple Words
In this example, an array contains the directory and filename (operand S2) for
an FREAD instruction.
• Variable Table
Input-output variable or internal variable, data type = WORD, array setting
with 10 elements, variable names = filename[0] to filename[9]
• Data Settings and Internal Function Block Processing
• Input-output variables:
Set the input parameter to the address of the first word in the data (ex-
ample: D100). The data (#5C31, #3233, #0000, etc.) is set in D100 to
D109 in advance from the main user program.
FREAD (omitted) (omitted) read_num[0] (omitted)
• Internal variables:
Use ladder programming within the function block to set data into the
array.
MOV #5C31 file_name[0]
Set data in each array element.
MOV #3233 file_name[1]
MOV #0000 file_name[2])
FREAD (omitted) (omitted) file_name[0] (omitted)
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
Input-output variable or internal variable, data type = DINT, array setting
with 3 elements, variable names = read_num[0] to read_num[9]
• Data Settings and Internal Function Block Processing
• Input-output variables:
Set the input parameter to the address of the first word in the data (ex-
ample: D200). The data is set in D200 to D205 in advance from the
main user program.
FREAD (omitted) read_num[0] (omitted) (omitted)
• Internal variables:
Use ladder programming within the function block to set data into the
array.
• 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)
Specify the first element of the array
in the instruction operand.
Specify the first element
of the array in the instruction
operand.
Specify the first element of the array
in the instruction operand.
Set data in each array element.
Specify the first element of the array
in the instruction operand.
Section 2-5

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