LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

While loop inside Event structure

Hi,
I am trying to make a program that can acquire data from a DAQ. I have it set up with an event structure which has a while loop inside of it. For every loop of the while loop i grab one piece of data. For the events i want to click a button which starts sampling data. Right now i click the button it stays down adn samples data jsut fine but I want to be able to click it again and have the event structure go back to timeout mode, but whenever i click the button nothing happens.
any suggestions?


0 Kudos
Message 1 of 9
(4,054 Views)
Can you upload your vi so we can have a look at what your trying to do.
Lots of questions... For example, exactly which event type are you triggering off? What stops the while loop?
Troy - CLD "If a hammer is the only tool you have, everything starts to look like a nail." ~ Maslow/Kaplan - Law of the instrument
0 Kudos
Message 2 of 9
(4,048 Views)
hi, ill upload it tomorrow when im at work. As for the two questions listed: I am triggering a value change event with a button on the front panel. I thought I coudl have that button also wired to the loop condition so that when the person clicks it a second time it would end the loop. The other option I am thinking about is putting the event inside the loop, but I have tried this and when the loop executes and loops back the event wont fire becuase i have it set as a value change on the button. ideas?
0 Kudos
Message 3 of 9
(4,035 Views)
Actually I would say that you have the code inside out. What you want to do is have the while loop with the event structure inside it. Put your acquisition code in the timeout event and get the timeout value from a shift-register that is initialized to -1. Now create additional event cases to handle the other buttons and controls on the application's front panel. One of those buttons might be one that sets the timeout for the timeout event based on the acquisition state. If acquisition is being turned on set the timeout value in the SR to something very short - like 1ms. If acquisition is being turned off set the timeout to -1 (no timeout).

With this structure the acquisition will happen the same as it does now, but if a button is pressed or a control is changed, it will be serviced immediately.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
Message 4 of 9
(4,024 Views)
We had similar discussions in the past. For one solution, have a look at my example in this old post:
 
 
 
0 Kudos
Message 5 of 9
(4,021 Views)
altenbach is there anyway you can post a screen shot of that example you posted in that hyperlink in your last post. I am runnin 7.1 and cant view the vi.
thanks
0 Kudos
Message 6 of 9
(3,992 Views)
A screenshot will not help much, because it has several cases. I converted it to 7.1 instead. (I cannot test the conversion in 7.1, hopefully it's OK).
 
0 Kudos
Message 7 of 9
(3,977 Views)
You can also do it with just one button.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

"... after all, He's not a tame lion..."

For help with grief and grieving.
0 Kudos
Message 8 of 9
(3,963 Views)
thanks alot. i got it all working now. i can now see and record beautiful data.
thanks

0 Kudos
Message 9 of 9
(3,950 Views)