LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to let one event transfer data to another event which is running?

Dear All,
I don't know how to do it :One event case is trigged and it is waiting another event to give it data.
I have tried it, but when another event is trigged, the vi will not stop.
This is the simple version of my vi.
Thank you!
 
Hugo
0 Kudos
Message 1 of 3
(2,544 Views)
Let's dissect your code:

1... You have a timeout of 1 mSec. Is it really necessary to detect the STOP button within 1 mSec? I doubt it - change that to 100 or something, and your CPU will run a bit cooler.

2... Each time you timeout, you set the STOP LOOP flag to the value of the STOP button. That will work, although you could do that via an event more easily.

3... When Button 1 is changed, if it's ON, you set the display to 1 (and do nothing if it's off).

4... When Button 2 is changed, if it's ON, you continually test (probably a million times per second) the DISPLAY, and don't stop until it's > 0. During this time you are doing nothing else.

The problem here is item 4. If the numeric is not set > 0 when you start that inner loop, it will NEVER get set, because you are not allowing anything else to happen. Your code says to wait here until it's >0, but there is no chance for anything to affect it.

Re-think your design. It's almost always a bad idea to have a WAIT UNTIL SOMETHING HAPPENS piece that's INSIDE an EVENT case.

Event cases should examine the current state, modify the state if appropriate, and get the heck out.

Maybe you could use the TIMEOUT event to check the states. If Button 2 has been pressed AND button 1 has been pressed, then light the light.

Steve Bird
Culverson Software - Elegant software that is a pleasure to use.
Culverson.com


LinkedIn

Blog for (mostly LabVIEW) programmers: Tips And Tricks

Message 2 of 3
(2,540 Views)
Thank you for your patient guidance.
I have modified my vi under your suggestion.
Thank you very much.
 
 
Hugo
0 Kudos
Message 3 of 3
(2,528 Views)