Need help on traffic light project!

Thread Starter

koshi

Joined Sep 25, 2014
27
Hello,

Can I know how is your button being designed?

If I use the one I attached some posts earlier on, would it make any difference?

I don't get the purpose of the OR and inverter before the FF.
 

MrCarlos

Joined Jan 2, 2010
400
Hello koshi

The clock signals V and P are generated in the circuit in document MOD 7 MOD 3 Needed.PDF That I have attached to my message #18.
And arrive at the circuit in document The Five Lights.PDF Enclosed in the same message.
 

Thread Starter

koshi

Joined Sep 25, 2014
27
Hello,

For the MOD3&7, what is the purpose of the NAND gate? I would like to discard the BCD 7 segment decoder portion since I would not be using that. So for the output to these mod counters I would just keep it unconnected? And to sum it up, these 2 in the mod pdf is just to create the two clocks right? And I would need another 2 191 chips for the 5lights.pdf?

Also, I notice in the 5 lights, there are bubbles at the input of the AND gate, do I need to apply inverters to the input for such?

Lastly, for the decoder/multi 139 chip, on pin 12, I am suppose to connect the clock inputs there right?

Side qn: The blue/red dots in the 5lights represent +ve/-ve?
 
Last edited:

MrCarlos

Joined Jan 2, 2010
400
Hello koshi

You're asking:
For the MOD3&7, what is the purpose of the NAND gate ?
This tells me you're too novice in digital circuits. Well, anyway.
Put front of you the circuit contained in the file MOD 3 & 7 Counters.PDF.
As you might know the 74LS191 is a binary counter; counts from 0 to F (HEX).
And it can be done in ascending or descending. This way:
X asce X desc
0 0000 F 1111
1 0001 E 1110
2 0010 D 1101
3 0011 C 1100
4 0100 B 1011
5 0101 A 1010
6 0110 9 1001
7 0111 8 1000
8 1000 7 0111
9 1001 6 0110
A 1010 5 0101
B 1011 4 0100
C 1100 3 0011
D 1101 2 0010
E 1110 1 0001
F 1111 0 0000

Since we want to know when have gone three seconds, need a counter to count from 3 to 0.
Counting downward, the next number after the 0 is F. . . Right ?
Therefore all Q’s outputs of the U4 counter, will have a one (1).
The symbol of the 4-input NAND gate (U5:A), what it say to you ?
Well said: When All its inputs are 1's (Because AND Function) its output will be zero (0) because the small circle on its output.

Ok. The output of this NAND gate is connected to the PL(11) control input of U4.
So this control input is true (0), by the small circle that look there.

-Every time you see a small circle in inputs or outputs of any logical symbol means that the FUNCTION is true when it is zero(0)-.

What does this mean ?.
Well: The state of the D's on U4 will go to their respective Q's.
What number have programmed in D's inputs of U4 ??
The number 3. . . Right ?
Thus the counter U4 is restored to 3. . Right ?
And U4 continuous counting from 3-0

Through this talk do an exercise for the MOD 7 counter. Please.


You're asking:
I would like to discard the BCD 7 segment decoder portion since I would not be using that.
So for the output to these mod counters I would just keep it unconnected ?

Yes, of course: you can remove all that is in the box marked with red lines.
But they remain the connectors called (Clock P and Clock V).
These are the signals for the counters of pedestrian traffic lights and vehicles.

You're asking:
And to sum it up, these 2 in the MOD pdf is just to create the two clocks right ?
And I would need another 2 191 chips for the 5lights.pdf ?

My answer is Yes to both questions.

You're asking:
Also, I notice in the 5 lights, there are bubbles at the input of the AND gate, do I need to apply inverters to the input for such ?
That symbol of the AND gate is called De'Morgan Gates.
Now put front of you the circuit contained in the file The Only Five Lights.PDF.
Speaking about the ICs U4 and U9:C.
We have already said that the 74LS191 requires a 0 in its PL input control. Yes, by the small circle that appears there.
This counter U3 is pre-programmed in its inputs D's to zero. . . Right ?
So when its input control PL(11) is true (0), the U3 counter is reset to zero. . . Right ?
U9:C tells me that any 0 in Its input (Because it is an OR gate), I will output a 0. . . Yes, by the small circle that appears there.
Basically U9:C is a 2-input AND gate. The statement to the AND gates is:
Until all its inputs are 1 (Because AND function) its output will be 1.
So any 0 at any input (Because OR function) will give 0 on its output. . . Right ?

You're asking:
Lastly, for the decoder/multi 139 chip, on pin 12, I am suppose to connect the clock inputs there right?
Ok: The 73LS139 PIN 12 is connected to a red color LED and a CONNECTOR, arrow-shaped called Stay In Red P.
So, everywhere you look similar to this connector with the same name, it means that they are interconnected.
If the tip of the arrow is pointing out, is output.
If the tip of the arrow is pointing inwards, is input.

You're asking:
Side qn: The blue/red dots in the 5lights represent +ve/-ve?
Not exactly, what point, is the logic state of the place where they are.
Red is 1, High level.
Blue is 0, low level.
Gray is undefined. neither high nor low.

