one to many, and many to one - logic example

TheWaterboy

Lifetime Supporting Member + Moderator
Join Date
May 2006
Location
-27.9679796,153.419016
Posts
1,926
I have several PLC's all running identical parts of a process in parallel. As part of this process when each one is ready they each need to tell a central common PLC to perform a cleaning process that is common to all of them.

Additionally I need that single common PLC to be able to take commands from only one of these other PLC's at a time, holding off the others until it completes its common task and then notify the others that it is available again.

There is no way to know in advance which PLC will want control ahead of time so a command needs to be sent to the common PLC asking for its availability and then if it is available, lock out the others.

At this time a token passing technique is used but if anything goes wrong in the process, or it gets manually cancelled, or the planets align just right, the token gets lost and both that common PLC and the one that called it get out of sequence and end up offline.

I hope this is clear, I have a couple untested ideas in my head how to make this work but if anyone has done this before I would love to see how you did it.

I intend to use Produced and Consumed tags to allow the multiple PLC's to monitor the common PLC status and availability and a MSG from the multiple PLC's to the common one to ask for its control when needed.

A RND number included in each request being sent from each PLC and echoed in the P/C tags would insure that the PLC that sent the same number actually has control in case of a comm or logic race condition occurs.

All sounds good in my head - sure would like some feedback.
 
How about:
All other PLC's talk to Master PLC via Produced / Consumed
Master PLC maintains a FIFO queue of requests
Master PLC sends to everyone who has control of the common process (first entry in the FIFO)

To ensure that all PLC's are using the latest "Who has control" have a control counter that increments when the control changes

eg

Common -> ALL PLC4 in control and counter = 1
waits for ALL to respond with counter = 1
Common -> ALL PLC4 in control and counter = 2
PLC 4 now knows that it is in control and all other PLCs are locked out and does its thing
eg PLC6 sends request to common
eg PLC3 sends request to common
PLC 4 sends to common no longer needed
Common -> ALL PLC6 in control and counter = 3
waits for ALL to respond with counter = 3
Common -> ALL PLC6 in control and counter = 4
PLC 6 now knows that it is in control and all other PLCs are locked out and does its thing
PLC 6 sends to common no longer needed
Common -> ALL PLC3 in control and counter = 5
waits for ALL to respond with counter = 5
Common -> ALL PLC3 in control and counter = 6

This will also work if you do not use Produced / consumed

It is assumed that the parallel part PLC must wait until the part has been cleaned before continuing.
 
I wouldn't go to the trouble of a random #...Not needed, IMO. Seems pretty simple to me...I just did one for a chemical processing plant:

Create a queue/array of Integers large enough to accommodate all the stations in the common PLC. The common PLC monitors this queue and shifts the entire thing whenever there is a hole (IE value = 0). So you load at the back of the stack, and a simple routine shifts this new request up as long as the next array spot = 0. This packs the array with requests.

The common PLC monitors the array index 0 for a non-zero value. When it sees one, it knows this the next PLC requesting its use. If the common can run it, it copies this requested PLC # into a register shared to all other PLCs. The PLC that matches the # sends its part. All the other PLCs that don't match wait.

Once the common finishes, it clears it, the queue moves up and the process repeats.

For cases where a requested PLC wants to cancel, that's easy to manage to. Create an additional BIT from each PLC that says its online and ready to be processed. When the queue moves up to next requested PLC, the common checks the BIT in addition to the requested # and if the BIT is not ready, either move the request to the end of the queue or just delete it and go to the next one.
 
Waterboy,

give some thought to including an error trap - after the sequencing/decision logic is written, write a 2nd section that checks for totally invalid entries (like - all remote plc's =1 or all plc's =0) and either trips the process, or throws an error bit/flag so you can troubleshoot.
...you'd be even better if you could make the same code handle a startup condition.
...and have some "PLC availability check" on the front end, so you dont get 5 steps into the process and have to stop becuase the forklift driver ran into some conduit.

-John
 
Thanks for the thoughts - I am working through it. I am not concerned with maintaining a FIFO schema, an operator decides which goes next.

The handshaking logic between the PLC's is turning out to be an enjoyable exercise in the KISS principle. The more I try add to it the more the potential for error becomes evident so I take it back out. Its keeping me humble.

I am using the shared register technique and trying to simplify that too.

Since I have each remote PLC monitoring the status of the common PLC at all times via the P/C tags, the error trapping takes place in the remote PLC's before attempts to write to the common PLC ever take place. In addition a watchdog in the common PLC monitors a moving value in the shared register and bails out of everything when it trips.

At least thats what is in code - haven't run it on hardware yet.
 

Similar Topics

I have an application that needs 20 inputs and 20 outputs with only 10 XNOR and 10 NAND blocks. I could do it with relays, but this could end up...
Replies
16
Views
5,169
Good Evening , We have a number of Powerflex 525 Drives . I took notice for years elsewhere and our plant , that our Powerflex 525 drive...
Replies
0
Views
639
Good Afternoon, Just wondering , are many of you using SAP in your plants ? If so , is it difficult to learn ? Are there many training...
Replies
10
Views
1,419
It better to have too many instead of not enough right?
Replies
26
Views
2,893
Hi all- I have an application where: - I have a fixed system with a pre-determined, static, network (say, 192.168.2.0/24). - That system...
Replies
13
Views
4,238
Back
Top Bottom