how do I 'queue' machines using PLC & relays

post #19

Ok. I give. I re-read post #19 and I don't see what you want me to revisit.

As far as I can tell, my code is very similar. Some of the variable names are different, but other than that...

Please point out, specifically, what I'm doing wrong here.

You are using Or-Bool's in whose place?
In the second graphic of post #19, you use 3 SRs. When I animate these, the coils for these are NEVER set. I tried OR_BOOLs in place of the SRs: still nothing.

Instead of using, both, DISABLE_SEL_TMR and ENABLE_WAIT_TMR, why not toggle one variable. That's what I did with my SCAN_DELAY.

I'm trying. đź“š
 
Hickman...

I see the problem. I was still in a digital-logic frame of mind when I made Post #19... that won't work... as you have already seen.

Basically, particular signals are being held HIGH and LOW at the same time... that simply won't do.

Yes, we do need some RESETs on the SR's. They would be "NOT CHECK_X".

However there is more to it than that... it's easy to get into a race condition or hang-state.

I'll be thinking on it today. This sounds like a good place to use a K-Map. The K-Map will eliminate any race conditions and conflicts. I'll think on it...
 
RE: race condition & k-map...

What's a 'race condition'? I've heard the term, but don't understand what it is.

And, K-Map?

Also, you mentioned using NOT CHECK_X. Are you referring to a second variable named NOT_CHECK_X or just the inverse of variable CHECK_X? A toggle of that variable would be my preference. I'm all for conserving memory. Makes the project simpler.

(y)
 
Here's what a K-Map Looks like at least

K-Map Explanation

I'm sure others here can give a much better explanation than I can but here is what it looks like at least. They're basically just a method of simplying expressions.

kmap.jpg
 
RE: alien gibberish

That's GREAT, Coop! Now splain it to me.

I'm not sure, but I think that's the same formula the govt used in Close Encounters to communicate with the aliens. After converting it to music, of course. :D
 
DID you also notice that YOU made the system work?

That after all this what YOU HAVE ALREADY DONE is working AND so far noone has shown another way...let alone a better way??

Notice not many deal with Modicon?

There are times when its acceptable to leave well enough alone.

Play with the software to learn and see what you come up with to make things easier, faster and better in the future.

Would surprise me if Schneider Group..ie Modicon doesnt also have a forum you can goto online.

I think MR PLC.com also has a forum on Modicon
 
re

i'm getting confused here!!!
you said that u want to control 12 motors with PLC and relays but your screenshots shows logic gate array. NIview Widgets??
 
hickman,

I'm pretty sure that this will give you what you want.

(Update: I was pretty sure... then I noticed a problem. I will leave it as I originally designed it and then show what I found and how I handled it)

FIGURE-1:
3f521b2b4086a94e.gif


Figure-1 shows the basic control for your Select Timer, the Select Counter and the Select Output.

As long as power is applied and the WAIT_TMR is not running then the SEL_TMR runs. When the SEL_TMR times out, the counter is incremented and the next motor is selected for check.


Figure-2 shows the control for starting a motor and running the WAIT_TMR.

When CHECK_X is activated, if IN_X is ON and RUN_MTR_X is OFF, then turn ON a signal called START_MTR_X. That signal is applied to the SR to run Motor_X.


FIGURE-2:
3f521b603af3affd.gif


At the same time the signal is applied to a set of OR-Gates. All of the Start_Mtr signals are applied to this set of OR-Gates. Depending on how many inputs you are allowed to use, you might have to OR-the-OR's to get the final signal - STARTING_A_MOTOR.

The STARTING_A_MOTOR signal is applied to an SR which turns ON RUN_WAIT_TMR. This signal causes the WAIT_TMR to run and, at the same time, disables the SEL_TMR.

In Figure-2, as soon as RUN_MTR_X goes ON, then the output from the AND-Gate goes OFF. RUN_MTR_X will stay ON until IN_X goes OFF.

YIKES!!!

I just realized that I have created a highly likely "race condition" in Figure-2. That is just as well!

This allows me to give you a real example of a race condition (in answer to your question) and how to fix it.

