Overview

The Modbus RTU TwinCAT PLC library offers function blocks for serial communication with Modbus end devices.

Typical end devices are operating terminals with a Modbus driver that are connected to a TwinCAT controller via a serial RS-232, RS-422 or RS-485 interface. In this case, the TwinCAT PLC is a Modbus slave and the operating terminal is a Modbus master. In this configuration, the programming effort on the PLC side is very low.

Alternatively, Modbus master functions are available in the library, through which the PLC can address one or several Modbus slaves. This configuration is less common and also not really recommended, since the programming effort is higher.

Supported TwinCAT controllers

Supported interfaces

Boundary conditions

The Modbus protocol defines accurate timing to ensure, for example, the complete transfer of all characters of a telegram. Since the communication Modbus RTU is realized on a PLC controller, accurate timing cannot be guaranteed due to the cyclic execution of the PLC program. Most end devices are very tolerant and function without problems in the event of short time gaps between characters. In individual cases, the behavior of the end device should be checked.

The second channel of an EL60x2 is not suitable for Modbus RTU communication, because it is processed with low priority, which means the frames are sent with gaps, which in turn could be detected by the remote terminal as frame errors.

Overview 1:

With some serial interface terminals an internal buffer can be filled before sending (option continuous sending). The ModbusRTU library can use this feature if it is set in the corresponding serial terminal. For example, on the KL6031 continuous mode can be activated with the KL6configuration configuration function block (register 34 bit 6). Up to 128 bytes are then placed in the internal buffer of the Bus Terminal and transmitted continuously.

Further documentation

www.modbus.org