Traffic light controller and delay timer

Thread Starter

spudda123

Joined Apr 19, 2021
15
I'm firstly struggling on how to draw a moore machine for a 2-way traffic light system which goes red-amber-green on both the main street and side street. I think I need 8 states and 3 inputs for this? It is for a uni project so I can attach the brief or lab sheets if more detail is needed
 

Irving

Joined Jan 30, 2016
3,843
A Moore machine is a finite state automaton whose next state is determined entirely by the current state without external input.

So that begs the question firstly why you consider you need three inputs**?

Secondly, each street goes through a fixed light sequence. In the UK that would be:
RED
RED-AMBER
GREEN
AMBER
then back to RED - so 4 states, but your sequence might differ.

Now, what's your thinking so far?


**Edit: it seems a Moore machine can have 'internal' inputs, transitional triggers such as time delays.
 
Last edited:

Thread Starter

spudda123

Joined Apr 19, 2021
15
A Moore machine is a finite state automaton whose next state is determined entirely by the current state without external input.

So that begs the question firstly why you consider you need three inputs**?

Secondly, each street goes through a fixed light sequence. In the UK that would be:
RED
RED-AMBER
GREEN
AMBER
then back to RED - so 4 states, but your sequence might differ.

Now, what's your thinking so far?


**Edit: it seems a Moore machine can have 'internal' inputs, transitional triggers such as time delays.
This is a photo of the brief I was given, it shows the 8 states they’re looking for I assume as it’s a 2-way system. I’m just not sure what the input(s) would be and where to go after drawing the 8 circles and linking them Together
 

Attachments

Irving

Joined Jan 30, 2016
3,843
So show your state diagram so far, and what you think the 3 inputs are..

The clues are in the brief, remembering 'inputs'are triggers for state transitions.
 

Irving

Joined Jan 30, 2016
3,843
OK, that's one approach. Can you think of an alternative map?

In either case, how will you handle the other key inputs in the brief? Can you see what they are?
 

Thread Starter

spudda123

Joined Apr 19, 2021
15
OK, that's one approach. Can you think of an alternative map?

In either case, how will you handle the other key inputs in the brief? Can you see what they are?
The only other way I can think is input 1- E-W on for 4s, input 2- button pressed E-W (N-S on for 8+s)
 

Irving

Joined Jan 30, 2016
3,843
OK, I see in the brief they've forced you to follow 8 sequential states. An alternative approach would be to consider the state machine for each street in isolation, and then cross-linking the two state machines. that would be more flexible (eg if, later, you wanted to add a pedestrian crossing button on each street corner as well).

As I read it, the priority on the main street implies it sits on state 0 (G-R) until triggered by the arrival of a car on the side street(s) but the state doesn't change until main street has been in the G-R for at least 8 seconds. So you need to add the timing transitions. Apart from the state machine have you created a state transition chart?

Have you read the bit about timing of state transitions and the Mealy machine (which isn't in the notes you've shown us)? How does that integrate with your state machine?
 

Thread Starter

spudda123

Joined Apr 19, 2021
15
OK, I see in the brief they've forced you to follow 8 sequential states. An alternative approach would be to consider the state machine for each street in isolation, and then cross-linking the two state machines. that would be more flexible (eg if, later, you wanted to add a pedestrian crossing button on each street corner as well).

As I read it, the priority on the main street implies it sits on state 0 (G-R) until triggered by the arrival of a car on the side street(s) but the state doesn't change until main street has been in the G-R for at least 8 seconds. So you need to add the timing transitions. Apart from the state machine have you created a state transition chart?

Have you read the bit about timing of state transitions and the Mealy machine (which isn't in the notes you've shown us)? How does that integrate with your state machine?
I'm currently just working on the traffic light controller then moving on to the mealey machine for the delay-timer. I have done a state transition table which I will attach.
 

Attachments

Irving

Joined Jan 30, 2016
3,843
I think you're pretty much there. Your state transition input Y and Z, what do they represent and does that match the brief? Also, while not considering the Mealey machine completely you do need to factor its ouputs as inputs alongside Y and Z, rather than hanging them on the end.
 

Thread Starter

spudda123

Joined Apr 19, 2021
15
I think you're pretty much there. Your state transition input Y and Z, what do they represent and does that match the brief? Also, while not considering the Mealey machine completely you do need to factor its ouputs as inputs alongside Y and Z, rather than hanging them on the end.
For that I just did Y- cars waiting and Z- cars through. And as for the timings, shall I just transfer the columns next to Y and Z then so they’re together? Thanks for your help btw it’s cleared a few things up for me
 

Irving

Joined Jan 30, 2016
3,843
Ok, I get where you're coming from with Y and Z though I'm not yet 100% convinced that meets the brief, but if you're comfortable with it...

Finish the table and integrate the Mealey machine and let's review that :D

BTW I do a very similar exercise with my Arduino programming tutorial for my MSc students, though we do a simplified approach to state machines (they don't do the math just the hi-level concept). We include pedestrians crossing with red/green man and visual/audio countdown as an add-on requirement... Its a nice example of how a state machine can simplify what otherwise is a daunting bit of programming.
 
Last edited:

Thread Starter

spudda123

Joined Apr 19, 2021
15
Ok, I get where you're coming from with Y and Z though I'm not yet 100% convinced that meets the brief, but if you're comfortable with it...

Finish the table and integrate the Mealey machine and let's review that :D

BTW I do a very similar exercise with my Arduino programming tutorial for my MSc students, though we do a simplified approach to state machines (they don't do the math just the hi-level concept). We include pedestrians crossing with red/green man and visual/audio countdown as an add-on requirement... Its a nice example of how a state machine can simplify what otherwise is a daunting bit of programming.
I'm currently working on the Moore machine for the TLC rather than a Mealey which it asks for for the delay-timer in the next part. Not sure if that changes things regarding moving the timing columns? Also, I've moved the reset to the S0 rather than S4. (I made the table a while ago, hence why I'm confused now I've come back to it as I've kinda forgotten what I did). I've attached an updated Moore machine (I wasn't sure if adding the X's instead of having multiple transition lines was correct so I just underlined them alongside rather than change the whole thing for it to be wrong to use the X's).
 

Attachments

cg5939

Joined Apr 29, 2021
6
spudda I have a very similar project, where did you get up to in the end with your moore machine state diagram and state table?
 

Thread Starter

spudda123

Joined Apr 19, 2021
15
spudda I have a very similar project, where did you get up to in the end with your moore machine state diagram and state table?
Hi, I managed to complete both and linked in the delay timer, I’m not sure if it works correctly yet tho as we need to fix our ripple counter to test properly. Is there anything specific you need help with?
 
Top