Modbus Error Variable

Topics about the Software of Revolution Pi
Post Reply
plima
Posts: 7
Joined: 04 Jun 2020, 17:20
Answers: 0

Modbus Error Variable

Post by plima »

I am trying to detect a communication failure in a Modbus TCP Master and I am having some issues.

When I reset the driver with the Modbus Slave disconnected, the Modbus_Master_Status has a '255' value, after I start the slave it changes to '0', this is ok but if I disconnect the slave again, the value never changes, it is always '0'.

Is this a bug or should I do something to make this working?
Amar
KUNBUS
Posts: 157
Joined: 15 Jul 2019, 12:58
Answers: 4

Re: Modbus Error Variable

Post by Amar »

Modbus_Master_Status does not provide slave communication status.Communication failure in a Modbus TCP Master with corresponding Slaves can be checked with corresponding Modbus_Action_Status_[1… 32] registers.The error codes correspond to the Modbus exception codes as specified in the Modbus specification.The Modbus master can handle up to 32 tasks. For each task there is a register for status and status reset. If an error occurs in a task, the error code is written to the Modbus register “Modbus_Action_Status_[1… 32]”.The error stays in this register until the value “1” is written manually into the Modbus register “Action_Status_Reset_[1… 32]”.
KUNBUS
plima
Posts: 7
Joined: 04 Jun 2020, 17:20
Answers: 0

Re: Modbus Error Variable

Post by plima »

According to Modbus master documentation the "Modbus_Master_Status" should provide the communication status.

quote:
"If a communication error occurs, the error code is written to the Modbus register "Modbus_Master_Status"."

However, even using the "Modbus_Action_Status" I have some problems, after I reset the status, how can I know that the connection is re-established?

I need to know, if the values that I am trying to collect are valid at all times, when the connection is lost I need to set an invalid status and reset it when the connection is established, how can I do this?
Amar
KUNBUS
Posts: 157
Joined: 15 Jul 2019, 12:58
Answers: 4

Re: Modbus Error Variable

Post by Amar »

Thank you for the Quote.There is some unclarity in documentation for Modbus_Master_Status which is related to internal errors associated with master.

After you reset with Action_Status_Reset you monitor Modbus_Action_Status again.Modbus error codes (eg 110 CONNECTION TIMED OUT ) are written in this register.Modbus_Action_Status with value 0 also means that communication is established and received data is error free.

More detailed Modbus application logs can be found in system log:
tail -f /var/log/daemon.log
KUNBUS
plima
Posts: 7
Joined: 04 Jun 2020, 17:20
Answers: 0

Re: Modbus Error Variable

Post by plima »

Thank you Amar, I think that's ok, it works for what I want.

Just a little problem, the failure detection is too slow, I have an Action Interval of 1000ms and the failure is only detected after 2 minutes.
Is there a configuration to increase the speed of the failure detection?
Amar
KUNBUS
Posts: 157
Joined: 15 Jul 2019, 12:58
Answers: 4

Re: Modbus Error Variable

Post by Amar »

Hi Plima,
The issue occurs for Modbus error CONNECTION RESET BY PEER (Error Code: 104) when the slave connection is abruptly closed.

You will have to try out with our latest Stretch 06/2020 Image.It uses libmodbus 3.1.6 (instead of 3.0.6) .

Download link for Image:
https://revolution.kunbus.de/shop/en/stretch

The issue does not occur in this image which uses newer piModbusMaster (with libmodbus 3.1.6 ).
The error entry will be quickly noticed in system log too.

tail -f /var/log/daemon.log
piModbusMaster[1800]: Modbus TCP action IP: 192.168.168.89, Port: 502 function: 0x06, address: 1 failed -1/104

Also note, if 'n' modbus actions are used i.e Modbus_Action_Status_1 to Modbus_Action_Status_n then
one of them will be set to MODBUS error code: 104 (CONNECTION RESET BY PEER) .This is the precisely the action where the error appeared.So basically you will have to monitor all those 'n' Modbus action status register's inorder to catch this error.

Regards,
Amar
KUNBUS
Post Reply