Remember, the circuit with the Flip-Flop D type (U8: A) and associated components do not work as you expect. I've already had mentioned.
This part of the circuit you have to do it.
 

Attachments

Last edited:

WBahn

Joined Mar 31, 2012
30,058
I know I'm a Johnny-come-lately and perhaps this has already been cleared up, but it didn't seem so from my quick perusal of the thread.

My take is that the scenario here is a single street, not an intersection of streets, that has a crosswalk in the middle of it and the light is for the crosswalk. These are not too common, but they certainly exist. The details of the project have been further simplified a bit from how real such lights work and the timings have been greatly simplified and shortened for the purposes of the project. With that in mind, it often helps to lay out an event sequence that makes sense and use that as a guide when making the flowcharts and/or state diagrams. This should help:

State 2: Light is green for traffic and red for pedestrian.
State 3: Light is yellow for traffic and red for pedestrian.
State 1: Light is red for traffic and green for pedestrian.

You then go back to State 2. (I used the same state numbers as in the OP, but put them in an order that I think makes more intuitive sense)

So there are only three states and, furthermore, there is never a decision that has to be made regarding what state to go to next, only when to go to it.

The next step is to identify the sequence of events that happen as you enter a state and what determines when you exit a state.

According to the description, in the absence of a button being pressed, each state will last for seven second and then automatically proceed to the next state. The button merely shortens the amount of time it might spend in State 1. This actually seems a bit counter-intuitive, especially for a highly simplified project like this. I would have had the system simply remain in State 1 until someone pressed the button. But that doesn't seem to be how it was written.

So let's ignore the button for now:

State 2: Light is green for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon expiration of the timer: Go to State 3
State 3: Light is yellow for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon expiration of the timer: Go to State 1
State 1: Light is red for traffic and green for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon expiration of the timer: Go to State 2

Now we just need to add in the effect of the button. According to the information given, it is insensitive during State 1 (meaning that someone can't extend the time for the pedestrian green) or during the three second countdown time that it initiates (which makes is to that additional pushes don't restart the 3-second timer). It also seems like it should be insensitive during State 3 since this state means that the light is about to turn green for the pedestrian anyway. The description is inconsistent in this regard, but I suspect that it is supposed to be insensitive during State 3, so that is what I will assume.

So let's add in the button, but ignore the 7-seg display:

State 2: Light is green for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon Button Push: Start a 3-second countdown timer.
Upon expiration of EITHER timer: Go to State 3
State 3: Light is yellow for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon expiration of the timer: Go to State 1
State 1: Light is red for traffic and green for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon expiration of the timer: Go to State 2

Now here is something that is tricky and I suspect they are doing something unintuitive to simplify things. If someone presses the button one second before the light would have turned yellow for vehicles, it really doesn't make sense to hold it green for another two second to wait for the light to expire. But the description explicitly says that the light won't turn green for pedestrians for ten seconds once the button is pressed. My guess is that they did this so that you don't have to have a second timer or logic to trap when you are already within three seconds of the light turning anyway.

So let's impose this interpretation:

State 2: Light is green for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon Button Push: Reset the countdown timer to 3 seconds.
Upon expiration of the timer: Go to State 3
State 3: Light is yellow for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon expiration of the timer: Go to State 1
State 1: Light is red for traffic and green for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Upon expiration of the timer: Go to State 2

Now we just need to add in the seven segment display. You have to decide what is displayed when it isn't counting down (i.e., in States 2 and 3). You could have it be blank (off completely) or you could have it display 0. The implementation will be simplest if you blank it completely, so lets do that.

State 2: Light is green for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Blank 7-seg display while in this state.
Upon Button Push: Reset the countdown timer to 3 seconds.
Upon expiration of the timer: Go to State 3
State 3: Light is yellow for traffic and red for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Blank 7-seg display while in this state.
Upon expiration of the timer: Go to State 1State 1: Light is red for traffic and green for pedestrian.
Upon Entry: Start a 7-second countdown timer.
Show counter value on 7-seg display.
Upon expiration of the timer: Go to State 2

Now you have a clear roadmap to work from. Do you see how I developed it piece by piece, starting with a very simple outline and then fleshing it out one feature at a time?
 

Thread Starter

koshi

Joined Sep 25, 2014
27
Hi,

I am trying to portray it in a state diagram, but for the button function, I can't seem to implement it correctly. If I put it in a table, where do the button fall under if there's only 3 states?
 

WBahn

Joined Mar 31, 2012
30,058
How can we guide you on your state diagram when you won't show us your state diagram? Make your best effort and give us something to work with.
 

Thread Starter

koshi

Joined Sep 25, 2014
27
Hi,

Can you take a look. TL=1 means it is still counting for 7sec, and TL=0 means it counted finish and proceed to next stage. B is for button.

I haven't started to simplify anything yet since the draft seems to be wrong? Is it right if I add in the timing TL and TS? It seems to be a lot of don't care if I add in the timing.
 

Attachments

WBahn

Joined Mar 31, 2012
30,058
You need to resize your images to something reasonable. Don't expect people to waste their time and bandwidth downloading multi-megabyte files when you can easily get it to fit in an image file 1/10 to 1/100 the size.
 
Top