Overview
The driver list has two entries: Modbus RTU (serial) and Modbus ASCII (serial). They are used for devices on a serial line, such as an energy analyzer, a temperature controller or a drive. The address of the connection is a serial port instead of an IP, for example COM3. A USB serial adapter also appears as a COM port.
The read planning, the address format, the data types and the 32-bit byte order are shared with the Modbus TCP driver. Only the frame and the transport change.
| Driver | Frame | Default serial settings |
|---|---|---|
| Modbus RTU | Binary frame with a CRC16 check. The line stays silent for at least 3.5 character times between frames. | 9600 baud, 8 data bits, even parity, 1 stop bit (8E1)
|
| Modbus ASCII | Hexadecimal text that starts with : and ends with CR LF, with an LRC check.
| 9600 baud, 7 data bits, even parity, 1 stop bit (7E1)
|
What to set up on the device and the line
-
Find the slave ID
Each device on the line must have a different Modbus address (slave ID) between 1 – 247. Two devices with the same address corrupt the responses.
-
Match the serial settings
Baud rate, parity, data bits and stop bits must match the settings of the device. All devices on the line must use the same settings too.
-
Find the COM number
In Windows, Device Manager › Ports (COM & LPT) shows the number of the port. A USB serial adapter can get a different number when it is plugged into another USB socket.
-
Free the port
A serial port can be open in only one program at a time. Close the configuration software of the device if it is open.
Setting up the connection in Studio
In the Connections section click Add and choose Modbus RTU (serial) or Modbus ASCII (serial) as the communication driver. Type the port in the Address cell: COM1 – COM256; com 3 is corrected to COM3. The Port column stays empty. The serial parameters are in the inspector.
| Field | Values |
|---|---|
| Device address (slave ID) | 1 – 247, default 1. |
| 32-bit byte order | ABCD (default), CDAB, BADC, DCBA. Same as Modbus TCP.
|
| Speed (baud) | 1200, 2400, 4800, 9600 (default), 19200, 38400, 57600, 115200. |
| Parity | None (N), Even (E, default), Odd (O). |
| Data bits | Must be 8 for RTU. 7 (default) or 8 for ASCII. |
| Stop bits | 1 (default) or 2. |
| Timeout (ms) | The time to wait for the response of the device. Increase it at low baud rates and for long reads. |
Several devices on one line
Open a separate connection for each device on the RS-485 line and give them all the same COM port. The connections share the port; the requests go on the line one after another. Each connection has its own slave ID, read cycle and connection status tag.
Connections on the same port must have the same Modbus type, baud rate, parity, data bits and stop bits. If they differ, Studio reports an error in the Problems list of Check project; Live does not open the second connection.
Analizor_1 COM3 ID 1 RTU 9600 8E1 // energy analyzer Analizor_2 COM3 ID 2 RTU 9600 8E1 // second analyzer, same settings Sicaklik_1 COM3 ID 5 RTU 9600 8E1 // temperature controller
Addresses and data types
00001 // Coil, Bool, writable 10001 // Discrete input, Bool, not writable 30001 // Input register, not writable 40001 // Holding register, writable 40001.5 // Bit of a register (0 – 15), Bool
- Bool
- Int
- UInt
- DInt
- UDInt
- Real
- LReal
- String
The Modicon notation, the 0-based / 1-based address difference and the number of registers each type occupies are explained on the Modbus TCP page. Structures (UDT) work here too for devices with the same layout.
Reading, writing and testing
- Nearby tags are read in one request, and a rejected block is read tag by tag. A written tag is read back. These rules are the same as for Modbus TCP.
- If the port cannot be opened or the cable is unplugged, the connection drops; the driver retries after 1 s, 2 s and 5 s, then every 10 s.
- Online › Test connections does not test serial connections over TCP; they are counted as skipped. The line and the device are tried in Live when a tag is read.
- In Live the Connections section of the system menu shows the last error message.
Limits
- There is no broadcast address (0), no custom function codes, no array tags and no 64-bit integer. There is no serial protocol other than Modbus.
- Modbus has no authentication or encryption.
- The drivers were tested in automated tests with a simulated serial line. Try them with your own port and devices before commissioning.
Common errors
| Message | Cause and fix |
|---|---|
| COM3 not found: this computer has no such serial port. | The port number is wrong or the USB serial adapter is not plugged in. Enter the number shown in Device Manager. |
| COM3 could not be opened: the port is open in another program or access was denied. | Close the other program that uses the port. |
| The device did not respond (timeout). | The slave ID, baud rate, parity or cabling is wrong. On RS-485 check that the A / B wires are not swapped; increase the Timeout at low baud rates. |
| Invalid Modbus response (CRC error). · (LRC error). | The serial settings do not match the device, or there is noise on the line. |
| Modbus RTU requires 8 data bits. | 7 data bits are used only with Modbus ASCII. |
| COM3 is used in another connection with different settings. | Make the serial settings of the connections on the same port identical. |
Frequently asked
How many devices can I read on one RS-485 line?
You open one connection per device; the slave ID is between 1 – 247. Because the requests go on the line one after another, the refresh interval of each device gets longer as devices and tags are added.
Can I use this driver instead of a Modbus TCP gateway?
Yes, if the Live computer has a serial port you can connect to the devices directly. Tag addresses are the same in both drivers, so moving from a gateway to the serial port only changes the connection.
Related pages
Modbus TCP
Reads and writes Modbus TCP devices by Modicon address, with unit ID and 32-bit byte order.
StudioConnections
The Connections table, driver selection, connection test, diagnostics, reconnection and password storage.
StudioHMI tags
External and internal tags, scaling, quality, structures (UDT) and bulk transfer with Excel.
ConnectivitySimulator
The built-in driver that generates signals for trials, demos and training without a PLC.