Modbus RTU error 12?

Topics about the Software of Revolution Pi
Post Reply
GardG
Posts: 7
Joined: 22 Apr 2022, 19:59

Modbus RTU error 12?

Post by GardG »

I'm trying to get a RevPi Connect to talk to a Modbus slave connected directly to the onboard RS485 port using a short twisted pair cable.
I have previously gotten the Modbus slave to work with Node-Red on the same RevPi by using a Modbus master node in Node-Red, so I know the hardware configuration and wiring is OK. That worked at first attempt and I could read meaningful data. However, getting the RevPi virtual master to work with this slave is proving more difficult.

I've added a virtual master in Pictory, set the correct baud rate etc, and added an "action" that reads holding register 1 at slave address 1. I have saved the configuration, reloaded the driver and restarted Modbus ($ sudo systemctl restart pimodbus-master.service). When I do $ piTest -r Modbus_Action_Status_1 I get error code 12:

Code: Select all

1 Byte-Value of Modbus_Action_Status_1: 12 dez (=0c hex)
The "device value" for this action is Input_Word_1, which comes up emtpy (0000). I have no idea what status 12 is and I haven't been able to figure it out. If I change the Modbus address to something else (which doesn't exist, there is only one slave connected) I get a time-out (110) instead, which makes sense. I have also tried using 2 stop bits instead of 1 just in case, but that also results in time-outs.

Here's the Modbus log:

Code: Select all

$ journalctl -u pimodbus-master.service  | tail -n 50
Apr 29 15:50:19 RevPi52559 piModbusMaster[3461]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:19 RevPi52559 piModbusMaster[3461]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:19 RevPi52559 piModbusMaster[3461]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:20 RevPi52559 piModbusMaster[3461]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:20 RevPi52559 piModbusMaster[3461]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:20 RevPi52559 systemd[1]: Stopping Revolution Pi Modbus master...
Apr 29 15:50:20 RevPi52559 systemd[1]: pimodbus-master.service: Main process exited, code=killed, status=15/TERM
Apr 29 15:50:20 RevPi52559 systemd[1]: pimodbus-master.service: Succeeded.
Apr 29 15:50:20 RevPi52559 systemd[1]: Stopped Revolution Pi Modbus master.
Apr 29 15:50:20 RevPi52559 systemd[1]: Started Revolution Pi Modbus master.
Apr 29 15:50:20 RevPi52559 piModbusMaster[3816]: piModbusMaster started
Apr 29 15:50:20 RevPi52559 piModbusMaster[3816]: modbus rtu action timeout: 0 s 100000 us
Apr 29 15:50:20 RevPi52559 piModbusMaster[3816]: modbus rtu minimal time between telegrams: 0 s 50000 us
Apr 29 15:50:21 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:21 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:22 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:22 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:22 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:22 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:22 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:23 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:23 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:23 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:23 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:23 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:24 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:24 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:24 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:24 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:24 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:25 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:25 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:25 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:25 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:26 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/110/-112345568
Apr 29 15:50:26 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:26 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:26 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:26 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:26 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:27 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:27 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:27 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:27 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:27 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:28 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:28 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:28 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/110/-112345568
Apr 29 15:50:28 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
Apr 29 15:50:28 RevPi52559 piModbusMaster[3816]: modbus rtu action device: /dev/ttyRS485, slave address: 1 function: 0x03, address: 1 failed -1/112345690/12
If it matters, the slave I'm dealing with is a Laumas TLB.

Any clues? What is status 12?
User avatar
nicolaiB
KUNBUS
Posts: 912
Joined: 21 Jun 2018, 10:33
Location: Berlin
Contact:

Re: Modbus RTU error 12?

Post by nicolaiB »

Hi Gard,

you can find the action status error codes in our modbus rtu tutorial: https://revolutionpi.com/tutorials/modb ... rect=en_US (scroll to table at the bottom). The error code 12 in you case means INVALID_CRC: A faulty packet was received from the slave. This can occur after the connection has been interrupted, for example. Check your wiring.

Nicolai
GardG
Posts: 7
Joined: 22 Apr 2022, 19:59

Re: Modbus RTU error 12?

Post by GardG »

Got it! I think there were a few different issues at play. Some of the fields in the "extended data" had been emptied (as described in a different thread in the forum), and in an attempt to fix that I re-added the virtual master and apparently forgot to set the correct parity. And to top it off, the /dev/RS485 symlink had disappeared again. But now it works!
mitchellday06
Posts: 21
Joined: 29 Nov 2022, 00:08

Re: Modbus RTU error 12?

Post by mitchellday06 »

With the node-red modbus. Did you need to have the virtual modbus in pictory? Or was that purely for pictory testing?
Also was the default etc/ttyRS485 address used in nodered to access the modbus rtu units?
Post Reply