4 green 4 red

jimcav

Member
Join Date
Dec 2004
Location
new jersey
Posts
229
hey guys

i have been thinking about this on and off know for days. here it goes i have 8 lights, 4 green and 4 red. 1 green and 1 red make up a station, there are four stations. when some one turns on the switch at station 1 the green lite comes on. when some one turns on the switch at station 2 the green lite come on, and so fourth. i need this to work in any combination when 3 are green the 4th needs to be red. the trick is this need to work in any combination. i was thinking of using a counter but if possible i would prefer XIO AND XIC. i will be using a ab micro 1100.


thanks
guys
 
Jim,

I would move the bits to a word then compare the word...but then again just compare the input word, =/> set-bit

Here I did a mask move (you should not have to) but in the next rung GEQ set your value in source B, your source A should be looking at your in put file, so your result in this rung would light your 4th red lamp...Try it I think it may work, there are many ways to do it.

compare.gif
 
How about:

| SW1 L1RED L1GRN
|--] [--]/[------------( )
|
| SW1 SW2 SW3 SW4 L1RED
|--]/[--] [--] [--] [--( )
|
| SW2 L2RED L2GRN
|--] [--]/[------------( )
|
| SW1 SW2 SW3 SW4 L2RED
|--] [--]/[--] [--] [--( )
|
| SW3 L3RED L3GRN
|--] [--]/[------------( )
|
| SW1 SW2 SW3 SW4 L3RED
|--] [--] [--]/[--] [--( )
|
| SW4 L4RED L4GRN
|--] [--]/[------------( )
|
| SW1 SW2 SW3 SW4 L4RED
|--] [--] [--] [--]/[--( )

... just a thought. So basically the first 3 switches to turn on, get green lights. The fourth gets a red light ... even if it does get turned on ... last. You didn't mention any kind of latching requirement or reset function ... so if ... say ... the second switch turns off ... then the fourth WILL go green ... and then the second WILL go red.
I suppose it could be reduced by using some built-in function. But this uses simple I/O.
But hey ... I'm new here ... so what do I know?
Just my 2 cents,
- Tony
 
Using NetMans code, in each Red Light rung, parallel the NC contact with a NO contact of the Red Light. This will latch in the Red Light status at that station, even if the switch is turned on, preventing the green light turn on. It will take one of the 3 NO contacts to release and turn off the red light.

At that point the station can turn on their switch getting a green light. Even better, if the previously Red station's switch is already on, it will turn green as soon as one of the other three turns off. AND the station that turned off will immediately get its own Red light.
 
After simulating my suggestion in the previous post I realised that it didn't deal with the worst case of all 4 switches being ON at startup. To prevent a lockup put a NC (XIO) of the 'First Scan' bit in each green light rung. Also place a NO (XIC) of the 'First Scan' bit in parallel with the latch bit (mentioned in the previous post) in each red light rung. This causes all 4 red lights to be on waiting for one switch to be turned off.
 
Classic Karnaugh!

I have to admit that, although I know what a Karnough map is, I'm a little at a loss as to how exactly I would apply one in this case. If we were only turning one green light on, and one red one, I believe I could come up with some workable code from a karnaugh map and a couple of truth tables. But I'm not sure how you would do it with a light on each one, and only the last one activating the red light. At least, I'm not sure it would be the simplest or most elegant solution.

Could you throw me a couple of clues Terry?
 
Basic rung:



Other Green 1 This On OK
------+-----|\|-----+-------------------------------------------( )---
| |
|Other Green 2| This Switch This Green
+-----|\|-----+----------| |------------------------------( )---
| |
|Other Green 3|
+-----|\|-----+
| |
| This Green |
+-----| |-----+
|
| This On OK This Red
+-----|\|-------------------------------------------------( )---





Four times fill in in appropriate references
 
Tom...

First of all, the problem was described very poorly. From the description, as it is, I get the following impressions...

There is a Green Light and a Red Light at each station.

Green indicates "Running", while Red indicates "Inhibited".

When no stations are running...
- ALL lights, at all stations, are OFF! No Green... No Red!

When any station is started...
- The Green Light, at that station, is illuminated.

When any three stations are running...
- The Red Light at the fourth station, whichever one that is, is illuminated.
- That station is thusly prevented from starting!

What that means is... whenever a switch is turned ON at a station, doing so is essentially a "request to run" that station. If three other stations are already running, and the Red Light at this station is illuminated, then that station is not allowed to start.

What this means is... whether, or not, a station can be started depends on whether, or not, it is "Inhibited"! If not "Inhibited", it can start, and the Green Light will be turned on at that station. If that station happens to be the third station running, then the Red Light at the remaining station is illuminated.

So... whether, or not, a particular station can be started depends on the status of the Red Light associated with that particular station. If the Red Light is ON, it is "Inhibited", and it can not be started... if the Red Light is OFF, then it can be started. Once started, the light goes Green. And then, if that station happens to be the third running station, then the light at the last station, whichever that one is, goes Red.

So, what this boils down to is... the switch is a "request to run", and then, depending on the status of the Red Light associated with the particular station... the station might, or might not, be allowed to run. Then... if allowed to run, the Green Light associated with that station goes ON!

Do you get the picture? The running-status of the station depends on the status of the Red Light at that station, and then, depending on that status, the subsequent action controls the status of the Green Light at that station.

Are ya dizzy yet? I sure am. The point is, the scheme can NOT be as simple as jimcav described.

At the very least, I would replace the switches with push-buttons. If a switch is used, then, if the switch at the fourth station was ON when any of the other three stations goes OFF... then the fourth station would start... maybe unexpectedly!

HOWEVER... since jimcav described the problem as he did, here is the complete K-Map solution to the problem... as he described it.

NOTE:
To some, the following might look like a lot of effort for very little result. Some people will say that they can come to the same conclusion without going through all of this cra-p.

Well, it's my contention that they do go through all that... no matter what... whether they do it on paper, or they do it in their heads! More experienced programmers will certainly do this kind of stuff in their heads. All I'm doing is showing the novices the logic behind how the conclusions are derived... that is, what the more experienced players are doing... in-their-heads.

As far as I'm concerned, the following is only part of the total solution. And again, the following applies only to the problem as described by jimcav.


"A" = Run Station-1
"B" = Run Station-2
"C" = Run Station-3
"D" = Run Station-4

In the following map...
Alpha = GREEN Example: A,C = "A Green" and "C Green"
(Alpha) = RED Example: (D) = "D Red"

The box with the ??? represents the "Not Allowed" condition.
That is, it is not allowed to have all stations on at the same time.

Let's map all station light conditions...

C D
0 0 0 1 1 1 1 0
A B +-----+-----+-----+-----+
| | | | |
0 0 | ALL | D | C,D | C |
| OFF | | | |
+-----+-----+-----+-----+
| | | | |
0 1 | B | B,D |B,C,D| B,C |
| | | (A) | |
+-----+-----+-----+-----+
| | | | |
1 1 | A,B |A,B,D| ??? |A,B,C|
| | (C) | | (D) |
+-----+-----+-----+-----+
| | | | |
1 0 | A | A,D |A,C,D| A,C |
| | | (B) | |
+-----+-----+-----+-----+

Now, let's map the conditions for "A" (Station-1) to be Green or Red...

"A" C D
0 0 0 1 1 1 1 0
A B +-----+-----+-----+-----+ A B C D
| | | | | 0 1 1 1 = "A-Red"
0 0 | | | | |
| | | | |
+-----+-----+-----+-----+ A B C D
| | | | | 1 0 X X
0 1 | | | (A) | | -or-
| | | | | 1 X 0 X
+-----+-----+-----+-----+ -or-
| | | | | 1 X X 0 = "A-Green"
1 1 | A | A | ??? | A |
| | | | | (A !B) + (A !C) + (A !D)
+-----+-----+-----+-----+
| | | | | A ( !B + !C + !D) = "A-Green"
1 0 | A | A | A | A |
| | | | | Note: !B means "Not B"
+-----+-----+-----+-----+

Now, let's map the conditions for "B" (Station-2) to be Green or Red...

"B" C D
0 0 0 1 1 1 1 0
A B +-----+-----+-----+-----+ A B C D
| | | | | 1 0 1 1 = "B-Red"
0 0 | | | | |
| | | | |
+-----+-----+-----+-----+ A B C D
| | | | | 0 1 X X
0 1 | B | B | B | B | -or-
| | | | | X 1 0 X
+-----+-----+-----+-----+ -or-
| | | | | X 1 X 0 = "B-Green"
1 1 | B | B | ??? | B |
| | | | | (!A B) + (B !C) + (B !D)
+-----+-----+-----+-----+
| | | | | B (!A + !C + !D) = B-Green
1 0 | | | (B) | |
| | | | |
+-----+-----+-----+-----+

Now, let's map the conditions for "C" (Station-3) to be Green or Red...

"C" C D
0 0 0 1 1 1 1 0
A B +-----+-----+-----+-----+ A B C D
| | | | | 1 1 0 1 = "C-Red"
0 0 | | | C | C |
| | | | |
+-----+-----+-----+-----+ A B C D
| | | | | X X 1 0
0 1 | | | C | C | -or-
| | | | | 0 X 1 X
+-----+-----+-----+-----+ -or-
| | | | | X 0 1 X = "C-Green"
1 1 | | (C) | ??? | C |
| | | | | (C !D) + (!A C) + (!B C)
+-----+-----+-----+-----+
| | | | | C (!A + !B + !D) = "C-Green"
1 0 | | | C | C |
| | | | |
+-----+-----+-----+-----+

Now, let's map the conditions for "D" (Station-4) to be Green or Red...

"D" C D
0 0 0 1 1 1 1 0
A B +-----+-----+-----+-----+ A B C D
| | | | | 1 1 1 0 = "D-Red"
0 0 | | D | D | |
| | | | |
+-----+-----+-----+-----+ A B C D
| | | | | X X 0 1
0 1 | | D | D | | -or-
| | | | | 0 X X 1
+-----+-----+-----+-----+ -or-
| | | | | X 0 X 1 = "D-Green"
1 1 | | D | ??? | (D) |
| | | | | (!C D) + (!A D) + (!B D)
+-----+-----+-----+-----+
| | | | | D (!A + !B + !C) = "D-Green"
1 0 | | D | D | |
| | | | |
+-----+-----+-----+-----+


So, the Ladder looks like this...

B A
---|/|---+---| |---( "A-Green" )
|
C |
---|/|---+
|
D |
---|/|---+


A B
---|/|---+---| |---( "B-Green" )
|
C |
---|/|---+
|
D |
---|/|---+


A C
---|/|---+---| |---( "C-Green" )
|
B |
---|/|---+
|
D |
---|/|---+


A D
---|/|---+---| |---( "D-Green" )
|
B |
---|/|---+
|
C |
---|/|---+


A B C D
---|/|---| |---| |---| |---( "A-Red" )

A B C D
---| |---|/|---| |---| |---( "B-Red" )

A B C D
---| |---| |---|/|---| |---( "C-Red" )

A B C D
---| |---| |---| |---|/|---( "D-Red" )



.
.
Essentially, I look at the Green conditions as nothing more than status,
while the Red condition is both a status and an "Inhibit" signal.
The Green conditions are used to develop the Red condition.

It's really tough dealing with poorly defined problems.
 
I think that was Terry's point

russrmartin said:
My question is, who in the heck ever dinks around with a karnaugh map, when they could be developing code? :)

