LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Triggered AI Read + While Loop?

I would like to be able to monitor the clicks of buttons on my main VI panel while it is waiting for the triggered AI read to happen.  If I put a while-loop with the AI read block, the loop will continue forever and the VI execution will never make it out of the current frame.
 
Can you suggest a way to be able to do stuff while the AI Read is waiting for a trigger?
 
Thanks,
Dave
0 Kudos
Message 1 of 9
(2,599 Views)
You could have your Read be in a subVI and onyl execute the read once a button was pressed or some other event (using an event structure).  Another good structure to use is the producer/consumer set up, but it can get a little more complicated.

You may also consider running 2 while loops in parallel to execute the counting of clicks and the reading at the same time (but that would usually mean that both are running at the same time).

You could also do a while loop with a case structure in it.  The while loop would contain the code for counting and the case structure could check if the Rewad had been triggered yet.  If it has not been triggered, do nothing, if it has, then execute the read.

There are many possibilities, if you want to see some examples, let me know and i can make up some VIs quick to illustrate what I mentioned.

Kenny

Kenny

0 Kudos
Message 2 of 9
(2,597 Views)
But how do I know when the triggered AI Read has completed?  It is hardware triggered and is confirgured in the MAX as such.
 
Dave
0 Kudos
Message 3 of 9
(2,595 Views)
The hardware triggers the Read, does it also tell it to stop??  Or is there a set number of data points that you aquire or a set amount of time that you have it to aquire??
 
If you ahve a time that you need to aquire, you could use a Tick Count (ms) VI to count a certain amount of time and compare that to a constant and wire it to the stop button of the while loop.  Or if it is a set number of data points, you could do something similar and wire the iteration counter of the while loop to a comparision and to the stop button.
 
Or you could have another button that tells the AI read to stop taking data so you could stop it at any time.
 
Kenny
Kenny

0 Kudos
Message 4 of 9
(2,588 Views)

Sorry I should have been clearer.  There is only one sample being read, so there is no while-loop containing the read.  Would it be possible to use the event handling mechanism to sense the value-change in the error out of the AI Read block?

Dave

0 Kudos
Message 5 of 9
(2,586 Views)
If you wanted to try that approach you can, but I think that you would have to add in a simple error handler after the AI read and on the Simple error handler, there is an output "error?" which is a boolean.  You can wire an indicator to that and then the event structure can sense a value change in the indicator.
 
A thought came to mind, why couldnt you use the Retrevial complete boolean output on the AI read to sense when you are done?  You could wire an indicator to it to let the operator know that the read is complete or you could have it stop the While loop that has the monitoring of buttons in it.
 
How many buttons/what are the buttons needed for that you need to monitor them??  If you need to do a bunch of tasks that may need to be done AFTER the AI Read, then it would probably be best to use a producer consumer structure.  That way you could do many things and ahve the AI Read handled in the background.  But if you jsut ahve a start/stop button, then a while lopp and an event structure will work just fine.
 
I attached a simple VI to give some ideas on things you could do.
 
Kenny
Kenny

0 Kudos
Message 6 of 9
(2,581 Views)
why couldnt you use the Retrevial complete boolean output on the AI read to sense when you are done
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
I'm using DAQmx and I don't see such an output.  This is exactly what I am looking for though.  Is there anything like this in the new DAQmx api?
 
Dave
0 Kudos
Message 7 of 9
(2,579 Views)
Try this VI.  I know that it seems like a lot of work to get a simple boolean out, but ti was what i thought of off the top of my head.  I am sure ther are other ways to do it.
 
Sorry, I assumed when you said AI Read that you were using traditional DAQ.
 
Kenny
Kenny

0 Kudos
Message 8 of 9
(2,576 Views)
I was looking through some of the examples shipped with LV 8.0 to find an answer to a question I had and I found that there is a VI that is Daqmx Task done, located in Measurement I/O > Daqmx > Task Config/Ctrl.  That will give you a boolean out when the task is done.  The example is "Cont Gen Voltage Wfm-Int Clk-Analog Start.vi"


Kenny
Kenny

0 Kudos
Message 9 of 9
(2,555 Views)