# Creating a state diagram

Discussion in 'Homework Help' started by koshi, Oct 22, 2014.

1. ### koshi Thread Starter New Member

Sep 25, 2014
27
0
Hi,

I have another thread regarding the traffic light project which is yet to be completed.

Apparently, some helpful people has provided me with some schematic diagram to work on but how do I work on creating a state diagram that will lead me to a circuit implementation.

But it doesn't show how I can implement it with various clock inputs.

2. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
You should only be using one clock. You should never* try to use multiple clocks on a sequential circuit.

*in the engineering sense, meaning this is a rule that can be broken on rare occasions only when you know what's going on.

3. ### koshi Thread Starter New Member

Sep 25, 2014
27
0
Hi,

I am only using 1 555 timer as my clock. What I mean is that I need to have a 7sec and 3sec counter for the traffic lights, so I need to use the 7sec and the 3sec output to connect to something to do the counting for the LEDs.

4. ### tshuck Well-Known Member

Oct 18, 2012
3,527
675
It sounds like you need to make 7 and 3 second counters each with a count enable/reset. Or, you could incorporate the counters into your main state machine and output the requisite signals, though it would also serve to muddle the design work...

The way that allows you to do the most unit testing is the independent counters approach. They may also need the ability to signal the time has expired.

5. ### WBahn Moderator

Mar 31, 2012
20,224
5,748
You need to first decide what your states are. You don't have to get this right on the first attempt -- make your best effort and as you realize that your current attempt lacks necessary information, revise it. Forget about implementation, we are talking conceptual logic here. List your states and what they mean. For instance. You might have:

State 0: This tells me that the light is green for vehicles and red for pedestrians.
State 1: This tells me that the light is yellow for vehicles and red for pedestrians.
and so on.

Once you think you have your states defined, draw them on a piece of paper (or whatever) and then ask yourself what information you need that would tell you to go from one of those states to another state. Don't worry about whether you can think of how to represent or capture that information, the first thing is to identify the information you need. For instance, you might have an arrow going from State 0 to State 1 with the notation, "After 7 sec in this state or 3 sec after the button is pushed, whichever happens first." This is a pretty complex condition that is not easy to see how to implement it, but that's fine, because it is a condition that is easy to comprehend for a human that captures the information we need to eventually implement.

As you proceed you may find it necessary to define additional states to capture more information, or you might rely on other signals to do that. For instance, you might split State 0 as follows:

State 0.0: This tells me that the light is green for vehicles and red for pedestrians and that the button has not been pushed.
State 0.1: This tells me that the light is green for vehicles and red for pedestrians and that the button has been pushed.

Then you might have an arrow going from State 0.0 to State 0.1 that says, "When button pushed," an arrow from State 0.0 to State 1 that says, "After 7 sec," and an arrow from State 0.1 to State 1 that says, "After 3 sec." Now we have three conditions that capture the same information as the earlier one, but each of these three is very simple and much easier to see how to implement.

If you are having problems getting all of this at one time, start simple. Create your own problem to solve that is much more tame. For instance, make a system that turns a light on for 7 sec and then turns it off for 3 sec and repeats.