MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Topics about the Software of Revolution Pi
LEOMENA
Posts: 44
Joined: 02 Aug 2021, 21:57
Answers: 0

MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by LEOMENA »

My Project involves slaving a Connect via a Connect+ master over Modbus RTU over the RS485 link on both. I have not been able to establish successful communications between the two Revpi's.


I have a few questions that I think you can answer for me to make sure I am have followed the right steps:

1.- Is it at all possible that a Revpi Connect+ slaves a Revpi Connect using the RS485 ports on both?
2.- I am using the Connect+ as a Master and the Connect as a slave.
3.- My cable is two-wire like the following (+) -> (+) and (-) -> (-):
See image
image (3).png
image (3).png (8.61 KiB) Viewed 3769 times

4.- My configuration on the slave: I had to change the device path from /dev/ttyUSB0 to /dev/ttyRS485 but also noticed that the file named as ttyRS485 is a link with target ttyUSB0, which doesn't make sense to me. Of course I activated the RTU Slave service on the slave and the Master Service on the Master. I have tried 1 and 2 for the slave addresses without luck.
image (4).png
image (4).png (411.44 KiB) Viewed 3769 times
image (5).png
image (5).png (981.89 KiB) Viewed 3769 times


5.- On my master and extended data I have tried several combinations of addresses and Modbus function codes (Read and Write) but never succeeded to get any readings.

(Here I was supposed to paste two more images but the system would not let me. I will try to add them on a reply or edition of this issue. These images show my enabling of the Modbus Master service on my master Revpi Connect+ and the extended data of my ModbusRTU Master device alongside of my Revpi connect+ )




6.- To force my cyclic readings I am using a python code of yours, modified to fit the case as follows:

Code: Select all

import revpimodio2
def eventfunction(ioname, iovalue):
    """Event function, which is executed when the value changes."""
    print("Input {} has value {}".format(ioname, iovalue))
# Instantiate RevPiModIO
rpi = revpimodio2.RevPiModIO(autorefresh=True)
# Catch Ctrl+C signal and exit program clean
rpi.handlesignalend()
# Register input events
rpi.io.Input_Word_1.reg_event(eventfunction)
rpi.io.Input_Word_2.reg_event(eventfunction)
rpi.io.Output_Word_1.reg_event(eventfunction)
rpi.io.Output_Word_2.reg_event(eventfunction)
#rpi.io.Core_Temperature.reg_event(eventfunction)


# Start event processing (program will block here)
print("start mainloop")
rpi.mainloop()

7.- To force value changes I use piTest on both ends.
For example: Suppose I write a value to Output_Word_1 on the master and should be able to read the same change in Input_1 on the slave side.
But nothing's working.

8.- I would like help on how to install a Modbus Master simulator on the Revpi, but I thought It should work the way I got it set up.


9.- Can you help pointing out what's wrong?

Thanks!!!!
image (3).png
image (3).png (8.61 KiB) Viewed 3769 times
LEOMENA
Posts: 44
Joined: 02 Aug 2021, 21:57
Answers: 0

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by LEOMENA »

This is not a reply, but an addition to my problem.. I mean to upload the following two images to my original post:
image (7).png
image (7).png (372.33 KiB) Viewed 3768 times
image (6).png
image (6).png (968.6 KiB) Viewed 3768 times
User avatar
nicolaiB
KUNBUS
Posts: 878
Joined: 21 Jun 2018, 10:33
Answers: 8
Location: Berlin
Contact:

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by nicolaiB »

Hi LEOMENA,

first of all thanks for the detailed description of what you have done so far in order to establish your project.

At first glance, I can't spot anything suspicious, so I need to start with some questions:

  • Did you reset the piControl driver (via pictory or piTest -x) on both devices?
  • What are the values of the following registers on the master: Modbus_Master_Status, Modbus_Action_Status1-4?
  • Please share the log files of master and slave. You can export the logs into a file with the following command: journalctl -u pimodbus-master.service > modbus-master.log (for slave change master to slave and run on slave)

Nicolai
LEOMENA
Posts: 44
Joined: 02 Aug 2021, 21:57
Answers: 0

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by LEOMENA »

Hi Nicolai,
thanks for your reply.
My answers to your questions follow:
Did you reset the piControl driver (via pictory or piTest -x) on both devices? YES I DID.
What are the values of the following registers on the master: Modbus_Master_Status, Modbus_Action_Status1-4?
Modbus_Master_Status: 255
Modbus_Action_Status1-4: ---> All show: 255

Please share the log files of master and slave. You can export the logs into a file with the following command: journalctl -u pimodbus-master.service > modbus-master.log (for slave change master to slave and run on slave)
--->Attached as a zip file as the system did not allow me to attach them "as are".

Nicolai

I have been using a Master simulator named Modpoll, do you have another one, if so, please send links and install instructions.

