How to configure multiple RS-485 MODBUS RTU slave devices?

I have several MODBUS RTU RS-485 slave devices and I’m following this link: RUT955 Modbus - Teltonika Networks Wiki, but I have several doubts because I’m obtaining timeout errors.

Slave Device Configuration:
Number of timeouts → set to 0
Period: Interval at which requests are sent to the slave device. → set to 1
Timeout: Maximum response wait time. → set to 1

If I have 10 devices and I set period to 1 s, will these requests overlap? “Period: Interval at which requests are sent to the slave device”: 10 devices at the same time ?

What’s the timing if I configure different periods for each device and 2 requests per device?
What the best way to avoid problems if I have 10 devices and 2 requests per device?

Thanks in advance.

Hello,

Indeed, if you set period to 1 second, there will be too many Modbus requests on the serial link, especially when you have 10 slave devices.

First of all, try increasing the period to say, 30 seconds or above for testing purposes.

Secondly, configure only one instance and check if you are able to read Modbus data from the device. You may also increase timeout to 2-3 seconds for testing. If you can the Modbus data from a single slave, you can proceed adding more slave devices to configuration.

Thirdly, verify your Serial Device configurations and make sure that settings like baud rate, data bits, and so on, are consistent between both the RUT955 and the slave devices.

The following article here may also be helpful if you would like to do some testing.

Kind Regards,

This is my current setup:

Slave Device Configuration:
Number of timeouts → set to 0
Period: Interval at which requests are sent to the slave device. → set to 10
Timeout: Maximum response wait time. → set to 1

With 10 seconds as period, the system works Ok for about 5 devices, if I add more devices some timeouts appear.

Is there any rule to set the parameter “Period” properly or just trial and error ?

ModBus is a polling protocol, simplex. Thus, you should not start a new transmission from master (either poll or select), until response OR timeout. Be advised, that 1s timeout is far too long, unless your RS485 link is configured for 300bit/sec, or even slower. You should become familar with org ModBus protocol specs, from Modicon (now Schneider).
There are very detailed protocol specs regarding correct timing. I.e. timeout after poll (or select) is heavily dependent upon speed of link, of course. FYI, there is also a character timeout specified, speed dependent, of course. However, in software usually it is approximated by using a timeout for (expected) telegram length.

Thanks for your remarks.

I’m aware of that you wrote, in fact, I’m reading the same information from a PLC working as MODBUS master with no problem, I’m trying to replace the PLC with a RUT955.

The problem is that I can’t infere how the MODBUS driver works on a RUT955 according to the provided parameters.

I’d like to know how to adjust these parameters for 10 devices and 2 requests per device, a complete example. My network begins to fail when the number of slaves increases, even increasing timeout to 5 (insane) and period to 150 seconds, this doesn’t happen when I use a PLC as MODBUS master.

Thanks in advance.

Sorry, I do not really understand this. You want to use 10 slaves, OK, but what does … 2 requests per device … mean ?
I have a large fleet of RUT955 in the field, NOT running Teltonikas OS, but “official” openwrt. Thus, I programmed the ModBus stuff myself, using a very well established library called libmodbus. Org written in C, I am using its LUA bindings. I very strongly suspect, that Teltonika uses this library, too. There you can specify a ‘response-timeout’, and a ‘byte-timeout’. Running my RS485 with 115kbit/s, I am using a byte-tmo of 0, and a response tmo of 150,000 microsec, which is more or less according to ModBus specs. However, I only have one slave.
To read the slaves data, I programmed a standard polling cycle of 1/sec; however, after issuing a special write to the slave, starting some mechanical equipment via slave, I am using a shorter poll of 0.5 sec to catch the equipments feedback. This works perfectly.
So, I suggest you to search on github for ‘libmodbus’ , for further details.
Assuming, you can do C or LUA :slight_smile:

  • 10 identical devices
  • every device with 2 requests: one request for “power” and another one for “energy”
  • both requests are “Read input registers (4)”

Nothing more, this works using a PLC, I just want to get rid of the PLC and to use a RUT955.

RUT955’s OS is Linux, I also think the library has to be libmodbus.

Yes, I developed a MODBUS C library in the past, but I prefer to use a standard solution instead a custom one.

Hello,

It seems that the issue manifests when additional slave devices are added. Along with checking the timings, please make sure to use termination resistors. Note that the RUT955 does not come with a pre-soldered RS485 termination resistors. When you have many slave devices, it is strongly advised to use termination resistors on the RS485 serial link. For more information, including a diagram, please refer to the wiki page here.

Kind Regards,

This topic was automatically closed after 15 days. New replies are no longer allowed.