Jump to content

Modbus RTU problems


DaveB

Recommended Posts

Dear colleagues.

I hope you are doing fine.

I have 5 power meters in a RS485 bus communicating through Modbus RTU with one Unistream which is acting as master.

3 of them are from the same brand and model. They are all ok, connecting and communicating. The registers are 32 bit length (treated as INT32 in the Unilogic). So far everything is good.

For the other 2, from different manufacturer, It seems I am receiving the data in a strange way because the data is not coherent. It seems I am receiving the words or bytes inverted. if I use a external Modbus client in my laptot, I can see the value correctly displayed as a FLOAT32 ABCD and it matches with the actual value (12.3, 24.1, 48.3 volts... etc). In contrast, with the PLC I see gigantic values.

I tried to use the swap byte funcions but couldn't get it. I don't know whether there is a way to compose a REAL from two INT...

Does anybody ever had similar problems/solutions? I am kind of desperate.

Thank you and best regards.

Link to comment
Share on other sites

Hi Alex,

Thanks a lot. It worked!!

I've noticed that the performance of the RS485 network is very slow. I takes around 3 seconds to read all the slaves (5 in total) with 5 Aperiodic Indirect Group Trigger functions. I don't have dropped packets but it is slow no matter the speed of the requests (I made a loop from 1 to 5 and i ask each slave in each step of the loop). I tried it also using periodic function but I had lots of problems with dropped packets. The network becomes saturated.

Do you have any sugestion? I have to read 10 holding registers from 3 devices and 1 holding register from the other 2. Is there any way, maybe to request multiple holding register when they are consecutives? Maybe that will increase speed. I also configured the network to 115 kbps. Or maybe using other function as Modbus Aperiodic Direct?

Thank you for your help and best regards.

Link to comment
Share on other sites

  • MVP 2023
13 hours ago, DaveB said:

I've noticed that the performance of the RS485 network is very slow.

Modbus on 485 is inherently not a quick method of comms.  On many modbus items from various suppliers a max baud rate of 9600 is the norm, so you can easily understand how that can slow things down as everything proceeds at that rate.  You need to play with your settings and number of retries etc to find your optimum speeds that work for the entire network.

cheers, Aus

  • Upvote 1
Link to comment
Share on other sites

  • MVP 2023
13 hours ago, DaveB said:

I've noticed that the performance of the RS485 network is very slow. I takes around 3 seconds to read all the slaves (5 in total)

I'm not sure how old you are, but back in the day less than one second per device on a serial network was considered fast.  Each device must have it's own packet set generated and listen for a response, which in serial land can take a while.  Modbus RTU is a handshaking protocol, not a broadcasting protocol.

If speed is an issue you need to switch to Modbus TCP.

 

Joe T.

  • Upvote 1
Link to comment
Share on other sites

20 hours ago, DaveB said:

Is there any way, maybe to request multiple holding register when they are consecutives?

I think if you make an array out of a tag you write into, it will read consecutive registers to fill the length of an array.

I also had to look up the topic Alex linked this morning because I got stuck on the same problem as you did. In VisiLogic you didn't have to swap bytes, just combine two MIs into an MF with Struct.

Link to comment
Share on other sites

Thank you guys. I thought this was slow even for serial comms. It would not be a problem if the read data would be just to display the values in the HMI, but I need them as Process Value for PIDs, so the tunning is becoming very hard.

Thank and have a nice day

DaveB

Link to comment
Share on other sites

  • MVP 2023
5 hours ago, Isakovic said:

it will read consecutive registers to fill the length of an array.

Isak has touched on a potential help, but my experiences are perhaps relevant.  A lot of the modbus things I work with often have +600 registers full of useless info for the end user.  Sometimes I can read a whole series of registers into a vector and then pick and choose relevant items, but often the slave gets upset trying to do this if it does not use one of the registers in the range, and the entire thing falls over.  I always have to trial reads initially using the PC to achieve the best compromise of lots of vector length and time needed to do this vs picking individual registers vs how many consecutive registers will it let me read in one hit variances for the slave in question. 

cheers, Aus

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...