FB_WriteCouplerRegs
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 to write all the registers (0.255) of a table of the coupler. The register values to be written are 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 ).
VAR_INPUT
VAR_INPUT
stState : PLCINTFSTRUCT;
nTerminal : BYTE := TERM_COUPLER;
nTable : BYTE;
nStartReg : BYTE;
nEndReg : BYTE;
bExecute : BOOL;
stCouplerTable : ST_CouplerTable;
tTimeout : TIME;
END_VAR
stState : Status word of the 2-byte PLC interface.
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.
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.
VAR_OUTPUT
VAR_OUTPUT
stCtrl : PLCINTFSTRUCT;
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
stCtrl : Control word of the 2-byte PLC interface.
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. (Table of possible error codes).
Requirements
Development environment | Target system type | IO Hardware | PLC libraries to include |
---|---|---|---|
TwinCAT Version 2.7.0 Build > 518 TwinCAT Version 2.8.0 Build > 737 | PC (i386) | All couplers with 2- byte PLC interfaces | Standard.Lib; TcPlcCoupler.Lib |