FB_WriteCouplerRegs 1:

This function block provides write access to the table register in the coupler and the registers of the intelligent terminals. The coupler itself is referred to as terminal 0 (null). All the other terminals in the terminal block, with the exception of passive terminals (such as power feed terminals), are counted in ascending sequence (beginning with 1) . It is possible either to write all registers, or only a partial region (between nStartReg and nEndReg). Several seconds are required in order to write all the registers (0.255) of a table of the coupler. The register values to be written are located in the structure stCouplerTable.The structure is an array of high and low bytes. Each array element corresponds to a register value (e.g.: stCouplerTable[ 5 ] == Register 5 ).


    stState        : PLCINTFSTRUCT;
    nTerminal      : BYTE := TERM_COUPLER;
    nTable         : BYTE;
    nStartReg      : BYTE;
    nEndReg        : BYTE;
    bExecute       : BOOL;
    stCouplerTable : ST_CouplerTable;
    tTimeout       : TIME;

stState : Status word of the 2-byte PLC interface. (PLCINTFSTRUCT)

nTerminal : Terminal number, to whose table register access is to be made. The coupler has terminal number null. Passive terminals are not to be counted.

nTable : Table number whose register values are to be written. Intelligent terminals only have one table for each terminal channel. A 4-channel terminal has the following table numbers: 0-3. An intelligent terminal, however, only possesses a maximum of 64 register values for each terminal channel!

nStartReg : The number of the first register that is to be written.

nEndReg : The number of the last register that is to be written.

stCouplerTable : Register value array to be written (ST_CouplerTable).

bExecute: The function block is activated by a positive edge at this input.

tTimeout: States the length of the timeout that may not be exceeded during execution of the function.


    stCtrl   : PLCINTFSTRUCT;
    bBusy    : BOOL;
    bError   : BOOL;
    nErrId   : UDINT;

stCtrl : Control word of the 2-byte PLC interface. (PLCINTFSTRUCT)

bBusy: This output is set when the block is activated, and remains set until execution of the function has been completed.

bError: If an error should occur during the execution of the function, then this output is set, after the bBusy output has been reset.

nErrId : Supplies the error number when the bError output is set.

Error number

Error description


No error


Error at initialisation of the communication via the 2 byte PLC interface


Error during communication


Timeout-Error. The permitted execution time was exceeded


Wrong parameter value at register number


Wrong parameter value at table number


Development environment

Target system type

PLC libraries to include (category group)

TwinCAT v3.1.0

PC or CX (x86, x64, ARM)

Tc2_Coupler (IO)