LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

LED indicator--reset??

I have written a vi to measure reaction time by using an LED stimulus.
The program calculates the time difference from when the LED turns on to the time it takes the user to depress a switch. The program measure reaction time correctly.
It uses a while loop to keep measure reaction time until the user chooses to end the program by pressing the stop button to end the loop.
The problem is that when the LED indicator turns on, it does not reset. It stays on, and doesn't even reset even when the iteration is complete.
 
How do I get the boolean indicator to reset after the user has depressed the switch??
 
Thanks!!
 
0 Kudos
Message 1 of 9
(7,714 Views)
And indicator shows whatever data is fed to it. This is probably very easy to fix. Why don't you show us some code so we see what you are doing?
0 Kudos
Message 2 of 9
(7,708 Views)
I will post the code as soon as I get back to it on my other computer.
 
I fixed the problem with a local variable to turn the LED off.
 
Now, the program will only run correctly when I have the block diagram open and "highlight execution" is selected. Shouldn't it not matter whether the block diagram is open?
 
 
 
 
0 Kudos
Message 3 of 9
(7,690 Views)


als040 wrote:
Now, the program will only run correctly when I have the block diagram open and "highlight execution" is selected. Shouldn't it not matter whether the block diagram is open?

This means you have a race condition. Yes, please post your code.
Message 4 of 9
(7,683 Views)
looks like a timing issue.
0 Kudos
Message 5 of 9
(7,675 Views)
Here is the code. I'm a newbi, so it's not good programming 🙂

DAD_14April contains the program with both green and red lights simulating a traffic light.
DAD_Test3 only has the red LED.

Still, the program will only run when he highlight execution is selected.

I have it set to produce a random number, display the red light, detect the signal from the switch, turn off the red light, and record reaction time.

One more problem: Sometimes, the DAQ assisstant does not start aquiring data fast enough to detect the trigger. How do I get it to start aquiring data as soon as the program begins to ensure that the switch depression is detected?


Download All
0 Kudos
Message 6 of 9
(7,640 Views)
You are writing to the same indicator from two different places. Once directly and once via a local variable.
 
I am talking about "Stop!" and "Go!".
 
This is a typical race condition, because you don't know what happens first, and if the two data sources differ (1. the value from the subVI, 2. the "elapsed" boolean output) , the result will be vary depending on the execution order. The indicators might get a TRUE from the "Brake" and 1ns later a FALSE from the elapsed, and you'll never see a thing.
 
What determines the loop time of your while loop? It is probably so fast that any TRUE on the brake will get overwitten in the next iteration anyway.
 
Sorry, I don't have your subVIs and I don't have any DAQ, so I cannot test or even see what you are trying to do in detail. I would recommend to make a hardware-free version using LabVIEW buttons first and then add the hardware interaction later once everything works.
0 Kudos
Message 7 of 9
(7,634 Views)
Thanks for all of your help! I took your advice and made a hardware free version of the VI. It actually ended up working better because I figured out that the reset on the elapsed time should be connected to the output from the "time has elapsed" terminal. I also ended up using only one button with red and green for on and off. I added a case structure to save the data from the brake (red) and not save the data from the green light.

Thanks again! I'm getting better on my debugging skills 🙂 I realized it's easier to put indicators on each wire of interest to figure out what numbers are where and how they are affected by changing different things.


0 Kudos
Message 8 of 9
(7,597 Views)

Could you not just reinitialise to Default value once the code executes that section?

0 Kudos
Message 9 of 9
(5,756 Views)