Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Trigger Stop Data Acquisition when Move Completed

I'm new to triggering and synchronizing DAQmx with motion events and timing. It's not all that intuitive to me how to programmatically stop a data acquisition. I would like to initiate data acquisition at the moment a servo motor starts to move. I have done this through establishing a breakpoint and a trigger. I have tried several methods of stopping the data acquisition at the preceise moment when the move (only 1 milimeter or so, but very slow) is complete, and have not had much luck. I have attached a recent VI I made as an example, where the "wait for move" complete" was implemented to no avail.  What am I missing here? Should I be implementing a second breakpoint? If so, how? Should the DAQmx read vi be in a loop?
 
I am using DAQmx, PXI-7344, and PXI-4462.
 
Any advice, no matter how base level, would be appreciated.
 
Thanks,
 
ROB M.
0 Kudos
Message 1 of 6
(3,057 Views)

Hello Rob M.,

When the move completes, is there a pulse generated that could be used as a trigger?  If so, you could use a reference trigger to stop the acquisition.  There is an example VI in the Example Finder named Acq&Graph Voltage-Int Clk-Dig Ref.vi that you could look at. 

The way that your DAQmx acquisition is setup currently, you are acquiring however many samples are in the buffer when the DAQmx Read is called, then checking if the move is complete.  If it is, you call the stop task, and if not, the wait until done VI.  However, you are not setup for a finite acquisition which is where you would use the wait until done VI.  It would be better to use a while loop around the DAQmx Read VI to read a set number of sample each iteration until the move is complete.  You could use the boolean output from your subVI to stop the while loop.   This would be one way to stop the acquisition in software.  If you need an example of how to set up a continuous acquisition, you can look at Cont Acq&Graph Voltage in the Example Finder.  You are basically setup the same way, except that you do not have the while loop. 

Let us know if you have additional questions.

Regards,

Laura

0 Kudos
Message 2 of 6
(3,039 Views)

Thanks, Laura F.

I was able to create a VI that accomplished what I needed it to do, although I'm still unsure of exactly how it works. I have inlcuded this VI as an attachment as a sample for others. I was unsuccesful in my attempts to apply a second breakpoint for tiggering a stop signal via a reference trigger, but found a way to implement the check move complete and it's logic status in the same loop that holds the DAQmx read VI. I don't think this is the most elegant way to accomplsh the stop acqusition function, but it works. I would eventually like to get a handle on the triggering for DAQmx and utilize motion breakpoints more effectively for this purpose. I will probably post in the Motion forum for some advice on this matter.

I must say, that I find it odd that such a roundabout method (looping a finite read with special parameters) needs to be employed to create a programmatic stop function in DAQmx. Also, in my opinion, I find the documentation that qualitativley describes triggering (reference triggers, pre-triggering requirements, post-triggering requirements, etc.) to be less than adequate. A tutorial with several key teaching VI's would be a great addition to NI support.

Thanks again,

ROB M.

VI description: Can be used to collect data from an interferometer. Analog input from a photodiode. A small translation stage powered by servo motor with optical encoders. Plug in distance of move (+/- for forward/reverse), velocity, acceleration, sample rate, target file for collected data, etc. As soon as move initates, data acqusition starts via a motion breakpoint tigger. Buffer is read continuously until loop condition says stop due to move complete.

0 Kudos
Message 3 of 6
(3,027 Views)

Hello ROB M.,

Thanks for the feedback.  A better way to programmatically stop the acquisition is to set up a continuous acquisition and then use some condition, such as the one from your "Check Move Complete Status" to stop the while loop, stopping the acquisition.  You would use this if you did not have a hardware trigger to use for a reference trigger.  The only concern is that with a continuous acquisition, you must acquire some number of samples from the buffer each loop iteration, and if this is a high number, it may take a long time for these samples to be returned so your acquisition will not stop as quickly as you would like it to.

Regards,

Laura 

0 Kudos
Message 4 of 6
(3,011 Views)

Thanks again. Here's another question:

The example VI (#2) that I posted above only works when the DAQmx reference trigger VI is present, in addition to the start trigger VI. However, I am only specifying the start trigger through a motion breakpoint. I don't intend to have a reference trigger as a stop trigger b/c i am using  the "check move complete" VI to control the loop execution. i.e.: I'm not sending a hardware based stop trigger over an RTSI line. So, why does the application not start acquiring data when this reference trigger VI is removed?

ROB M.

0 Kudos
Message 5 of 6
(3,000 Views)

Hello ROB M.,

To make the VI work the way that you want it to, you should change the sample mode from Finite Samples to Continuous Samples in the DAQmx Timing VI.  Then, you can delete the Reference Trigger VI and everything should work the way you expect - samples are acquired continuously after the start trigger is received until the "check move complete" VI stops the while loop.

Let us know if this doesn't work.

Regards,

Laura

0 Kudos
Message 6 of 6
(2,981 Views)