Jump to content

Modbus struct


Vidmas30

Recommended Posts

Good evening, all,

 I have a project where UniStream US5 controller with RS485 port is used to read data from 8 electricity meters. These are exactly the same model and parameters quantity and type also the same. I thought about making a struct for one meter with all variables needed and then copy and change struct name so I don't have to enter each of these variables for each meter. But there's no way to copy struct in UniLogic. Maybe someone of you has done something like this and can share some advice? 

 One more thing: since no special logic needed, I'm planning to use PLC Communication Modbus Master's dialog to add slaves, enter all required data variable (about 50 each meter) and use toggle bit for each of the meter. I wonder if it's the best way to do this, because I need to read about 50 variables from each of slaves. Your thoughts about this would be highly appreciated. Thank you in advance.

Link to comment
Share on other sites

Hi, all,

 Some update: after some experimenting and reading, I found that tried to use not right approach - I tried to do separate struct for each of slaves with all the variables I need to read. So there were 37 operations with every slave. Then I used an arrays  of INT32 (electricity metter gives information that way). Since in one operation metters can give 50 words (and I need 50 INT32's pf which 47 are consecutive), I ended up with 3 operations - 1st for 25 INT32, 2nd for 22 INT32 and 3rd for last 3 INT32. With periodic, when there are 2 operations it works flawless, but when there are 3 operations and set for every period 1000ms, there are problems (dropped increments). Then I set different times in every period and it helped.

 Could someone give more detailed explanation what this time setting in "every period" means? And how exactly PLC does read/write of the slaves according these settings? Because when looking to sessions counter, it looks like it goes simultaneously.

 With 2 slaves (I have on my desktop) it works just fine, hope everything will be ok with all 8.

Link to comment
Share on other sites

  • MVP 2023

A serial Modbus transaction can take up some time.  The program builds the frame, sends it to the slave, and waits for the request.  You demonstrated this to yourself when 3 operations started erroring out a 1000 ms.  

The "every period" is how often the PLC will trigger a transaction.  If you have several slaves it will indeed send them out simultaneously.  Which means it's not going to work very well in a serial configuration, as the responses from the slaves will crash into each other on the COM port.

Maybe one of the Creators can chime in here and tell us if the PLC stages the requests under the hood.  Otherwise I'd manage the calls to each meter by shifting the "Active" bit for each Modbus operation.

Joe T.

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...