LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event case wouldnt cycle

Solved!
Go to solution

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.

Mahesvara_0-1721861877479.png

 

0 Kudos
Message 1 of 11
(484 Views)

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:

Kyle97330_0-1721866577021.png

 

Message 2 of 11
(460 Views)

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).

 

  • Please connect your terminals to the code and eliminate ALL (all!!!) local variables. your terminal belongs after the case structure. LabVIEW does not have variables, "the wire is the variable".
  • Also the wait belongs outside the case because it is shared by all cases.
  • Your upper shift register makes no sense because the value can never change. you can even delete that case structure.
  • an "equal true" is the same as a boolean wire and just returns the other input wire unchanged.
Message 3 of 11
(451 Views)

As s simple example how three lights can change as a function of time, have a look here.

0 Kudos
Message 4 of 11
(424 Views)

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

0 Kudos
Message 5 of 11
(400 Views)

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.

0 Kudos
Message 6 of 11
(399 Views)

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

0 Kudos
Message 7 of 11
(398 Views)
Solution
Accepted by topic author Mahesvara

Frozen_0-1721921595413.png

 

 

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

---------------------------------------------
Certified LabVIEW Developer (CLD)
Message 8 of 11
(383 Views)

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.

LabVIEW Pro Dev & Measurement Studio Pro (VS Pro) 2019
Message 9 of 11
(380 Views)

@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 😄

Message 10 of 11
(371 Views)