A "race condition" exists if all necessary and expected subsequent results do not, or might not, occur before the causal factor is removed - simply because the casual factor is removed too soon.

There are variations on that theme. Some race conditions prevent expected actions from happening while others cause unexpected actions. In any case, a race condition is a timing issue between cause and expected effect.

The "race condition" I see involves the following signals: START_MTR_X, RUN_MTR_X, STARTING_A_MOTOR, RUN_WAIT_TMR and WAIT_TMR_DONE.

The START_MTR_X signal is applied to the SR to produce the RUN_MTR_X signal. At the same time, the START_MTR_X signal is applied through the OR-Gate(s) to produce the STARTING_A_MOTOR signal. That signal is then applied to an SR to produce the RUN_WAIT_TMR signal.

Now... It takes a certain amount of time for a signal to propagate through the various devices.

START_MTR_X goes through one device to produce RUN_MTR_X.
START_MTR_X goes through at least two devices to produce RUN_WAIT_TMR.

It is very probable that RUN_MTR_X will go ON before RUN_WAIT_TMR goes ON. When RUN_MTR_X goes ON, then the necessary conditions for START_MTR_X are no longer present - START_MTR_X will go OFF. It will, of course, take time to turn OFF START_MTR_X - because it takes time for a signal to propagate through a device.

If it happens to be that you are allowed to use a single OR-Gate with 12 inputs (not likely) then START_MTR_X has to go through only two devices to turn ON RUN_WAIT_TMR.

In the time it takes to turn ON the START_MTR_X signal and then turn it OFF, it just might be the case that START_MTR_X will have enough time to cause RUN_WAIT_TMR to be turned ON before START_MTR_X is turned OFF... maybe... it's a "race" to see who finishes first.

If you are not allowed to use 12 inputs on an OR-Gate then the START_MTR_X signal has to go through more than two devices to turn ON RUN_WAIT_TMR. This would pretty much guarantee that the casual factor would go away before all of the subsequent actions were produced - that is, START_MTR_X will go OFF before RUN_WAIT_TMR is turned ON.

So... how is that situation handled?

FIGURE-3:
3f521b963ff2bc62.gif


Figure-3 shows my solution to the race condition. As soon as START_MTR_X goes ON, use that signal to SET "STARTING_MTR_X". This signal will be retained until RESET.

Then, instead of applying START_MTR_X to the OR-Gate(s), apply STARTING_MTR_X. The STARTING_MTR_X signal will remain ON until the WAIT_TMR_DONE goes ON.

Then apply STARTING_A_MOTOR to the SR as shown in Figure-4.

FIGURE-4:
3f521bbe643bb7f7.gif


When STARTING_A_MTR goes ON, the input to the AND-Gate goes OFF and the output from the AND-Gate is turned OFF. This removes the signal from the RESET at the SR which provides RUN_WAIT_TMR. So, with the RESET signal removed and the SET signal asserted, the RUN_WAIT_TMR signal is turned ON.

BTW, In SR Latches, the R Input over-rides the S Input. That is, if both signals are ON then the output goes OFF.

The RUN_WAIT_TMR signal causes the WAIT_TMR to run. While RUN_WAIT_TMR is ON the SEL_TMR is disabled. When WAIT_TMR_DONE goes ON, STARTING_MTR_X goes OFF (START_MTR_X is long gone).

After a certain amount of time, STARTING_A_MTR goes OFF (it takes time for the conditions to propagate through the devices).

Since STARTING_A_MTR is OFF and WAIT_TMR_DONE is ON, the AND-Gate provides a signal to RESET the latch providing RUN_WAIT_TMR. The WAIT_TMR goes OFF and WAIT_TMR_DONE goes OFF.

When RUN_WAIT_TMR goes OFF the SEL_TMR is re-enabled. The process then moves on to check the next motor.


So... Figures -3 & -4 should provide the basis for a functional solution to your original question.

It should also answer your question about "race conditions"... I hope.

Regarding NOT CHECK_X and NOT_CHECK_X, you are correct.
NOT CHECK_X is the Inverse of CHECK_X, as developed at the input to the logic box (the "bubble").

And, K-Map?

