Jump to content

Modbus call sequencing


Recommended Posts

  • MVP 2023

HI all,

If possible, I would like to know the different approaches people do on reading/writing to modbus devices.  I have always run seqencing as a count based routine, with a maximum of 20 slaves being polled, each call being 2 seconds apart for simplicity and a slower network running at 9600.  Most of the time, actions on each one are not urgent and can wait for them to roll around next time in the count, mostly reading but occasionally writing as well.

I am having to add into one system a device that is poorly laid out in it's addressing.  Normally I would read an entire vector out of a slave, and if needing to send things back altered, it would be adjusted where necessary and then sent back as the entire vector.  I then read it again to ensure it is all correct.  There might only be 10 things I vary, spread across a Vector of perhaps max 90 in length.

In this case, however, the slave utilises some intervening addresses internally, so that if you read a register that you aren't working with at all, by the time you send it back the slave itself may have varied this item and writing the "old" number (via sending the entire vector with only the desired changes) upsets it's operation.  It is dumb, but that's the way it works.  The only way it is possible to work correctly is to do the large vector read, but then send alterations back in a myriad of separate sends, just addressing the register in question.

Just to make it doubly interesting, the new unit also has the need to be read/written to more often than the rest.  I have played with varying the count sequencing so that if anything read out of the unit changes in the master "calls", then it interrupts things and the register in question temporarily becomes next in line.  But this gets complex if a whole host of things change at once, meaning a FIFO stack.  And not forgetting that the count routinely checks the new unit 5 times as often as the rest.  I can see a situation where frequent changes might even stop calls to other slaves far longer than desirable.

I have also been trying things using a drum, and this works quite well.  It has innate fixed time, you can vary calls all over the place using the goto, and also speed the general operation up using successful comms flags (delayed a few scans to totally clear buffers) to force progress to the next step.  The main advantage is that it easily varies calls all over the place, in a fashion fairly easily seen on the initial programming screen...ie the drum layout.  The end result is similar to the count variation, but totally different approaches.

All of these seem very processor intensive, hence my ask.  I know some people's ideas might be very profound and they don't want to share their ingenuity, but if you can, please do so.

I'm sure such a discussion will benefit lots of people.

Cheers,

Aus

Link to comment
Share on other sites

Aus, kb9tms at yahoo dot com, send me blank msg and I'll send you back a Vision 1210 file with MODBUS master polling 4- V430 slaves. If that would help, the program was ran live in the field until master was replaced with UniStream 15.6 rendering Vision program obsolete. Would rather not release code to public domain. I may be able to find a timer based example also. First one that comes to mind is  counter/index driven. -dB

Link to comment
Share on other sites

  • MVP 2023

Thanks Hots, on it's way.

In the meantime, I found a 485 card I'd forgotten about on the spares shelf, and am considering putting this into the system to give me another port which I'll use just for the new device.  Running 2 ports might be the easy solution.

cheers,

Aus

Link to comment
Share on other sites

  • 2 years later...

I am in the process of trying to get my 1210 to communice with a string of 120's and 130's via modbus 485 for a total of 10 PLC's in a master slave set up. Each of these plcs need to be read and written too. I am rather new to networking PLC's and mostly self taught. Your expertise of programming I believe would greatly help me in my struggle with this. Ausman and hotwires could you send me examples or vlp files of what you did to get your systems working properly? Thank you!

Link to comment
Share on other sites

  • MVP 2023

Hi Lacey, in your case I would not be using modbus.  I would be strongly looking at UniCan, which will easily achieve everything you want and in a faster time.

In case you missed it, have a look at the first post linked below and the file attached there.  It should get the braincells going on the advantages and ease of UniCan to achieve what you want to do.  The second post link is my thoughts on using Excel that make a very confusing part of this operation easy.  Repeating what I say there, it is essential that you don't lose track of things when using UniCan, otherwise it can become a big mess.  Also note that until you get ALL your UniCan directives/controls/elements into ALL your plcs, things might not work as expected.  I always have UniCan stuff as a sub, and during development I often put a manually controlled MB in front of the sub's call, so that I can load all the programs in and then roam quickly around turning things on.  It can make it easier to track a potential issue.   If you have it all set up correctly it works a treat.

http://forum.unitronics.com/topic/6550-displaying-mi-from-one-plc-to-another/?tab=comments#comment-26561

http://forum.unitronics.com/topic/6527-with-vectors-why-didnt-i-think-of-this-ages-ago/?tab=comments#comment-26422

cheers, Aus

Link to comment
Share on other sites

Ausman, I appreciate the information but sadly I had to go with modbus. Half of the cabling was already ran and modbus ports were the only thing I had available on all 10 PLC's. 

On 8/23/2017 at 8:37 PM, hotwires said:

Aus, kb9tms at yahoo dot com, send me blank msg and I'll send you back a Vision 1210 file with MODBUS master polling 4- V430 slaves. If that would help, the program was ran live in the field until master was replaced with UniStream 15.6 rendering Vision program obsolete. Would rather not release code to public domain. I may be able to find a timer based example also. First one that comes to mind is  counter/index driven. -dB

Hotwires, would you be willing to share how you did this with me? I am having trouble figuring out how to get my master to poll each plc one after the other. 

Link to comment
Share on other sites

  • MVP 2023

You're going to have to make a stepping program to address each slave separately.  This is going to be a bit of a beast.  Since you have to read and write each slave and they are Unitronics PLCs, I'd make use of the special Modbus Read/Write Mixed Data function.  A couple of questions-

1.  Have you made a mapping spreadsheet showing what registers in each slave will go to / come from which registers in the V1210?  If you haven't, do that first.

2.  Have you started the program for the V1210?  All you'll need in each slave is a Modbus Config and a ScanEX block.

If you can post the programs you've done so far we can hack it up and try to help.

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