Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Error when reading at low sampling rate

Hi all,

 

I'm running into a strange error.  I have an application where I measure the impedance spectra of circuits.  I use a PCI-6259 to generate some digital control signals, an analog output waveform (sine waves at different frequencies and amplitudes), and analog input to capture the resulting data.  The analog ouput is buffered by external circuitry (op-amps etc) that perform the grunt work of the measurement.  The system works pretty well most of the time, but gives about a 10-20% error when testing 1000 Hz impedances and above.

 

I went about investigating the error, and used an oscilloscope to measure the analog output and input.  Both are perfectly correct.  However, the input, when I look at it within my program (Measurement Studio) is incorrect.  The voltages are low by ~25%.  I'm only scanning one channel, so I don't think ghosting is at play. 

 

For timing, I use the analog input sample clock to control the analog output.  I had previously set both to 100 kHz, and noted 20% errors.  When I move to 1 MHz, the error drops to 10% (the read data is off by less). 

 

Does any one have any ideas what might be going on? 

 

The output impedance of my source is <1 Ohm.  And, as I noted above, the voltage is correct when measured in the SCB-68 with an oscilloscope, just not read by the software correctly or converted by the D/A correctly.

 

Thanks!

John

0 Kudos
Message 1 of 6
(3,251 Views)

Hi John,

 

From the way you describe the circuit, I don't see any reason for 25% voltage drops from impedance differences etc.  Assuming the oscilloscope is around 1MOhm or so impedance (really just high impedance over the 1Ohm source), you should be seeing the same results from the input impedance of the 6259.  Can you try reading the analog input through the Test Panel in Measurement & Automation Explorer (MAX)?  Perhaps there is something with the coding that modifies the resulting voltages?  To access the Test Panel, right-click on the device under NI-DAQmx devices. Also, has the card been calibrated recently or is it within the calibration period?  I don't see how this would equate such a large error but it could attribute to the results. 

 

Thank you,

Simran K
National Instruments
Applications Engineer
0 Kudos
Message 2 of 6
(3,226 Views)

Thanks for the reply.  I tested the input with Measurement & Automation and it looks okay.  In the code, I'm looking at the data before any processing, and it's there where I note the 25% drop in amplitude.  Here's an idea of what the C# Measurement Studio code looks like.  Hopefully someone can see what I'm doing wrong!

 

IMPEDANCE_SAMPLING_RATE = 100000;

impedanceRecord = new Task("Impedance Task");

impedanceRecord.AIChannels.CreateVoltageChannel("Dev3/ai2", "", AITerminalConfiguration.Nrse, -5.0, 5.0, AIVoltageUnits.Volts);impedanceRecord.Control(

TaskAction.Verify);

impedanceRecord.Timing.ConfigureSampleClock("", IMPEDANCE_SAMPLING_RATE, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples);impedanceReader =

new AnalogSingleChannelReader(impedanceRecord.Stream);

impedanceRecord.Timing.ReferenceClockSource = "OnboardClock";

 

stimPulseTask = new Task("stimPulseTask_impedance");

stimPulseTask.AOChannels.CreateVoltageChannel("Dev4/ao2", "", -5.0, 5.0, AOVoltageUnits.Volts);

stimPulseWriter = new AnalogSingleChannelWriter(stimPulseTask.Stream);

stimPulseTask.Timing.ConfigureSampleClock("/Dev3/ai/SampleClock", IMPEDANCE_SAMPLING_RATE, SampleClockActiveEdge.Rising, SampleQuantityMode.FiniteSamples);stimPulseTask.Triggers.StartTrigger.ConfigureDigitalEdgeTrigger("/Dev3/ai/StartTrigger", DigitalEdgeStartTriggerEdge.Rising);

stimPulseTask.Timing.ReferenceClockSource = impedanceRecord.Timing.ReferenceClockSource;

stimPulseTask.Timing.ReferenceClockRate = impedanceRecord.Timing.ReferenceClockRate;

 

SineSignal testWave = new SineSignal(1000.0, 0.1); //Generate a 100 mV sine wave at 1000 Hz

 double[] testWaveValues = testWave.Generate(IMPEDANCE_SAMPLING_RATE, (long)Math.Round(0.001 * (double)IMPEDANCE_SAMPLING_RATE));

int size = Convert.ToInt32(0.001* IMPEDANCE_SAMPLING_RATE);

double[] analogPulse = new double[size]; for (int i = 0; i < size; ++i)

    analogPulse[i] = testWaveValues[i];

impedanceRecord.Timing.SamplesPerChannel = (long)(100 * size);stimPulseTask.Timing.SamplesPerChannel = (

long)(100 * size); //Do numperiods cycles of sine wave

 

stimPulseWriter.WriteMultiSample(true, analogPulse);impedanceReader.BeginReadMultiSample(100 * size, analogInCallback_impedance, (Object)stateData);

stimPulseTask.WaitUntilDone();

impedanceRecord.WaitUntilDone();

stimPulseTask.Stop();

impedanceRecord.Stop();

  }

 

private void analogInCallback_impedance(IAsyncResult ar)

{ double[] data = impedanceReader.EndReadMultiSample(ar); }

0 Kudos
Message 3 of 6
(3,215 Views)

Hi jrolston,


Thats great that you are able to read the correct voltage in Measurement & Automation Explorer (MAX)!  This would indicate that the hardware is ok, so we can focus on the code now.  From looking at your code, I noticed that you are generating the sine wave from Dev4.  May I ask what device you are generating the stimulus from? 


I am not sure how much experience you have programming with NI-DAQmx in a .NET environment, but the examples are a great resource.  The locations of these examples will depend on your version of Visual Studio as well as your Operating System (see this KB). 


After troubleshooting in MAX, I usually turn to these examples.  They provide a great foundation which you can build your application on.  You can also do the same troubleshooting that you did in MAX, making calls to the DAQmx driver from the .NET environment.   

Rod T.
0 Kudos
Message 4 of 6
(3,181 Views)
Thanks, Rod T.  I generate the stimulus from Dev4, and have tried recording on Dev4 or Dev3, with the same error in measurement.
0 Kudos
Message 5 of 6
(3,179 Views)

Hi jrolston,


Thanks for the reply, and for clarifying which devices you are using.  I assume that both Dev3 and Dev4 are PCI-6259s.  It would be helpful if you could take the same troubleshooting measures that you took in MAX, in the .NET environment.  Try running the simple ContAcqVoltageSamples_IntClk example to measure the voltage.  You can generate the stimulus using either another example, or from the Analog Output tab in the Test Panels.  From there, it would be helpful to start commenting out code from your original program.  Try to isolate where the problem could be in your existing code.  But first, verify that you can take proper measurements in the .NET environment using the example.

Rod T.
0 Kudos
Message 6 of 6
(3,146 Views)