Testing the communication
Here you can unpack the complete PLC sources: TutorialSample.zip
You can simulate the data point value changes. Setting the bChangeIO variable to TRUE enables the simulation and to FALSE disables. The new values are send cyclicaly every 3 seconds to the control station.
PROGRAM MAIN
VAR
...
bChangeIO : BOOL; (* TRUE => simulate/modify plc process data *)
timer : TON;
i : INT;
...
END_VAR
...
(*modify plc process data *)
timer( IN := bChangeIO, PT := T#3s );
IF timer.Q THEN
timer( IN := FALSE );
msgSingle_0 := NOT msgSingle_0;
msgSingle_1 := NOT msgSingle_1;
msgSingle_2 := NOT msgSingle_2;
FOR i:= 0 TO 3 DO
IF F_iecGetDPI(msgDouble_0, i) = eIEC870_DPI_ON THEN (* the value of double point allready ON? *)
msgDouble_0 := F_iecSetDPI( msgDouble_0, i, eIEC870_DPI_OFF ); (* change ON => OFF *)
ELSE
msgDouble_0 := F_iecSetDPI( msgDouble_0, i, eIEC870_DPI_ON );(* change OFF => ON *)
END_IF
END_FOR
F_iecIncVTI( msgStep_0 );
F_iecDecVTI( msgStep_1 );
msgBitStr_0 := ROL( msgBitStr_0, 1 );
msgBitStr_1 := ROR( msgBitStr_1, 1 );
msgNormalized_0 := msgNormalized_0 + 1;
msgNormalized_1 := msgNormalized_1 + 2;
msgScaled_0 := msgScaled_0 + 3;
msgScaled_1 := msgScaled_1 - 3;
msgFloating_0 := msgFloating_0 + 0.1;
msgFloating_1 := msgFloating_1 + 1.5;
msgTotal_0 := msgTotal_0 + 1;
msgTotal_1 := msgTotal_1 + 2;
END_IF
...