Modbus timing and timeouts

Topics about the Software of Revolution Pi
Post Reply
alf@emcom.no
Posts: 20
Joined: 25 Sep 2018, 10:17

Modbus timing and timeouts

Post by alf@emcom.no »

In my endeavour to make a simple Modbus-logger I am having problems reading modbus from the sensor.
I looks like it is a problem on layer 1 or 2 when connecting RS485 sensor to the physical RS485-port on the RevPi Connect.
This is the sensor: https://micronicsflowmeters.com/product ... low-meter/

It is a simple 1-1 sensor-to-Pi connection of 2m.
If I do not connect cables - or ; if I insert a 120Ohm resistor between + and - -> i Get this in the daemon-log :
Oct 10 10:38:13 RevPi9693 piModbusMaster[1390]: modbus rtu action device: /dev/ttyUSB0, slave address: 24 function: 0x03, address: 1 failed -1/110/-112345568

If I have the cables connected correctly but no resistors or anything :
Oct 10 10:38:02 RevPi9693 piModbusMaster[1390]: modbus rtu action device: /dev/ttyUSB0, slave address: 26 function: 0x03, address: 1 failed -1/112345690/12

Two questions concerning this :
1) Can you help me decipher the logmessages above ?
2) The manufacturer of the sensor says I should try and set the timout for the poll to 5 seconds - where can I do that ?

Thanks in advance
Alf M
User avatar
Mathias
Posts: 130
Joined: 29 Nov 2016, 10:46

Re: Modbus timing and timeouts

Post by Mathias »

Hi Alf,

in the error messages in daemon.log the smaller number at the end of the line is the interesting one:
110 means Timeout: the response from the slave was not received fast enough.
12 means CRC-Error: The CRC of the response was not correct. If you have no termination resistor that is reasonable error.

The modbus master uses two timeout values. They are determined by a heuristic at the moment.
  • action timeout
This is the time the master is waiting for a response from the slave. The half of the smallest action interval is used.
If you have an action withan action interval of 1000ms and one with 2000ms, the timeout will be 500ms.
  • time between telegrams
This is the length of the pause after receiving a response before the next telegram is sent to a slave. It is the smallest cycle divided by number of actions and by 4.
If you have the 2 actions from above, the smallest interval is 1000ms. This is divided by 2 and by 4. The result is 125ms.

When the piControl driver is reset, the modbus master is also reset. It make a new calculation an prints the 2 values as below:

Feb 20 06:25:11 RevPi1321 piModbusMaster[539]: modbus rtu action timeout: 0 s 500000 us
Feb 20 06:25:11 RevPi1321 piModbusMaster[539]: modbus rtu minimal time between telegrams: 0 s 15625 us

If you need long timeouts, you have to configure really large action intervals.
We had a modbus slave that needs 1 second pause. Otherwise it will not respond to requests. We also had to increase the action intervals.

Mathias
Post Reply