Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronized digital output and analogue input

I am trying to write a VI in Labview 7.1 to run data acquisition using an M-series board (PCI-6221)with NI-DAQmx 7.3 and have got rather stuck. The (I guess simple)function that is troubling me is required to do the following:

Analog data acquisition should be started at a user set frequency (typically 10kHz) by the user pressing a button on screen
After a user-defined time, a digital output sends a signal to open a shutter (high=open)
After a further period, the digital signal should change back to low, closing the shutter
The acquisition should stop after a set number of data points are acquired. This may or may not be after the shutter closure

This function is used several times in a for loop, and the signals averaged, so it is important that the timing of this is accurate. I tried a couple of approaches, e.g. using a sequence, with timed delays in between actions, and it sort of worked, however the timing on this was not accurate enough. I have found lots of examples that use synchronization, however I am not sure how to write in the delays necessary.

Can anyone point me in the direction of some examples that might help me or suggest solutions to this problem? Any help would be gratefully received!
Giles
0 Kudos
Message 1 of 2
(2,485 Views)
giles,

I have a suggestion, but I only have time to be brief right now. The key to timing precision is to use the output from one of your DAQ board's Counter/Timers instead of using digital I/O.

1. Outside your main loop, configure a finite AI task and a triggered single pulse Counter task. The trigger signal for the Counter task should be the AI sample clock. You should also define the delay time and pulse time here.

2. When the user presses the button on screen, start the Counter task first and then the AI task.

3. When the AI task finishes collecting all its data, stop it and stop the Counter task as well.

4. On each user button press, steps 2 & 3 will happen with very repeatable relative timing between the AI waveform and the "Shutter open" pulse signal.

5. After the main loop ends, don't forget to clear the AI and Counter tasks!

Hope this helps get you started. There's more info on Counters in the online help, examples, and here at ni.com.

-Kevin P.
CAUTION! New LabVIEW adopters -- it's too late for me, but you *can* save yourself. The new subscription policy for LabVIEW puts NI's hand in your wallet for the rest of your working life. Are you sure you're *that* dedicated to LabVIEW? (Summary of my reasons in this post, part of a voluminous thread of mostly complaints starting here).
0 Kudos
Message 2 of 2
(2,475 Views)