FB_ReadCouplerRegs
This function block FB_ReadCouplerRegs provides read 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 supply terminals), are counted in ascending sequence (beginning with 1). All registers or only a subrange (between nStartReg and nEndReg) can be read. Several seconds are required to read all registers (0.255) of a coupler table. Register values that have been successfully read are found 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;
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 read. |
nEndReg | BYTE | The number of the last register to be read. |
bExecute | BOOL | The function block is enabled by a positive edge at this input. |
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;
stCouplerTable : ST_CouplerTable;
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 |
Name | Type | Description |
---|---|---|
stCouplerTable | Structure with the read register values of the terminal or coupler. |
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) |