Page 2 of 3

Re: Modbus change variable between virtual devices

Posted: 19 Jul 2021, 17:17
by a.alvsantos
Hi Dirk,

Thank you for investigating into this error and having reported to us the outcome.
As well pointed by @KTB-Vo2345 and @saardrimer we have also relied on RevPi to handle the Modbus functionallity and I find it rather peculiar and non-reasonable that you recommend us to work with libmodbus instead. We are using RevPi in a industrial equipment and that is going to a client facility and such behaviour cannot occur.
Please share with us what's your plan for a fix/workaround including an estimated timeframe (days, weeks) to fix the issue

Thank you,
Best regards,

Re: Modbus change variable between virtual devices

Posted: 01 Aug 2021, 19:47
by bmoeller
I would like to echo above. I seem to have a similar problem. We bought two RevPi Connect to use them in a project where we have to control two external cooling units. Reading register 202, which is a temperature reading we get a value that is completely of the actual value and despite the actual value being constant the the value read by the RevPi Connect varies all the time. We made a number of different checks in order to check connectivity and offset, but all seem to be correct. Only the reading is unreliable.

Re: Modbus change variable between virtual devices

Posted: 02 Aug 2021, 10:22
by bmoeller
I have to correct myself. I thought I had a similar problem and the data I read via the RevPi connect (Modbus RTU) were not correct. Turns out that the problem was in the convertion from the 2 byte hex to integer decimal. The low and high byte was swapped around. at the same time the register address offset was wrong (o instead of 1). After getting these two points correct we got the correct ready from the controller. The analog signal does vary slightly but nothing that is visible on the rounded number.

We have normally read the registers directly using the Modbus Contrib nodes in node red. Using pictory the only way we have found is to get the values piTest -1 -r 11,2,h and then slice the output to two string with now spaces, and build a new string with 4 characters (0x two bytes) having the correct order of the high / Low byte. The convert this string a integer decimal.

Is there not an easier way to get this decimal value (piTest -1 -r 11,2,d is not producing the right value, it just generates two decimal numbers)?

It is an advantage to use the Pictory and use this as a kind of a poll server. Thus, being able to read the same variables from more devices without overloading the ModBus.

Re: Modbus change variable between virtual devices

Posted: 03 Aug 2021, 10:30
by Amar
Hello everyone,
Please update the RevPi device to latest Buster Image and test the attached piModbusMaster binary to verify if the issue is resolved.
piModbusMaster uses the libModbus API in which Modbus TCP/RTU context is not thread safe.Multi instance Modbus TCP/RTU
devices running on seperate threads now use mutex to access libmodbus API in this fix.

1)Stop piModbusMaster service .
sudo systemctl stop pimodbus-master.service

2)Copy(overwrite the original binary) the provided piModbusMaster binary to path /usr/sbin.

3)Restart piModbusMaster service
sudo systemctl resart pimodbus-master.service

Attachment:
piModbusMaster.zip
(49.13 KiB) Downloaded 342 times
Regards,
Amar

Re: Modbus change variable between virtual devices

Posted: 15 Aug 2021, 14:32
by VdH
Multiple Modbus virtual devices is a central feature. Not implementing this patch for Stretch would be a sad trade-off. The bug has been reported in February by RevPiModIO and me and never has been fixed since then. There is also a second issue we reported which has nothing to do with the first one. I asked for contacting me to discuss the issue (as I'm deep in the implementation of Modbus in RevPi). The developer in charge has never contacted me although my office is around the corner of KUNBUS. That is a shame and I'm really disappointed!!!

Re: Modbus change variable between virtual devices

Posted: 31 Aug 2021, 13:40
by Simvei001
We're looking forward to testing the new version of the pi-modbus master in the next month.

But for the last months and the following weeks we had to adapt our software to an older approach using another modbus libraryto fix the software for our release.
Before we can test the new variant we need to adapt the complete setup to the newer buster image, including a complete rebuilt of our own development pipeline based on an buster image.
These aren't very complicated steps, but for now our hardware is occupied by the release tests.

We definitly want to test the new variant, but this will take some more time on our side.
A version for the stretch image could be tested within the next couple of weeks, if it would be available.

Kind regards,
Simon

Re: Modbus change variable between virtual devices

Posted: 22 Sep 2021, 11:11
by dirk
Hello everyone, thank you for your patience. I am happy to inform you that the problems have now been fixed due to an in-depth analysis.
You can update your systems as follows:

Code: Select all

sudo apt update
sudo apt install pimodbus-master pimodbus-slave
Please remember to backup your system and close running applications before updating. To do this, you can set the following in WebStatus:
iNXrygbnq0.png
iNXrygbnq0.png (294.82 KiB) Viewed 5855 times
The update should then proceed like this:

Code: Select all

pi@RevPi33114:~ $ sudo apt install pimodbus-master pimodbus-slave
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages will be upgraded:
  pimodbus-master pimodbus-slave
2 upgraded, 0 newly installed, 0 to remove and 20 not upgraded.
Need to get 28.4 kB of archives.
After this operation, 16.4 kB of additional disk space will be used.
Get:1 http://packages.revolutionpi.de stretch/main armhf pimodbus-master armhf 1                                                                                       .0.9-1~revpi9+1 [15.8 kB]
Get:2 http://packages.revolutionpi.de stretch/main armhf pimodbus-slave armhf 1.                                                                                       0.9-1~revpi9+1 [12.5 kB]
Fetched 28.4 kB in 0s (93.4 kB/s)
(Reading database ... 91595 files and directories currently installed.)
Preparing to unpack .../pimodbus-master_1.0.9-1~revpi9+1_armhf.deb ...
Unpacking pimodbus-master (1.0.9-1~revpi9+1) over (1.0.7-1stretch) ...
Preparing to unpack .../pimodbus-slave_1.0.9-1~revpi9+1_armhf.deb ...
Unpacking pimodbus-slave (1.0.9-1~revpi9+1) over (1.0.4-1stretch) ...
Setting up pimodbus-master (1.0.9-1~revpi9+1) ...
pimodbus-master.service is a disabled or a static unit, not starting it.
Setting up pimodbus-slave (1.0.9-1~revpi9+1) ...
pimodbus-slave.service is a disabled or a static unit, not starting it.
pi@RevPi33114:~ $

Re: Modbus change variable between virtual devices

Posted: 04 Oct 2021, 18:54
by RR4711
Can you give some explanation on what was the problem and how it was solved?

Re: Modbus change variable between virtual devices

Posted: 17 Nov 2021, 14:46
by dirk
Hello piModbusMaster uses the libModbus API in which Modbus TCP/RTU context is not thread safe.Multi instance Modbus TCP/RTU
devices running on seperate threads now use mutex to access libmodbus API in this fix.

Re: Modbus change variable between virtual devices

Posted: 17 Nov 2021, 15:01
by RR4711
Thanks. We will deploy a Connect+ 32GB in the Amazonian Rainforest next week using 3 MODBUS Mass Flow Controllers. We will see in the long term data if the issue is finally fixed :-)

Markus