Light Controller

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
Hi
The purpose of this question is only to learn how to create a state diagram.
Just assuming I have to create state diagram for traffic control system

Red light is indication for pedestrians to stop

Green light is indication for pedestrians to go straight

Yellow light is warning indication for pedestrians that signal is about to change to red

Red light will turn on only for 60 second's
Green light will turn on only for 40 second's
Yellow light will turn on only for 20 second's

I do not understand the transaction for system. I have shown necessary current and next state in table

IMG_20200808_152716.jpg
 
Last edited:

WBahn

Joined Mar 31, 2012
29,932
Your state diagram also needs to include information about when to take the transitions. For a fully synchronous machine, you need to indicate what happens on every clock cycle in every state. Let's assume that your system has a countdown counter (whose output we'll call T) and that the clock runs at 1 Hz. You could then have six states, R, R0, Y, Y0, G, G0. The R0, Y0, and G0 states set the counter to the necessary time for that light (so in R0 you set T=60) and then goes to the corresponding next state (so R0 goes to R, etc.). The R will have two arrows leaving it -- one arrow that goes to the next color's initialization state when T=0, so R goes to G0 -- and an arrow that loops back to the same state for T!=0.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
. Let's assume that your system has a countdown counter (whose output we'll call T) and that the clock runs at 1 Hz. You could then have six states, R, R0, Y, Y0, G, G0. The R0, Y0, and G0 states set the counter to the necessary time for that light (so in R0 you set T=60) and then goes to the corresponding next state (so R0 goes to R, etc.).
Thank you for help.

Ok. Truth table of down counter

IMG_20200808_230634.jpg

So I have no problem in creating a table, The problem is I do not understand how to convert it into a state diagram of light system. I tried to make state diagram #1 but the state diagram is not complete
 
Last edited:

jpanhalt

Joined Jan 18, 2008
11,087
Assuming it is a 4-way intersection for cars, shouldn't the state diagram include the lights for the cross street. For simplicity, you might label the streets NS (NorthSouth) and EW (EastWest).

There are other places and types of road intersections where traffic lights are used, but 4-way intersections are by far the most common in the US.
 

dl324

Joined Mar 30, 2015
16,788
So I have no problem in creating a table
The first line of the table doesn't make sense to me. You go from all lights off to all lights on. Neither of those states should be allowed.

Pedestrian traffic is usually controlled by walk and don't walk signs. If they need a warning for when the light is going to switch to red, there's usually a numerical display that counts down.
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
. Let's assume that your system has a countdown counter
The first line of the table doesn't make sense to me. You go from all lights off to all lights on. Neither of those states should be allowed.
@dl324 As WBahn said to assume the down counter, so I created the table for down counter. I didn't think about the light, what would be the difference in the output. But you have a valid point.

All lights should be off when the system is power off and red light should be on when it starts. Red light should be on for 60 seconds, After that the green light should be on for 40 seconds and after that the yellow light should be on for 20 seconds and then the red light should be on. Whole process should be repeat continuously.
 

WBahn

Joined Mar 31, 2012
29,932
If you want to include the counter states as part of your state machine, that's fine, but then you really need to call them something other than R, G, and Y as those strongly imply whether the corresponding lights are on of off.

You would also need a LOT more states. If your clock is at 1 Hz, you would need 120 states. If you really wanted to go this route, I'd slow the clock to 1/20 Hz so that R lasts for 3 states, G for 2 states, and Y for 1 state, yielding a total of six states.

But what I was suggesting is that you have a separate count-down timer that you can load with a particular value and that you can check it's current output value. That also results in a six-state machine, but for unrelated reasons.
 

WBahn

Joined Mar 31, 2012
29,932
Does the table given in post #1 make any sense? Total we have eight states. I've only taken four possible state.
Yet your diagram only shows three states.

Your diagram is a representation of your table. Given one, a person should have all the information they need to construct the other.
 

jpanhalt