NOTE:
To some, the following might look like a lot of effort for very little result. Some people will say that they can come to the same conclusion without going through all of this cra-p.

Well, it's my contention that they do go through all that... no matter what... whether they do it on paper, or they do it in their heads! More experienced programmers will certainly do this kind of stuff in their heads. All I'm doing is showing the novices the logic behind how the conclusions are derived... that is, what the more experienced players are doing... in-their-heads

Or to put it plain to fully understand and write code you will need to be able to think in the fashion that a Karnaugh map represents.

I have always written out things on paper before creating code but now, because of Terry, I use Karnaugh maps because I am not experienced enough to do it in my head. I have no idea if it has made me better but sure has made it faster, I do not struggle as much. There are many situations when writing code like the situation Terry has defined, in some cases there could be even more variables involved, the more variables the harder it can be to fully grasp or define all the what ifs.
 
Last edited:
Excellent... Thanks for the help Terry.
I'll sit down and study this a little bit more later, and see if I can wrap my head around it a little better.
 
I particularly like in Terry's implementation if the 4th switch is turned on then ALL lights turn off. Very symetrical. Then as soon as one switch is turned off the other 3 go back to green.
 

Similar Topics

Today I was making an online edit to a 5/40 Series E Rev K.2 with about 14% free memory. I was removing one branch in a large rung. Accept...
Replies
4
Views
3,163
Hi; I have 02nos AB Stratix 2000 (1783-US05T) Ethernet switches having 5 ports. I have a problem that the Power indications of both switches...
Replies
2
Views
1,926
Hey All, I'm working in Logix5000 and was wondering if anyone had some code I could steal to make a cool sequence for my stack light to run while...
Replies
4
Views
2,753
Hello everyone. This is my first post to the forums and I came here looking for some help on a ladder diagram. Okay so what I'm trying to do is...
Replies
6
Views
2,834
Anyone know of a 22mm or 30mm indicator that can be powered from either: - 120VAC to 277VAC or - 208VAC to 480VAC I'm working on a little relay...
Replies
3
Views
1,645
Back
Top Bottom