6-39
6 Programming
NJ-series CPU Unit Software User’s Manual (W501)
6-3 Variables
6
6-3-6 Derivative Data Types
A derivative data type has a configuration that is based on one of the basic data types. The following is
a list of the derivative data types.
• Structures
• Unions
• Enumerations
Refer to 6-3-12 Restrictions on Variable Names and Other Program-related Names for restrictions on
the number of characters in data type names and other restrictions when you create a derivative data
type.
NJ-series Controllers come with three different types of system-defined derivative data types.
• System-defined variables that are structures
• Structures used for input, output, and in-out variables for instructions
• Structures for Special Unit expansion memory (You must register these in the Unit Editor to
use them.)
A structure is a derivative data type that groups together data with the same or different variable types.
You can easily change data and add new data if you place your data into a structure.
For example, you can define a “Box” structure that has three members (Width, Height, and Depth) in
order to organize and group your data.
You can then use this structure data type to add a variable called Box1. You can then use it to access
the different levels of the data by placing a period after the variable name followed by the name of the
data you want to access. For example, Box1.Width or Box1.Height.
If you need to create a new variable to store more box data, you can perform the same steps to add a
new variable called Box2 to the variable table.
When a structure is used for a variable in an instruction, it is necessary to select a structure for the input
parameter, output parameter, or in-out parameter, and register the variable.
Example: Communications Instructions
6-3-6 Derivative Data Types
Structures
Height
Width
Depth
Structure Variable Box1
Height
Width
Depth
Height
Width
Depth
Structure Variable Box2 Structure Variable Box3
Height of Box1
Height of Box2 Height of Box