FB_WriteCouplerRegs
The function block FB_WriteCouplerRegs can be used for write access to the coupler's table registers 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 supply terminals), are counted in ascending sequence (beginning with 1). All registers or only a subrange (between nStartReg and nEndReg) can be written to. Several seconds are required to write all registers (0.255) of a coupler table. 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).
Inputs
VAR_INPUT
stState : PLCINTFSTRUCT;
nTerminal : BYTE := TERM_COUPLER;
nTable : BYTE;
nStartReg : BYTE;
nEndReg : BYTE;
bExecute : BOOL;
stCouplerTable : ST_CouplerTable;
tTimeout : TIME;
END_VAR
Name | Type | Description |
---|---|---|
stState | Status word of the 2-byte PLC interface. | |
nTerminal | BYTE | Terminal number whose table register is to be accessed. The coupler has terminal number null. Passive terminals are not to be counted. |
nTable | BYTE | Table number whose register values are to be read. Intelligent terminals only have one table for each terminal channel. A 4-channel terminal has the following table numbers: 0-3. However, an intelligent terminal only has a maximum of 64 register values per terminal channel. |
nStartReg | BYTE | The number of the first register to be written. |
nEndReg | BYTE | The number of the last register to be written. |
bExecute | BOOL | The function block is enabled by a positive edge at this input. |
stCouplerTable
| Array of the register values to be written. | |
tTimeout | TIME | Specifies the time-out period that must not be exceeded when the function is executed. |
Outputs
VAR_OUTPUT
stCtrl : PLCINTFSTRUCT;
bBusy : BOOL;
bError : BOOL;
nErrId : UDINT;
END_VAR
Name | Type | Description |
---|---|---|
stCtrl | Control word of the 2-byte PLC interface. | |
bBusy | BOOL | When the function block is activated, this output is set and remains set until the function is completed. |
bError | BOOL | If an error occurs during the execution of the function, this output is set after the bBusy output has been reset. |
nErrId | UDINT | Supplies the error number when the bError output is set. |
Error number | Error description |
---|---|
0 | No error |
0x100 | Error at initialisation of the communication via the 2 byte PLC interface |
0x200 | Error during communication |
0x300 | Timeout-Error. The permitted execution time was exceeded |
0x400 | Wrong parameter value at register number |
0x500 | Wrong parameter value at table number |
Requirements
Development environment |
Target system type |
PLC libraries to include (category group) |
---|---|---|
TwinCAT v3.1.0 |
PC or CX (x86, x64, ARM) |
Tc2_Coupler (IO) |