Declaring and calling an instance of the IEC60870-5-101 controlling station
The entire functionality of a central station is encapsulated in the function block FB_IEC870_5_101Master. A connection to the substation can be established with an instance. For a further connection, declare a further instance of the function block.
Insert the following PLC code in the declaration part of P_MAIN_LowSpeed:
PROGRAM P_MAIN_LowSpeed
VAR
AODB : ARRAY[0..49] OF ST_IEC870_5_101AODBEntry;
hTable : T_HAODBTable;
init : BOOL := TRUE;
initError : UDINT;
asduAddr : UDINT := 7;
inputs AT%IB0 : ARRAY[0..2999] OF BYTE;
outputs AT%QB0 : ARRAY[0..2999] OF BYTE;
memory AT%MB0 : ARRAY[0..2999] OF BYTE;
data : ARRAY[0..2999] OF BYTE;
bEnable : BOOL := TRUE;
client : FB_IEC870_5_101Master;
END_VAR
and the instance is called in the program part:
IF init THEN
init := FALSE;
...
ELSE
...
client( pAOEntries := ADR( AODB ),
cbAOEntries := SIZEOF( AODB ),
pInputs := ADR( inputs ),
cbInputs := SIZEOF( inputs ),
pOutputs := ADR( outputs ),
cbOutputs := SIZEOF( outputs ),
pMemory := ADR( memory ),
cbMemory := SIZEOF( memory ),
pData := ADR( data ),
cbData := SIZEOF( data ),
bEnable := bEnable,
hSerial := P_SerialComm_HighSpeed.hSerial,
hTable := hTable );
...
END_IF