Multifunction DAQ

Showing results for 
Search instead for 
Did you mean: 

USB 6211

I am working with the USB DAQ 6211 and when performing a simple test to measure with two AI channels (Analog Input in differential mode) a 0 16 kHz CHIRP signal with a peak-to-peak value of +/- 4 Volts supplied by channel Analog Output (AO) I noticed considerable voltage differences between the two AI channels. Someone could tell me the reason and what to do to resolve this difference.

Thanks in advance for any suggestions.
Carlos Augusto
0 Kudos
Message 1 of 12


there are two different chirp signal sources and you use 4 pins for acquisition? If yes, make sure, that both AI are simultaneously in differential mode (consult the pinout). Also monitor the two chirp signals seperately and not at the same time, in order to locate the issue.

Also make sure, that your acquisition rate is at least 32 kHz in order to avoid Aliasing problems. Try to measure a constant frequency 16kHz sine. Does it appear normal in the MAX or Labview? Repat the same with a very low frequency.

If you are reading a lower voltage than the +-4 V peak-to-peak, maybe some part of the data acquisition path acts a low filter, reducing the voltage at higher frequencies.

0 Kudos
Message 2 of 12
0 Kudos
Message 3 of 12

You haven't given us a lot of detail to go on regarding *precisely how* your results differ from what you expect.  I'll take a somewhat educated guess though.


I suspect wrong *expectations*.   On your device, there's one shared A/D converter.  When there are multiple channels in a task, they have to take turns having access to it through a process known as multiplexing.  As a result, two channels wired to the same signal will *sample* that signal at slightly different times.  A highly dynamic signal like a chirp will likely have *actually* changed its value during those microseconds.  One shouldn't *expect* the two channels to show the same value.



-Kevin P

Present job ending soon. Need DAQ expertise? PM with serious opportunities.
Message 4 of 12
Show! Great tip! But I'm still in trouble! Now, I am not using a CHIRP signal, but according to the tip provided, I am only using a 16 kHz sine wave. However, in the first analog input channel, when shifting a sample, I can read 83% of the 125000 samples correctly and, in the second analog input channel, when shifting 8 samples, I can read 97% of the 125000 samples correctly.
I imagined that all the problems had been solved and went to test another sine signal, now with 15 kHz. To my sadness, the shifts ratio previously used was no longer adequate. The result was the following: In the first analog channel, there were 84% of hits related to the 125000 samples and in the second analog channel there were 16% hits.
Does anyone have any other tips?
Download All
0 Kudos
Message 5 of 12

Need more info. What are "hits"?   How do you define the % of samples that were read "correctly"?


Need to see code.  Need to have a more complete description of what you're trying to do with the code, the data, and the analysis.  Screencaps of a spreadsheet aren't enough.


Note: it is possible to query (and, to some extent, control) the multiplexing rate.  That can tell you the amount of time between A/D conversions for consecutive channels in the AI task.  It seems quite odd to me that the 2 AI channels appear to be shifted by multiple *samples* relative to one another.  Multiplexing only accounts for a *fraction* of a single sample.


I'm not sure what your long-term goal is, but I suspect from your data that you haven't taken proper measures to get your AO and AI tasks in sync.  You can find more info by searching those terms, and as a headstart here's an old thread I remember being in.



-Kevin P

Present job ending soon. Need DAQ expertise? PM with serious opportunities.
0 Kudos
Message 6 of 12

So, there was advice given that you need to sample at at least 32 kS/s to capture the frequency content of a 16 kHz signal.  This is true, but this will not help the poster.  The OP seems to care about accurately characterizing the amplitude of a 16 kHz signal.  If you imagine a 16 kHz signal captured at 32 kS/s, you have two samples per signal period.  Your sample clock is in no way phase locked to the incoming signal, so you could be sampling at the two zero points or the crest and trough of the sine, or anywhere in between.  In fact, your sampling phase is guaranteed to drift over time since your sample rate and signal frequency are not phase locked, so your result will be different every time you run.  Additionally, as Kevin correctly pointed out, there is a multiplexer adding additional relative skew between the two channels.  This will manifest as a large amplitude difference between the channels since the convert clock period (probably in the 10 us ballpark) represents a huge portion of the period of a 16 kHz signal (62.5 us).  In other words, if one channel is sampling at phase = 0 deg, the other could be measuring (10/62.5)*360 = 58 deg later!  Not a trivial error.


You can't get around the phase difference between the channels unless you buy a much more expensive simultaneous DAQ card.  You can, however, get a much better amplitude representation of the two channels if you significantly increase your sample rate.  The very general rule for capturing the shape of the waveform is to sample at least 7-10x times faster than your max frequency of interest.  (These numbers are somewhat arbitrary and should not be taken as fact.  YOUR APPLICATION requirements need to determine your actual sample rate.)  That said, as a starting point, these guidelines mean sampling at at least 16 kHz * 7 = 112 kHz.  Your 6211 supports sampling at an aggregate rate of 250 kS/s, so each of your two channels can sample at 125 kHz, which should be enough to give you a much better amplitude representation at 16 kHz.  Again, you'll see a large phase difference between channels at this frequency, but they should rise to roughly similar amplitudes.

Message 7 of 12

Hi! Croohcifer is right, I worry about accurately and synchronously acquiring the amplitude not only of a 16 kHz signal, but of a range of 0 Hz to 16 kHz, the rate chosen according to the specifications of my device (precisely by the general rule to sample at least 7 to 10 times faster than the maximum frequency of interest).


I am in a survey that requires the simultaneous accuracy of two channels and I am evaluating the accuracy of the two. From Kevin's comment about the multiplexer, and now from Croohcifer, there seems to be no way around the phase difference between them. Is this really correct?


