How to do proper port settings/configuration of Rs 485 modbus?

Every RS 485 port on a device has a configuration associated with it and these configuration parameter must be set using the programming software for the particular device.

First thing to consider is device id.Device id can be set with programming software.

The main RS 485 configuration parameters are

1.Baud rate 2.Number of data bits 3.Number of stop bits. 4.Parity

Every single device on the same Rs485 network must all have the exact same settings for their port parameters.it is the only way that the RS 485 network will operate properly.

Baud rate - Stands for bit per second.Serial connection supports following baud rates.

1200bps 2400bps 4800bps 9600bps 19200bps

Baud rate is the rate at which the data is transferred on the RS 485 network.If the device on the same RS 485 network has different baud rate they cant communicate one another.

Number of data bits - Data sent in frames on modbus network. The setting for this is either 7 or 8.This indicates how many bits are present in a frame.

Number of Stop bits - Each RS 485 port when it receives data must know when the data is ended.When the frame is stopped. The setting for this is either 1 or 2.

Parity - Parity is for error checking. Following options are available. None,Even,Odd. Usually None is sufficient.No error checking because that would be used over RS 485 have its own error checking.

Regardless of the manufacture all these setting will be present in the modbus device.

3 Likes

Stop bits

the setting for this is either 1 or 2.

Not always. The Modbus specification declares that the selection of ‘no parity’ requires two stop bits. Whether a device can be configured for 1 or 2 stop bits is device-specific.

The problem is that a large number of serial implementations on devices can not handle two stop bits with 8 data bits (Modbus RTU is, by definition, an 8 bit data word)

The most common default implementation of serial communications seems to be 8-N-1: 8 data bits, no parity, 1 stop bit. Every device I have used can handle 8-N-1, but there are several devices that could not handle 8-N-2. One slave device had only 8-N-2 for the ‘no parity’ selection. The master could not do 8-N-2 and the only way to get it to work was even parity for both devices.

Parity

RS-485 has its own error checking

I think the statement means to state that the Modbus protocol uses error checking. Modbus RTU uses CRC error checking and Modbus ASCII uses LRC error checking. Either protocol can run on the RS-485 transport layer.

The EIA 485 spec covers stuff like a balanced interface, multidrop topology, bus voltage and common mode limits, unit loading, data rate at various distances.

Error checking at the transport layer level is a parity check . RS-485 is a transport layer, a carrier, a transmission mechanism. As such, it can use parity for error detection when implemented in the form of UART.

Configuration parameter Settings

The settings are made via various methods, depending on the device

  • multiposition rotary or DIP switches
  • jumper(s)
  • firmware/software selection
  • soldered links

The highest grade devices also offer selection of bias resistance and/or termination resistance, usually with hardware like a jumper or DIP switch.

It is not uncommon to find that the network changes are not recognized until power to the device is cycled (turned off, then back on).

2 Likes

Thanks for the information carl

The most important information when the communication doesn’t work, switch the wires, sometimes the polarity is not clear on the electrical drawing.

1 Like

Hello, I have one question related to this, how to set the unit_id in the modbus master

The master has no unit ID, only slaves have a node/unit/device ID; in fact the unit ID is frequently referred to as the Slave ID number.

The master’s command/query includes the slave node ID number which all devices on an RS-485 network ‘see’. Each interprets the message to determine whether the message is addressed to it. Only the slave to whom the message is addressed (determined by the slave/unit ID number) issues a reply and the reply includes the slave’s ID number as an identifier of who issued the reply.