3-15
3 I/O Ports, Slave Configuration, and Unit Configuration
NJ-series CPU Unit Software User’s Manual (W501)
3-4 Allocating Variables to Units
3
3-4-2 Using Variables Assigned to Units
You can specify members of the variables that you assign to Units to specify some of the Unit attributes.
Example: Executing an Instruction with the Unit Number of an NX Unit
The following programming example reads a data object from an NX Unit if the NX Unit number of the
NX Unit to which the NX1 variable is assigned is 2. The NX1.UnitNo member gives the NX Unit number.
IF (NX1.UnitNo = UINT#2) THEN
NX_ReadObj_instance(Execute:=TRUE, UnitProxy:=NX1, Obj:=S_Obj, ReadDat:=Rdat);
END_IF;
To designate more than one Unit, you can specify the elements of an array of the variables that are
assigned to the Units. This allows you to use loop processing to perform the same process for more
than one Unit.
Example: The following programming example changes multiple NX Units to the mode that enables
writing data.
NX0, NX1, and NX2 are the variables that were assigned to the NX Units. The variables are assigned to
the elements of the NXTable[0..2] and then the NX_ChangeWriteMode instruction is executed in order
for each.
FOR i:= 0 TO 2 DO
NX_ChangeWriteMode_instance[i](Execute:=FALSE);
END_FOR;
NXTable[0] := NX0;
NXTable[1] := NX1;
NXTable[2] := NX2;
FOR i:= 0 TO 2 DO
NX_ChangeWriteMode_instance[i](Execute:=TRUE, UnitProxy:=NXTable[i]);
END_FOR;
Designating Unit Attributes
Designating More Than One Unit