Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

daqmx synchronized analog and digital inputs using buffers

Hi there,

 

I am trying to synchronize the acquisition of analog and digital (single bit) input samples (using an external trigger) from a PXI6122 S-series and DAQmx in LV 8.2.

 

For synchronizing the starting of the tasks, I have used the method in the examples, i.e. use the ai/Sampleclock as the Clock Source of the digital Task and start the digital Task first.

 

However, unlike the example, I am using ring buffers for storing the last N samples of each task (see attached graphic).  I want to do this for my application, as the tasks should be set running, and another VI should read the last N samples of each channel (regardless of whether some of the samples have been read before or samples are lost).

 

My question is how to make sure that the same set of samples is read from both analog and digital Task buffers (this is of course trivial in the example, as they use modal calls with a fixed number of samples, so the two tasks only have to start on the same trigger edge).

 

I have put the two DAQmx Read's side-by-side in the same sequence frame, but this does not guarantee that both buffers are read within one trigger cycle (I am using a 2 kHz trigger)...

 

Is it possible to suspend the Tasks before reading the buffers, and then resume? I do not mind if some samples are lost during the readout.

(I had a look at the DAQmx Control Task function to see if this is appropriate, but sadly I did not understand how it might be used for this...)

 

Regards, MT

 

0 Kudos
Message 1 of 2
(2,924 Views)

 

I think you could probably use the kind of scheme I've used before.  The essence of it is to be able to pause and resume sampling at will to help make sure you keep your lossy data sync'ed in time.  

 

The way I've typically done it is to generate a pulse train with a counter which is then used as the sample clock for both tasks.  The AI and DI tasks are configured as continuous, but in a sneaky way behind their backs, I make sure that the sample clock signal won't be similarly continuous.   With pulse trains, all you'd have to do is stop the pulse train, perform the two reads of recent AI and DI data, then restart the pulse train again.

 

Note that this method will help guarantee sync, but may add a very little bit of "transport delay" to your data.  It sounded like you could live with this.

 

Another approach might be to configure the tasks to be pause-triggered by a digital signal you can control.  I haven't personally ever done hw-timed DI on an S-series board though, so I'm not quite as certain that this method will work with your daq board.

 

-Kevin P

ALERT! LabVIEW's subscription-only policy came to an end (finally!). Unfortunately, pricing favors the captured and committed over new adopters -- so tread carefully.
0 Kudos
Message 2 of 2
(2,900 Views)