System parameters
Here you can unpack the complete PLC sources: TutorialSample.zip
The common ASDU address and the user functions of the substation are configured via the system parameters.
In our introduction we configure the following system parameters:
- The common ASDU address is set to 7. (asduAddr)
- During initialisation the system time of the substation is synchronised with the system time of the local TwinCAT PC (bUsePCTime).
- Synchronisation of the substation system time via the time synchronisation command is activated (bSyncTime).
- The system time of the TwinCAT PC (bSyncPCTime) should not be synchronised during synchronisation of the substation system time.
- Sending of M_EI_NA_1 (End of init) to the central station is activated (bEndOfInit).
- Sending of the periodic/cyclic data is deactivated (bPerCyclic). The base time for sending of these data is set to 5 s.
- Background scan is deactivated (bBackScan). The background scan cycle time is set to 30 s.
- Local freeze and resetting of the counter readings is activated (bPerFRZ), and the cycle time for freeze and resetting is set to 15 s.
- Logging of debugging messages in the application log is activated (dbgMode). Logging of device state changes is enabled.
Add the following PLC code to your PLC project:
IF init THEN
init := FALSE;
...
server.sysPara.asduAddr := 7;
server.sysPara.bUsePCTime := TRUE;
server.sysPara.bSyncTime := TRUE;
server.sysPara.bSyncPCTime := FALSE;
server.sysPara.bEndOfInit := TRUE;
server.sysPara.bPerCyclic := FALSE;
server.sysPara.tPerCyclicBase := T#5s;
server.sysPara.bBackScan := FALSE;
server.sysPara.tBackScanCycle := T#30s;
server.sysPara.bPerFRZ := TRUE;
server.sysPara.tPerFRZCycle := T#15s;
server.sysPara.dbgMode := (*IEC870_DEBUGMODE_ASDU OR*) IEC870_DEBUGMODE_DEVSTATE;
...
ELSE
server( pInputs := ADR( inputs ),
cbInputs := SIZEOF( inputs ),
pOutputs := ADR( outputs ),
...
END_IF
The documentation for all system parameters can be found here: ST_IEC870_5_101SystemParams.