LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger a while loop from a T/F data input?

I have a set of VI's I've created that open a read/write serial port, open a data file, and then wait for a T/F trigger signal from the serial port (this all works ok). When that T/F trigger happens, I want to start a second while loop that records data until the stop button is pushed. (Reading the material on Control References has been absolutely no help.)

Ideas appreciated!
Dave
0 Kudos
Message 1 of 8
(6,028 Views)
If the second while loop is going to be running in parallel to the first one, I'll suggest you consider using "occurrence." Take a look at Advanced Synchronization Techniques in LabVIEW. There are sample vi's included.
In case you want to run the second while loop withing the first one, use the T/F trigger to control a case structure with embeded while loop.
0 Kudos
Message 2 of 8
(6,028 Views)
The attached VI demonstrates a very basic structure for what you are wanting to do. Note that there are some things that you will probibly want to add--like more robust event handling--but this should get you pointed in the right direction.

If you have any question on specific parts of the structure, fee free to hollar.

Mike...

Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion

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

For help with grief and grieving.
Message 3 of 8
(6,028 Views)
> I have a set of VI's I've created that open a read/write serial port,
> open a data file, and then wait for a T/F trigger signal from the
> serial port (this all works ok). When that T/F trigger happens, I want
> to start a second while loop that records data until the stop button
> is pushed. (Reading the material on Control References has been
> absolutely no help.)

You want to start both loops and have the button loop go to sleep
waiting for notification. You want the serial loop to analyze the data
and when appropriate send the notification. Once the button loop takes
off again, it will be completed when the button is pressed, and this
button will also cause the serial loop to finish.


What notification functions might you want to use? Look at th
e
synchronization palette and specifically look at notifiers, semaphores,
and occurrences. I believe the notifier is what you want.

Greg McKaskle
0 Kudos
Message 4 of 8
(6,028 Views)
Mike, this was the link I was looking for - some way to sequence various loops.. I have some tuning yet to do, but it looks very much like this logic will solve the problem!

I've added most of my serial read/write/etc steps to your framework - I'm initializing the serial device, opening the datafile, and waiting for the trigger. When that trigger happens, the next loop starts up and is writing out to the file (intermediate step of telling the external device what to read is in process, and is easily added.) It's working!!

Thanks very much!
Dave
0 Kudos
Message 5 of 8
(6,028 Views)
Mike, where did the small function on the far left of your basic_structure.vi come from? It doesn't come up as anything in context help when I click on it, etc (just says error in).

I suspect it is the error cluster you so helpfully demonstrated - but I don't find documentation on anything that looks like it in the help or even here online.

I want to add some additional structures in the middle of the several while and structure functions, and need a better understanding of what this "error cluster" is, in order to be able to expand and reduce it in my programs. (-as in if I delete one of the purple lines (error out ??), how to rebuild it again!)

Thanks again! The program is working great!!

Dave
0 Kudos
Message 6 of 8
(6,028 Views)
Dave - it's just a cluster constant. Right click for functions pallette>>cluster>>cluster constant -- stick your constants inside (in this case false,0,string constant)... then resize to suit...

Paul.S
0 Kudos
Message 7 of 8
(6,028 Views)
The error in/error out cluster controls are on the Array & Cluster palette and are explained in the LabVIEW User Manual. Chapter 6 has a whole section called "Error Checking and Error Handling". The LabVIEW User Manual is a .pdf file and is part of the shipped documentation. Go to the Help menu and select "Search the LabVIEW Bookshelf".
0 Kudos
Message 8 of 8
(6,028 Views)