Calling and declaration of the central station

The entire functionality of a central station is encapsulated in the function block FB_IEC870_5_104Master. 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 MAIN:

PROGRAM MAIN
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_104Master;

END_VAR

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,
hTable := hTable );
...
END_IF

The associated PLC example tutorial can be downloaded here.