Counter/Timer

cancel
Showing results for 
Search instead for 
Did you mean: 

6259 pulse train start trigger

Attempting to perform a finite acquisition several times in a row at a certain rate using a pulse train generated by one of the counters as the start trigger.  The plan was to use the number of samples to acquire and the rate to acquire them to calculate the rate of the pulse train (# of samples / rate = period of pulse train).  Since obviously it will take some small amount of time for the DAQmx VIs to execute in the while loop I added a control to add a cushion to the pulse train period ( period = X + (# of samples / rate) ). 
 
Based on the X value I input I get a error because X is too small and my acquisition times out because one of the pulse trains went by before my while loop came back around to call the next DAQmx Start.  If I set X to be 40-50ms greater than the time it takes to execute one iteration of the loop I still get a timeout.  I.e. specifying one acquisition run and benchmark the time it takes to execute the loop, I get about 60ms.  If I then specify a cushion time X of 100ms (60 + 40) I still get a timeout on the 4th or 5th iteration when I go to run the loop 5 times.  Sometimes the loop time of the later iterations is greater than twice the calculated pulse period and it doesnt timeout, which doesnt seem to make sense.  If I specify an X value of 500ms it works as it should, but I need to run about 10 times faster than that.
 
Anyone have any insight or a possibly better implementation to do what I need to do?  Other than going to Real-Time?
 
thanks,
Quintin
 
0 Kudos
Message 1 of 2
(3,192 Views)

Hi Quintin,

It sounds like you are trying to accomplish a "Finite Retriggerable Pulse Train" to time analog acquisition.  This is set up in an example (Help>>Find Examples) by the name of "Multi-Function-Ctr Retrigg Pulse Train Generation for AI Sample Clock.vi".  A search for 'retriggerable' in the Example Finder is an easy way to find this example.

This example only starts and stops each task once.  This is the most efficient way to achieve this functionality since there is overhead involved in restarting a task.  This example uses a hardware signal to control when the counter pulse restarts or retriggers.  If you do not have a hardware signal you can use a digital line to generate one.

Alternatively you can set up the analog input to be continuous, and setup a finite pulse train with your counter. You can then use software timing to start and start and stop the counter task repeatedly. The analog task only needs to be started once. Use the DAQmx Timing function to specify the counter as your clock for your analog task. 

Please test the above example to see if it suits your application. This should help to address the timeout problem.  Specifying a continuous AI task, a sufficient timeout period, and sufficient number of samples to acquire for the read (-1 for 'do not timeout' and 'read all available samples') may help when working with this example.

Hope this helps,

Jennifer O
Applications Engineer
National Instruments

0 Kudos
Message 2 of 2
(3,176 Views)