07-24-2024 05:59 PM
Hi
This is a state machine for a traffic light, easy. Well, not so much for me at least
After a loop ends and the state machine goes to the shift register, to go to the next cycle(1, then 2, then 3, then 1 again), but it just doesnt enter to the event structure with the new value(After the first cycle, wich is 0, goes to 1) but it stops there, before the event cycle, i need to click once again the button for it to enter, but i need to just click once and the state machine just keep going until i press "pause" to interrupt the cycle like an emergency stop in a machine, i don´t know what i'm doing wrong there.
Solved! Go to Solution.
07-24-2024 07:16 PM
Thank you for attaching your VI but it's in LabVIEW 2024 which a lot of us don't use. If you save it back to 2019 then a lot more people can look at it.
Just guessing from your screenshot though, it's probably one or both of two things:
First, you don't appear to have a timeout case input set up. If you don't set a timeout, then the only time the loop will move is when a button is clicked. You may need to add a timeout case, setting it to a low value.
Second, it looks like you pass through two shift registers through your structures, but on the outputs I can see that they are set to "use default if unwired". Right-click on those outputs and turn that off, then wire the shift registers to those to preserve their values:
07-24-2024 07:52 PM - edited 07-24-2024 07:58 PM
You need to start with some basic tutorials.
Your loop cannot complete the iteration until all code in it has completed. Since your event structure waits forever until start, pause, or end is pressed, it will hang there. You have no timeout wired, so it will wait forever (default is -1).
07-25-2024 12:41 AM
As s simple example how three lights can change as a function of time, have a look here.
07-25-2024 10:18 AM
I did what you said, but still, it doesn't "cycle" i need to still push the button for it to keep going in each of the cases.
I cant find a solution 😞
I just need for the program to start when i click, keep cycling, if i press pause, to stop everything, if i press end, to end the cycle
i did the save it for a previos version now, thank you
07-25-2024 10:21 AM
I know i need tutorials, i'm not an expert at all, im just a student
I managed to do things that i believe are more difficult than this, but right now im just blocked to this correctly
Im sorry if it bothered you
I tried what you said, but still didnt fin the solution.
07-25-2024 10:22 AM
It's simple, i know how to do a simple traffic light
But i need this to have an emergency stop, a start cycle, an end cycle and a stop program
Thats why i cant do it
07-25-2024 10:32 AM - edited 07-25-2024 10:33 AM
I cannot open your attached vi, but from the first post I can see you are waiting for ever on the event structure.
That is one of the reasons it is not cycling... there maybe more.
Good luck
07-25-2024 10:38 AM
The traffic light is a standard LabVIEW test question and there are lots of webpages covering it. Just search "LabVIEW Traffic Light".
Here is a simple one: Traffic Light State Machine Demo Using LabVIEW - NI Community
There is no need for an event structure unless you are doing an advanced intersection simulation that detects cars waiting to turn, etc. Keep it simple until you have the basics down.
07-25-2024 10:59 AM
@NIquist wrote:
There is no need for an event structure unless you are doing an advanced intersection simulation that detects cars waiting to turn, etc.
A traffic light system does not have a user interface and any traffic sensors need to be polled at regular intervals. Even if this is simulation where sensors are manually activated on the front panel, polling is the only realistic way to implement it, no event structure should ever be used for this!
@NIquist wrote:
Here is a simple one: Traffic Light State Machine Demo Using LabVIEW - NI Community
A 3 or more second wait is poor and makes the code unresponsive. In contrast, my example is even simpler and better 😄