Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Synchronized Analogue Output and Input using a PCI 6221

Dear all,
 
I am trying to get my PCI-6221 (and BNC-2110 breakout box) to synchronise an analogue input with an analogue output.  The output is a simple sine wave running at a low frequency (1122Hz).  I want to sample repeated chunks of 4096 samples of data at 32 times that frequency (35904Hz).  These need to be sampled starting at a fixed time in relation to the sine wave output each time. 
 
I have tried using the Labview 7.1 example DAQ Multifunction Multi-Function-Synch-AI-AO.vi. to synchronise my ouput and inputs using a digital trigger from the AI start trigger but I cannot get the output and input to synchronise at all.
 
Ideally I wanted to use the card's onboard memory to output a continuous sine wave & then keep triggering new finite acquisitions off some particular part of the wave (is there a pulse each time the onboard memory starts back at the beginning of the buffer again perhaps?).  I don't mind if there is a phase delay as I can take account of this.  But I just can't get the acquisition to start at a consistent time in relation to my sinewave output.  Over time the acquisition slips around.
 
I have attached my code.  To test the setup I connect my analogue output to my analogue input.  I want to see the acquired data stay fixed in relation to the output data at each cycle.  But it dances around all of the place!
 
I really don't understand what is available for me to trigger off so any help would be appreciated.
Cheers,
Bob
 
  
 
0 Kudos
Message 1 of 6
(3,211 Views)

Hi there Bob,

Thanks for posting on the NI forums.

I have taken a quick look at your code and I think I can see part of the problem here. At the minute your AI and AO tasks are running on seperate clocks, but starting on the same trigger. What could be done is to use the AI clock to time both the AI and AO tasks. I will see what I can do about mod'ing your code slightly to add in this functionality.

I hope this helps,

Rob

National Instruments | Northern California
Message 2 of 6
(3,202 Views)

Hi again Bob,

I have generated a snippet of example code based on your VI.

By sychronising the AI and AO operations to the same clock (the AI sample clock) we have a situation where for each new voltage generated (datapoint on your waveform) the AI takes a measurement. By forcing the task to be more precisely 'in-step' with one another, we can use a continuous AI task and choose to return chunks of data from the AI buffer that equate to exactly one cycle of your waveform (no repeated triggering needed!).

In order to ensure the tasks start off at the same time, we use the ai start trigger to start the AO task. This means the AI task will start, then the AO will begin generating the sine wave. We have a slight time delay here which results in a slight phase offset, but this offset is constant thoughout each acquisition insance.

I hope this helps!

Rob

National Instruments | Northern California
Message 3 of 6
(3,183 Views)
Hi Rob,
 
Thanks for the excellent response.  I'm currently trying to integrate your suggestions into my full program (I only posted the relevant Input/output bits) but it isn't working in the same way with all my code.  I'll post an update as soon as I get somewhere (or don't )....  It's taking me quite a while!
 
Cheers,
Bob
 
 
0 Kudos
Message 4 of 6
(3,168 Views)

Hi Rob,

Horray for the power of a windows reboot!  It seems to be working well now.  I'm using it as the basis for a software lock-in amplifier & so far I have only tested by plugging the output straight back into the input terminal.  I'll have to see what happens when I actually start sending the signal through my devices and amplifiers!

Thanks for all your help!

Bob  Smiley Very Happy

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

Hi Bob,

You've gotta love it when a plan comes together! Smiley Very Happy

I suspect when you pass the signal through your external circuitry you'll most likely get a larger phase difference, but if you need the displayed waveforms to be aligned, you could probably 'nudge' the phase of the graphed data by acquiring 1 sample more (or less) for one of the while loop's iterations. Not a particularly pretty solution, but the waveform's would 'look right'! 🙂

Let us know how you get on. I'll be glad to help again should you run into issues.

Cheers,

Rob

National Instruments | Northern California
0 Kudos
Message 6 of 6
(3,156 Views)