Omron CJ2 CPU UNIT SOFTWARE User Manual page 150

Cj2 cpu unit software
Hide thumbs Also See for CJ2 CPU UNIT SOFTWARE:
Table of Contents

Advertisement

5 Understanding Programming
User-defined Data Types (Data Structures)
When using CX-Programmer version 9.0 or higher with a CJ2 CPU Unit, you can create data structures
as user-defined data types.
Data Structures
A data structure is a user-defined data type that groups more than one data type. Names can be
assigned to the data types. The name of the variable that uses a user-defined data type is specified
along with the name of one of the variables within the data structure. The overall data structure is
called a structure variable and the variables within the data structure are called members.
Additional Information
• Arrays can also be used to handle multiple pieces of data. An array data type, however, is dif-
ferent from a data structure in that it contains data with the same data type that is accessed by
specifying an offset from the beginning of the array. With a data structure, data with the same
or with different data types is accessed using member names. Also, with the CX-Programmer,
structure data types can be assigned names.
• Structure variables can be placed in arrays.
• Also, array variables can be used as members of data structures.
Ladder Program Notation and Input for Structure Variables
In a Ladder Program, the structure variable name and member name are separated by a period.
Example:
S1 . A
Applications of Data Structures
When you specify data that is grouped, you specify a member of a specific group. In other words,
you can specify data in a hierarchy in the form "main - sub."
Using Data Structures without Arrays
Example for Structure Variables S1, S2, and S3 Each with Members A, B, and C
Structure variable S1
Member
A
C
B
C
5-58
Means "member A of S1."
Member name
Period
Structure variable name
A of S1
Structure variable S2
Member
A
C
B
C
A of S2
A of S3
Structure variable S3
Member
A
C
B
C
CJ2 CPU Unit Software User's Manual

Advertisement

Table of Contents
loading

Table of Contents