Omron NJ-series User Manual page 232

Machine automation controller cpu unit software
Hide thumbs Also See for NJ-series:
Table of Contents

Advertisement

Name
My Union
Variable Table
Variable name
Output
Output.bit[0]:
Output.data:
Specifying the Union
The union represents all members that make up the union. Unions are expressed by the name of the
union variable. In the example above, you would write Output.
 Creating Unions
1
Create a union data type in the Union Table.
Specify the data type names and different data types of the members of the union.
2
Specify the union data type from above as the data type and register the variable in the variable
table.
Example:
Here, OUT16_ACCESS is defined as the data type of a union. The members of this union are a
BOOL array with 16 elements and a WORD variable. The variable Output is registered with a data
type of OUT16_ACCESS. You can now read/write variable Output as a BOOL value for any of the 16
bits and as a WORD value.
Data Type Definitions
Name
OUT16ACCESS
Variable name
Output
Output.WordData := WORD#16#1234;
BoolData
ByteData
WordData
Output.BoolData[11] :=TRUE;
BoolData
ByteData
WordData
NJ-series CPU Unit Software User's Manual (W501)
Member
data
bit
Data type
My Union
This notation specifies the 0th element, or value at bit 00, of union Output when it is treated
as a 16-bit BOOL array variable.
This notation specifies the value when union Output is treated as a single WORD variable.
Member
Data type
BoolData
ARRAY[0..15] of BOOL
ByteData
ARRAY[0..1] of BYTE
WordData WORD
Data type
OUT16ACCESS
15
14
13
12
11
0
0
0
1
0
16#12
15
14
13
12
11
*
*
*
*
1
Bit 04 of ByteData[1] is TRUE
Data type
WORD
ARRAY [0..15] OF BOOL
BoolData
BoolData
[15]
[8]
ByteData
[1]
10
9
8
7
6
0
1
0
0
0
16#1234
10
9
8
7
6
*
*
*
*
*
Bit 11 of WordData is TRUE
6 Programming
BoolData
BoolData
[0]
[7]
ByteData
[0]
WordData
5
4
3
2
1
1
1
0
1
0
16#34
5
4
3
2
1
*
*
*
*
*
No change
6
0
0
0
*
6-45

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents