Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Strange problem with simultaneous analog output / input

Solved!
Go to solution

I'm using a PCI-6221. I have an application that outputs 2 waveforms (finite samples) and simultaneously records 4 channels of analog input. I'm using the AO sample clock as the sample clock for the analog input.

As a test I connected the first AO channel (AO0) to all 4 inputs. What happens when I run the vi is that the first sample on the first channel (AI0) has the value of the last sample that was output on AO0, from the previous generation.

 

Example:

  AI0     AI1     AI2     AI3

-0.369 -0.001 -0.001 -0.001

-0.001  0.062  0.062  0.062

 0.062  0.124  0.124  0.124

 

etc.

 

I figured out that it's an issue with the relative times of AO update and AI sampling.

It must be going: read AI0 / write AO0 / read AI1 / read AI2 / read AI3.

 

I'm using DAQmx Timing (Sample Clock) to specify the AO clock as the sample clock for the AI. I noticed that this has an input terminal called active edge. Aha, I thought - if I set the active edge to negative the AI will always start sampling half a clock cycle after the AO has updated. Wrong. It makes absolutely no difference. Maybe the AO clock signal is a very short pulse?

 

Is there a way to specify the order in which analog outputs and inputs update / sample?

 

0 Kudos
Message 1 of 4
(3,055 Views)
Solution
Accepted by topic author CDancer

Hi CDancer,

 

Changing the analog output voltage isn't instantaneous. It depends on the board's slew rate and the difference from the previous voltage.

 

You're right that the AO sample clock is a very short pulse. As far as I remember, it's on the order of 50 ns.

 

Here are two ways to insert a delay between the AI and AO tasks:

  • Delay the first AI conversion (AI0) with respect to the AI sample clock: use the DAQmx Timing >> More >> AI Convert >> Delay From Sample Clock >> Delay and DelayUnits properties.
  • Delay the first AI sample clock with respect to the AI start trigger: use the DAQmx Trigger >> Start >> More >> Delay and DelayUnits properties.

Brad

---
Brad Keryan
NI R&D
Message 2 of 4
(3,045 Views)

Thanks Brad. Setting the AI conversion delay to 10 microseconds causes all AI values to be about the same on every sample.

 

In reality it would not have been a problem because the device the card is driving is low-pass filtered at about 500Hz, so the steps in the waveform will be smoothed, but I feel better having confirmed the reason for the "strange" behaviour.

 

Chris

 

Message 3 of 4
(3,039 Views)

Thanks to this whole thread; 10 microseconds was the magic value for me as well, and it just ended two days of total hassle getting weird samples at random times.  Whew.

 

 

0 Kudos
Message 4 of 4
(2,879 Views)