From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

case selection using boolean on a text case structure

Solved!
Go to solution

Hi

 

I'm a newbie to Labview and I'm learning with some small tasks.  I've created a traffic light system using a case structure/state machine that cycles through the RED, AMBER, GREEN colours.

 

What I would like to do now is put a button on the front panel that if pressed sets the traffic light to RED permanently, like in the event of an accident, and then when switched back or off the sequence resumes.

 

I've done some searches and with the case selection being text and buttons being boolean I'm struggling to come up with a reasonably solution.

 

Thanks in advance for any advice help.

0 Kudos
Message 1 of 3
(4,172 Views)
Solution
Accepted by blast_uk

Here is a slightly cleaned up version which accomplishes what you were looking for.

 

Traffic Light.png

 

Some general notes about LabVIEW coding. Try to keep your block diagram neat and organized. That means minimize bends in wires and align your nodes. This helps make teh code much easier to read. In addition, the ENUMs in this code should be a typedefed ENUM. That way is you need to modify the ENUM all copies of it will be updated. If you simply copy and paster them you have to manually edit every one. (I didn't create the typedef and replace all the copies for you.) You would need a better state machine to handle the delay if you wanted to handle the accident condition in a more timely fashion. The "Wait" state would not wait the full duration but a small fraction of the time and repeat until your reach the desired time. This would allow the lights to switch to Red very quickly after the accident condition.

 

 

 

 

 



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 2 of 3
(4,165 Views)

Thank you Mark for the reply and the coding advice.

 

Your solution appears clear and simple which is what I was hoping for.

 

I will look at the code tomorrow as its 12.30am and I havn't got Labview on this machine.

 

Kind regards.

0 Kudos
Message 3 of 3
(4,153 Views)