From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
05-06-2020 12:48 PM
So this is my question:
Place the traffic light into a While Loop with a timer so that it actually runs on a two-minute cycle as specified. In the first 55 seconds of a cycle, the traffic light is green. From 56 to 59 seconds, the traffic light is yellow, and from 60 seconds until 120 seconds, the traffic light is red. This process should repeat indefinitely until clicking the Abort button on the front panel turns it off.
So basically. this traffic light I use flat sequence.
Please show me the simplest method to SHOW TIMER ON FRONT PANEL TO THE USER.
Shown below is my code
Thank you
Solved! Go to Solution.
05-06-2020 01:47 PM
You don't need any sequence structures or local variables. All you need is a state machine that spins at a reasonable rate and goes to the next state depending on elapsed time.
05-06-2020 02:21 PM
12-29-2021 07:43 AM
Hello, could you please explain more on this part? I did not understand how does the Constant of the traffic light affected the index array function. Next, why do you put the HR Relative second VI inside and outside the loop in addition using the subtract Boolean ?
12-29-2021 07:57 AM - last edited on 09-10-2022 01:34 PM by altenbach
The underlying value of an enum is an integer. So the three colors red, yellow, green are assigned the integer values of 0, 1, and 2 (I don't know what order they were assigned). When a "red" value is wired into the index array, it is giving the value at index 0, for example. When you add 1 to "red", it will then become "yellow". Enums automatically roll over, so red+1=green. (note that you need to use the +1 primitive not the plain add function)
The HR Relative second before the loop gives the time when the program started. Inside the loop, it gives the time at each iteration. So subtracting the two gives the time elapsed since the program started.