BTW, I can confirm that I have communications between the two Connects (that's something)... For that I used a modbus master (named Modpoll)  and I could confirm that the computers are communicating. 
However, what I don't have now is the master's image updated at all (it should update every second).
Again, I am expecting the Registers in the Modbus Master's list (Input_Word_1, Input_Word_2, ... etc) to be updated automatically (every 1000 milisec) and by itself whenever a change is made on the slave's registers Output_1, Output_2, etc...  But that is not happening...
I am forcing the changes on the slave's side by issuing piTets writes to those registers ( Output_*) , which do take effect and I can read them using Modpoll, but  they don't update in the master's image registers (Input_Word_*). Of course the writing is not working either.
I have used all combinations possible on the Extended Data section of the Master's config; namely: READ_INPUT_REGISTER, READ_HOLDING_REGISTER, WRITE SINGLE REGISTER, WRITE_MULTIPLE_REGISTER, etc...
Please help me understand what I am doing wrong.
Attachments
modbus-master-slave log files.zip
(896 Bytes) Downloaded 163 times
LEOMENA
Posts: 44
Joined: 02 Aug 2021, 21:57
Answers: 0

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by LEOMENA »

Nicolai,

Additional information became available:

It turns that my piTest tries are working now, after the same restart that I made (for my topic regarding Analog Outputs unresponsive). So The same reason that caused the AO's unresponsive caused my Modbus tests not work either. That concerns me..

So, I do have some writes that I can do and make sense to me, but some reads are not right. My guess is that I am using the wrong register address, can you please check???
As you know I am using the following Extended Data configuration:
2021-10-14 (5).png
2021-10-14 (5).png (299.95 KiB) Viewed 3644 times
But my plan is that I write a value to OutWord1_TempStPt (on my Master side) and it should go to Input_1 (on my Slave side). (This is ACTION ID 2 of my Extended Data table). This is working fine.
Also, I want to read whatever is in Output_1 (of my Slave side) into InWord1_SoloTemp (on my Master side). (This is ACTION ID 1 of my Extended Data Table). But this is only giving me whatever I have written with Action ID 2 (Input_1).
Which, I think means that I am addressing the same register (address 1).
I want to read Output_1, but I am reading Input_1 of the Slave.
I guess what I need to know is the full address map for the slave or what register address Output_1, 2, 3, 4, etc. correspond to..

Remember, for reading I am using Read_Holding_Registers Modbus function. I am going to try READ_INPUT_REGISTER to see if I get some progress, but then again I think the problem is on the register address, rather than the function code.
Can you please help..?
Thanks again.
LEOMENA
Posts: 44
Joined: 02 Aug 2021, 21:57
Answers: 0

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by LEOMENA »

After a short while of tries, the Modbus communication, became unresponsive again, tried the restart, shutdown but now nothing is working.
:(
User avatar
nicolaiB
KUNBUS
Posts: 878
Joined: 21 Jun 2018, 10:33
Answers: 8
Location: Berlin
Contact:

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by nicolaiB »

Hi LEOMENA,

can you please share the log files after the communication crashed?

There were also some improvements regarding the virtual modbus modules in our latest buster release. If possible I would advise to update the Connect with the stretch image (with the red pictory) to the latest buster image. More information can be found in our tutorial: https://revolutionpi.com/tutorials/imag ... ll-jessie/

Please also make sure that both systems run the latest versions of our software, which is described in another tutorial: https://revolutionpi.com/tutorials/over ... -software/

Nicolai
LEOMENA
Posts: 44
Joined: 02 Aug 2021, 21:57
Answers: 0

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by LEOMENA »

Nicolai,
thanks for your reply..

I have been working on different tests during several days since I had not received a reply here.
It turns out that with consistency I can say that it must be related to the image or the Kunbus software. In my many tests I managed to consistently get good behavior from the communications every time I would shutdown and restart the Revpi.. After a while, and for no apparent reason, it starts acting strange and gets unresponsive again.. This not only happens to the communications channel but also the Analog & Digital Ins & Outs (less frequently though).

So if the issue is that I have some outdated software or different versions in either of my Revpi's may I strongly suggest that you include a MUST DO procedure whenever a customer purchases a unit to make sure all the software is correct, and also place it in a very intuitive and easy to find place on the support page, etc... The user is normally expecting that all these things are taken care of right out of the box.

That said, I am not sure if this is what happens, but it sure looks like it. I will try your updates etc.. But can I ask you a favor and prepare a step-by-step procedure to make sure I can get it right at once and not miss anything??
Thanks Nicolai.
User avatar
nicolaiB
KUNBUS
Posts: 878
Joined: 21 Jun 2018, 10:33
Answers: 8
Location: Berlin
Contact:

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by nicolaiB »

Hi LEOMENA,

I'm sorry to hear that the problem still exists and would like to help you to solve this.

In order to find the cause of your problem I need more information like the log file before and after the crash. Please make also sure that there aren't any other services try to access the process image (like revpyload or nodered revpi server). A list of all running processes can be helpfull too. You can gather all necessary informations with our revpi-sos tool. Fore more details please have a look at the article in our support knowledge base:
https://kunbus-gmbh.atlassian.net/servi ... 2036400208

A step-by-step intruction on howto backup your current image and flash a new one is stated in the tutorial I mentioned in my last answer (https://revolutionpi.com/tutorials/imag ... ll-jessie/). The latest image is Buster 7/21 and can be downloaded here: https://revolutionpi.com/tutorials/down ... evpiimages. Please make sure to backup customizations like your application before flashing a new image.

Nicolai
LEOMENA
Posts: 44
Joined: 02 Aug 2021, 21:57
Answers: 0

Re: MODBUS RTU over RS485 FUNCTIONALITY with TWO CONNECTS

Post by LEOMENA »

Nicolai,
Thanks again for your reply, I have been out in the field with the testing of our system. I still have the issue (and I am testing with what I got now) but I need some time off to gather all the information. Please give me a few days to do it and I will get back with you on that.

Thanks
Post Reply