Croohcifer said that I would get a much better amplitude representation of the two channels if I significantly increased my sampling rate, but I'm using the maximum, which is 125 kS / s for each channel. And yes, the amplitudes are approaching. However, the frequency and timing of this information is also extremely important to me, which is not happening.


Explaining my code, initially I generate a 16 kHz signal in 1 second generating 125,000 cells to be sampled by both channels. In the previous figures I compare the signal generated and sent to the AO port with the signals read by both AI ports (whose response vector also has 125,000 cells) and it is on these cells that I realized the displacement and where I make the correct percentages. As Kevin asked, the hits are based on the difference between the read signal and the sent signal on the same cell line with an arbitrary 10% tolerance percentage. If they are within this tolerance, this specific reading is considered a hit. If I shift and compare different lines (equivalent to later microseconds), my hit percentage increases in case I try the 16 kHz, but it does not work for 15 kHz, for example.


I am attaching my code to you:


% This is a MATLAB R2009a code.

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% DAQ Configuration

ao = analogoutput('nidaq','Dev2');   % Creates an analogoutput object associated with the NIDAQ USB-6211.
addchannel(ao,0,'Sinal de Saída');   % Allocates the AO0 port of the DAQ (circuit power).
ao.SampleRate = 125000;              % Set SampleRate of the DAQ to ensure that the actual sampling time is compatible with the time programmed in the signal sent to the AO port.
ao.TriggerType = 'HwDigital';
ao.HwDigitalTriggerSource = 'PFI5';

ai = analoginput('nidaq','Dev2');    % Creates an analoginput object associated with the NIDAQ USB-6211.
set(ai,'InputType', 'Differential'); % Set AnalogInput to Differential Mode.
addchannel(ai,[2 4]);                % Allocates, respectively, the DAQ ports AI2 / AI10 and AI4 / AI12.
ai.SampleRate = 125000;              % According to NI-DAQ USB-6211 specifications, the total sampling rate (250 KS / s) of Analog Input ports is divided by the number of ports used.
ai.SamplesPerTrigger = 125000;
ai.TriggerType = 'Immediate';
ai.ExternalTriggerDriveLine = 'PFI5';
ai.SamplesAcquiredFcnCount = 125000;

%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% Data Aquisition

frequency_analysed = 16000;         % 16 kHz 
time_espace = 0.000008:0.000008:1;  % Totalizes 125k time slots in one second.
volts = 4;
signal_excited = volts*sin(2*pi*frequency_analysed*time_espace)'; % Sine w/ 4V

putsample(ao,0)                     % Ensures that AnalogOutput starts at zero
putdata(ao,signal_excited)          % Loads the test signal into the AnalogOutput buffer

start(ao)                           % It is necessary to start the AnalogOutput first so that it waits for the beginning of the AnalogInput

[signal_read,time] = getdata(ai);   % Returns the result.
stop([ai,ao])                       % Terminates AnalogOutput and AnalogInput


Sheet_for_Excel = [signal_excited,signal_read];
0 Kudos
Message 8 of 12

I am in a survey that requires the simultaneous accuracy of two channels and I am evaluating the accuracy of the two. From Kevin's comment about the multiplexer, and now from Croohcifer, there seems to be no way around the phase difference between them. Is this really correct?


Yes, it is really correct.  That is the nature of using any multiplexed acquisition device.  You won't be able to synchronize the channels much more tightly than a few microseconds in hardware, so you have two main options if you can't switch to a simultaneous device.


  1. Characterize the skew between channels (in units of time) and then apply that much time shift to your data after acquiring it.
  2. Measure each channel independently, and use a start trigger to phase align the stimulus AO signal to your AI signal.  In other words, if your circuit is static in behavior over time and you don't expect a change in response if you were to test each channel separately, run two separate bursts.  In the first burst, send the AO signal sync'd with AI0's acquisition and DO NOT acquire on AI1.  Then do the same but only acquiring on AI1, NOT AI0.  In this circumstance, each AI channel will have had the same timing relationship with AO.  They simply won't have been acquired simultaneously.

If you have to acquire simultaneously and achieve lower skew in the hardware layer, you'll need to buy a simultaneous DAQ device. I believe the NI USB-6356 is the cheapest multifunction DAQ board that supports simultaneous sampling, but you might be able to cobble together a slightly cheaper solution with cDAQ modules if you don't need all the digital channels of an MIO device


As a general note, when you use the term accuracy, it's important to define exactly what you mean.  AC or DC amplitude accuracy?  Frequency accuracy?  Phase accuracy?  It would also be helpful to know how accurate you need the measurements to be (i.e., +/- 100 mV, or +/- 10 Hz, or +/- 10 deg, or whatever).  You mentioned "an arbitrary 10% tolerance", but I don't know what that refers to and if that "arbitrary" number is actually what you want in the end.  Thus, it's kind of hard to be more helpful.  I don't really know what you want.

Message 9 of 12

Hi, Croohcifer!
First of all, I would like to reiterate my thanks for the participation of everyone, which has been very significant in analyzing the problem.

In fact, I had already tested the second suggestion outlined in his last note, which refers to measuring each analog input signal independently. In the meantime, I am encountering difficulties with regard to the phase of each spectrum frequency from 0 to 16 kHz, as I realize that I will have to define a specific sampling rate for each frequency, ensuring greater 'accuracy' in each measurement.

In response to the question asked: The term 'accuracy' is based on the amplitude AC (+/- error tolerance = +/- 10%) of the voltage value read by the AIs when compared to that inserted by the AO.

Carlos Augusto

0 Kudos
Message 10 of 12