05-07-2012 04:58 AM
Hi,
I´m currently trying to read a voltage on my ni6008-usb.
The expected voltage ranges from 0V to 3V. But with the appended code (derived from the example "Acq-Int Clk") I always read a voltage with an offset of about -1.4V.
100 values should be aquired so that the arithmetic mean corresponds to the voltage.
Has anyone an idea what I´m doing wrong?
Thanks in advance
Alex
/* DAQmx create input and output task */
DAQmxCreateTask ("", &vlk0790HandleI);
/* Config input channel */
DAQmxCreateAIVoltageChan ( vlk0790HandleI,
"Dev1/ai0",
"",
DAQmx_Val_Cfg_Default,
0.0,
3.0,
DAQmx_Val_Volts,
NULL );
DAQmxCfgSampClkTiming ( vlk0790HandleI,
"",
10000,
DAQmx_Val_Rising,
DAQmx_Val_FiniteSamps,
100);
/* DAQmx start code */
DAQmxStartTask (vlk0790HandleI);
/* DAQmx read code */
DAQmxReadAnalogF64 ( vlk0790HandleI,
100,
10.0,
DAQmx_Val_GroupByChannel,
fData,
100,
&iValue,
NULL );
Solved! Go to Solution.
05-10-2012 02:47 AM
Hi,
Pleas choose a diferent Max and Min Value and retry, to check (-+10V) (is the Voltage displayed -1.4V when having +0V to +3V?)
There is no Arithmetic mean beeing calculated here, you will have to add all Array elements and divide the by the number of elements in the arry, on your own.
With a Sample Rate of 10kHz and 100 Samples to fecht you will have to collect the samples every 10ms, that should be OK even for Win machines.
You might want to check with a other DMM devise if the Voltage measured realy is what you expect and not -1.4V. Usually it should not differ, and maybe there is an electrical problem.
05-10-2012 03:38 AM
Hi,
thanks for the reply.
I tried a lot of combinations for Min/Max (valid ones and stuff like Max<Min). It had a little impact indeed. At Min=-0.1 and Max=0.1 the offset was slightly smaller. In the meantime I changed to acquiring a single sample with "DAQmxReadAnalogScalarF64". So the arithmetic mean calculation (not shown in 1st post) is dispensable.
Example:
0.147V measured with multimeter
=>-1.249V measured by software
The offset is constant so I can calculate the correct voltage. But this solution is anything but satisfying.
For reasons of code readability I´m currently using this approach:
DAQmxCreateAIVoltageChan ( vlk0790HandleI,
"Dev1/ai0",
"",
DAQmx_Val_Cfg_Default,
0.0,
3.0,
DAQmx_Val_Volts,
"");
DAQmxStartTask (vlk0790HandleI);
DAQmxReadAnalogScalarF64 ( vlk0790HandleI,
10.0f,
&fValue,
0U);
NI-DAQmx Testpanel displays the correct voltage, so the hardware is working...
What am I doing wrong?
Regards
Alex
05-14-2012 07:32 AM
hi alex,
I think you do nothing wrong. The offset can result from the input circuit design of the 6008.
Explanation of the Analog Input Circuitry on the 6008/6009
USB-6008/6009 Analog Input Reads Approximately -1.4V Offset with RSE Connections
-Michael F.
05-14-2012 07:51 AM
Hi Michael,
that explains a lot, thank you. At least I know the reason for the strange behaviour now.
Unfortunately I don´t see an option to configure the channel as single ended...seems like I have to accept it.
Nevertheless, thanks for the links!
Regards
Alex