Joined Jan 18, 2008
11,087
That is my question and I am seeking help for the same. I don't understand how to represent remaining states or branch in state diagram shown in first image
I don't see a problem with only 3 states if the purpose is to draw the state diagram for that. The fist state diagram in Wikipedia on this subject has just 2 states.

Of course, that is not a "real" traffic light. As you point out, without power, it is off. But then, most things are that way. Maybe that's considered a trivial state. In real life, there is a "not functioning" state that most traffic lights enter when they are being serviced or for some other reason fail. For a single light without a cross street (e.g., a light used for flow control) it might be a flashing yellow or green. With a cross street, it is usually a flashing red, but I have seen flashing yellow for the main thoroughfare and flashing red for the cross street.

I think you need to define a real situation and work from there; otherwise, this thread will end up addressing every possible scenario including but not limited to roundabouts, 6-way stops, flow control (e.g., entrance to busy freeways), traffic lights on runways, and so forth.

AN906 (Microchip) describes the state diagram(s) for driving stepper motors. That might be a more suitable challenge, unless this assignment specified traffic light.
 

dl324

Joined Mar 30, 2015
16,788
I am assuming all the lights will be off when the system is off , when power will on, the Red light will be On to indicate don't cross the road
I don't know of any traffic/pedestrian control signs that aren't on 24x7; except for maintenance and power outages.

That is my question and I am seeking help for the same. I don't understand how to represent remaining states or branch in state diagram shown in first image
If you really want to learn how to do this, you need to work out all of the details. Otherwise, one of us will eventually just post a solution.

For starters, if you're going to use green, yellow, and red indicators, they're for controlling automobile traffic, not pedestrian. So make up your mind. Second, most pedestrian control signals are triggered by pedestrians. If there are no pedestrians, it doesn't make sense to stop turning auto traffic. Some pedestrian controls don't allow pedestrian traffic for a full cycle because that could affect auto traffic that is turning.

If you're controlling traffic at a 4 way intersection, you need to have two sets of lights. Before you can start solving a problem, you need to define it completely.
 

Deleted member 115935

Joined Dec 31, 1969
0
State diagram.

Start with writing blobs , one for each of the states.

then for each state in turn, look at how you get from that state to another, and draw a line between the two, with a note on each line, as to what makes you take that route, Think of it liek a flow chart in programming,,,

Then in each state, document what is happening,

So if one state is cars running, you would have green light on for cars, red for pedestrians.
You stay in that state till a pedestrian presses a button,
so you draw a line between cars running to button pressed, and put on the line "button pressed"
in state button pressed , what state are the lights ?

The cars are still running , and the pedestrian are still stopped, so cars are still green, pedestrians red.
you stay there, for say 5 seconds, and move to next state, draw line, and the change,
in this state , you now stop the cars,
and wait for say 5 seconds,
then you move to next state, pedestrians can cross,
here you turn on the green pedestrian light, and wait for say 5 seconds.

then what ? any thoughts ?
 

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
Hi Ritesh, please resist the temptation to go back to All OFF.

Busy OP in two forums. HE's back!!
@atferrari It is one o'clock at night. I was about to sleep but I saw your post. I thought I should answer your question. I do not know any Ritesh, Your allegation is absolutely wrong. It is very wrong to accuse anyone. This is a way of insulating,

Yes I am on the another forum like you said , What's wrong with this

Edit : by the way , I have read some of his threads. Very strange boy. Am i so bad that you compare me to him?
 
Last edited:

Thread Starter

Djsarakar

Joined Jul 26, 2020
489
That hadn't occurred to me... Thanks for the warning.
The reason for not replying in thread is that I was looking for a simple example, which I can convert to state diagram. A complete example of the traffic signal was difficult for me.

I have tried my best to create a state diagram of a simple traffic light system. I am not able to create a basic state diagram for traffic light system. So creating a state diagram for a complete traffic control system will be difficult.
 
Top