ModbusRtuSlave_KL6x22B
The function block ModbusRtuSlave_KL6x22B
realizes a Modbus slave, which communicates via a serial Bus Terminal KL6031 or KL6041. Serial EtherCAT Terminals with 22 bytes of data process image are also supported. The function block ModbusRtuSlave_PcCOM is available for communication via a serial PC interface (COM port).
The function block is passive until it receives telegrams from a connected Modbus master.
![]() | Hardware connection The data structures required for the link with the communication port are included in the function block. On a PC, the assignment in the TwinCAT System Manager is analogous to the description in the chapter Serial bus terminal of the TF6340 TC3 Serial Communication documentation. |
Inputs
VAR_INPUT
UnitID : UINT;
AdrInputs : POINTER TO BYTE; (* Pointer to the Modbus input area *)
SizeInputBytes : UINT;
AdrOutputs : POINTER TO BYTE; (* Pointer to the Modbus output area *)
SizeOutputBytes : UINT;
AdrMemory : POINTER TO BYTE; (* Pointer to the Modbus memory area *)
SizeMemoryBytes : UINT;
END_VAR
Name | Type | Description |
---|---|---|
UnitID | UINT | Modbus station address (1..247). The Modbus slave will only answer if it receives telegrams containing its own station address. Optionally, collective addresses can be used for replying to any requests. Address 0 is reserved for broadcast telegrams and is therefore not a valid station address. |
AdrInputs | BYTE | Start address of the Modbus input area. The data area is usually declared as a PLC array, and the address can be calculated with ADR (input variable). |
SizeInputBytes | UINT | Size of the Modbus input array in bytes. The size can be calculated with SIZEOF (input variable). |
AdrOutputs | BYTE | Start address of the Modbus output area. The data area is usually declared as a PLC array, and the address can be calculated with ADR (output variable). |
SizeOutputBytes | UINT | Size of the Modbus output array in bytes. The size can be calculated with SIZEOF (output variable). |
AdrMemory | BYTE | Start address of the Modbus memory area. The data area is usually declared as a PLC array, and the address can be calculated with ADR (memory variable). |
SizeMemoryBytes | UINT | Size of the Modbus memory array in bytes. The size can be calculated with SIZEOF (memory variable). |
Outputs
VAR_OUTPUT
ErrorId : MODBUS_ERRORS;
END_VAR
Name | Type | Description |
---|---|---|
ErrorId | MODBUS_ERRORS | Indicates an error number in the event of disturbed or faulty communication. |
Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT v3.1.0 | PC or CX (x86, x64, ARM) | Tc2_ModbusRTU |