A K-Map (named after a guy named Karnaugh) is a method of simplifying combinatorial logic to a minimum number of gates. The smaller the system, the easier a K-Map is to use.

However, what many don't realize is that any system can be broken down into to smaller sub-systems which can then be subjected to the K-Map.

A K-Map can be made to manage mathematical routines. While it doesn't actually do any math, it can easily respond to, or call for, particular math operations in conjunction with field or internal conditions.

It is also a way to create a precise Sequential Control. If all conditions are accounted for, then the resulting code can be written in any order and the logical operation will always be correct. It can even account for unexpected failures in the field. As in all programming, it all depends on the amount of effort the programmer is willing to expend.

BTW, for the PLC Programmers,
These gates translate directly into ladder symbols and rung layout. An AND-Gate is simply two or more inputs in series. An OR-Gate is simply two or more inputs in parallel.

If the input to a particular gate has a "bubble" (a small letter "o") on the line at the input to the gate then that particular signal is subjected to "Examine if OFF". Otherwise the signal is subjected to "Examine if ON".

It really is pretty straight forward!
 
Last edited:
another try...

Ok, Terry. I'll give it another whirl and see what happens. I'll try to work on it some tonight and maybe tomorrow. Tuesday at the latest. Hopefully, I'll get back to ya with a "thumb's-up".
 
RE: misc

Eric: Thanks for the links. I've had to use logic tables or truth tables in the past (formal programming classes & math) but to tell ya the truth, I can't remember how to use 'em. I tried to read thru the thread you suggested, but I was too lost to keep up.

rsdoran: You're right! I do have a working copy of the prog, but I'm trying to make it more efficient. I know it's acceptable to leave well enough alone, but I'm not satisfied at this point. My code is lacking in efficiency. It doesn't meet my acceptable tolerance level, yet. Thanks for the encouragement, though!

t2heck:
you said that u want to control 12 motors with PLC and relays but your screenshots shows logic gate array. NIview Widgets??
I don't understand your confusion. What do you mean by "logic gate array"? And what's NIview Widgets?

I'm still learnin'! đź“š
 
Yet another way (maybe)

I've followed this thread and come up with this solution in AB PLC-5 ladder logic. I checked the Concept stuff out and it does include a FIFO (function block). Whether this will actually work in an FB machine I'll leave for others, I don't want to expend the time and energy figuring out in detail a system I'll likely never see.

Here are two screen captures of the ladder:
motor_q_main.jpg

motor_q_ffl_srtn.jpg


Rung 3 in the first graphic is the motor request logic for motor #4. Motors 1-3 precede it and are constructed similarly, just address and parameter changes. Same goes for rung 6, for brevity, only motor #1 is shown.

When a motor requests startup a subroutine (U:10 - 2nd graphic) is called which puts the motor number onto a FIFO stack. The R6:0/EN unlatch insures that the FFL instruction will always see a false to true transition and that all requests occurring on the same scan will be honored.

Rung 4: Once a request is loaded the FIFO is no longer empty and if the cycle timer is done a number will be unloaded.

Rung 5: The EU bit turned on in rung 4 resets the cycle timer, making it NOT done. The compares which follow will start the motor which matches the EQU in its respective rung.

The following scan the FFU is disabled by the timer done bit and will remain so until the timer is done. At this time the next request, if any, is popped and the cycle repeats.
 

Similar Topics

The idea here is to provide for a brief rapid influx of message codes while preventing sequentially repeating the same message. i.e. if two...
Replies
23
Views
668
I'm fairly green at PLC programming compared to everyone here. I have a firm understanding of most commonly used instructions. Everything I've...
Replies
19
Views
8,131
Hello everybody. For a project, I need to make a queue that stores REAL's. There needs to be the possibility to select a place and than move the...
Replies
9
Views
2,473
So, I'm very new to PLC and HMI's and I was asked to investigate something that occurred with my client's system: They set up a queue list of...
Replies
2
Views
1,545
Well can anybody give me a head start on some logic, I cant just seam to get a start. What I need is 4 lanes to queue and and which ever lanes is...
Replies
13
Views
2,982
Back
Top Bottom