WRITE_CMD Examples
(Original Document)
Example 1: Initializing Faults
To initialize faults on the bus ring of module 4 in rack 1: declare the Ring IODDT as type T_CSY_RING and associate to channel 0 of the TSX CSY 84 or TSX CSY 164 module in rack 1, slot 4:
!
(*If WRITE_CMD not in progress, then initialization of faults*)
IF NOT Ring.CMD_IN_PROGR THEN Ring.ACTION_CMD:= 409;
WRITE_CMD(Ring);
END_IF;
Example 2: Writing the Optical Power
To define (write) the optical power. We use the same IODDT:
!
(*If WRITE_CMD not in progress, then writing (set) of the optical power*)
IF NOT Ring.CMD_IN_PROGR THEN Ring.ACTION_CMD:= 2545;
Ring.PARAM_CMD_3:= 51.5;
//Parameter 3: optical power = 51.5
WRITE_CMD(Ring);
END_IF;
Example 3: Reading the transmission ratio
To read the transmission ratio (BAUD_RATE):
!
(*If WRITE_CMD not in progress, then reading (get) of the transmission ratio*)
IF NOT Ring.CMD_IN_PROGR THEN Ring.ACTION_CMD:= 1551;
WRITE_CMD(Ring);
END_IF;
!
(*If WRITE_CMD has been completed and if there is no fault, then the value of the transmission ratio is accessible in return 1*)
IF NOT Ring.CMD_IN_PROGR AND NOT Ring.CMD_ERR
THEN BAUD_RATE: = Ring.RETURN_CMD_1;
//transmission ratio in return 1
END_IF;
Example 4: Moving a real axis
Moving the real axis 3 from module 4 set in rack 1, at position 105.2, at speed 5 with the command "MOVE absolute immediate". We declare the Axis_3 IODDT of type T_CSY_IND and associate it with channel 3 of module 4 of rack 1:
!
(*If WRITE_CMD not in progress, then move real axis 3*)
IF NOT Axis_3.CMD_IN_PROGR THEN Axis_3.ACTION_CMD:= 513;
Axis_3.PARAM_CMD_1:= 0;
//Parameter 1: type of movement = absolute
Axis_3.PARAM_CMD_3:= 105.2;
//Parameter 3: position = 105.2
Axis_3.PARAM_CMD_4:= 5.0;
//Parameter 4: speed = 5
WRITE_CMD(Axis_3);
END_IF;
Example 5: Reading the position of a slave
Read the relative position of a follower slave when the master is at 102.5. We declare the IODDT Follow of type T_CSY_FOLLOW and associate it with the channel corresponding to the follower slave:
!
(*If WRITE_CMD not in progress, then reading the position of the follower slave*)
IF NOT Follow.CMD_IN_PROGR THEN Follow.ACTION_CMD:= 537;
Follow.PARAM_CMD_3:= 102.5;
//Parameter 3: position of the master = 102.5
WRITE_CMD(Follow);
END_IF;
!
(*If WRITE_CMD has been completed and if there is no fault, then the position of the slave is accessible in return 2*)
IF NOT Follow.CMD_IN_PROGR AND NOT Follow.CMD_ERR
THEN SLAVE_POSITION:=Follow.RETURN_CMD_2;
//position in return 2
END_IF;