LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

calibrate values from 12 bit ADC

Solved!
Go to solution

I want to understand how to convert integer values from a 12 bit ADC to voltages. I am using a NI USB-6008 in differential input mode. It has 12 bit resolution in differential mode.  I am using a simple VI to collect 100 samples of the differential voltage at analog input 0 (AI0).  When I connect AI0+ and AI0-, the voltage between them should be zero.  When I plot the numbers returned by the data acq routine, I see values of -32768 most of the time plus a few jumps to +32752.  When I convert the numbers from I16 format to U16 format. I see values ot +32768 mostly, plus a few jumps to +32752.See attached screen shot of front panel and block diagram.

 

It looks like Labview adds 4 zeros to the right hand end of the 12 bit binary number returned by the ADC.  Is there a simple way to make the ADC return numbers like 0, +1, -1 when the voltage is aproximately zero?  I could do the following:

1. Convert the values returned by the ADC from I16 to U16.

2. Divide by 16.

3. Subtract 2048. 

I am teaching students about the basics of analog to digital conversion, and I don't want to have to explain this clumsy scheme if I can avoid it.

 

Thank you.

 

Bill

Download All
0 Kudos
Message 1 of 4
(4,288 Views)
Solution
Accepted by topic author WCR

Hi Bill,

 

It sounds like you have discovered the two's complement representation that LabVIEW uses to represent signed integers. The Unscaled data is pulled directly off of the hardware registers, and are represented as they are on the device. 

 

If you want to convert the values, you can convert it as you have outlined. You can also take the opportunity to explain two's complement to them if that is within the scope of your course, or you can just put the arithmetic in a sub VI if you want to hide it. 

 

If you look at the unsigned values, you could also explain to them that that is where in the voltage range the value is. 

 

For example, 16 bits unsigned gives a range of 0-65535. If the voltage range you have selected is -10 to +10V. If you have 0V, then you should expect a reading around 32768.

 

Here is the wikipedia article on two's complement for reference: http://en.wikipedia.org/wiki/Two's_complement

Trevor B.
PSE
National Instruments
Message 2 of 4
(4,213 Views)

Thank you Trevor. You are right.  When I request U16 results, instead of I16, everything is simple, and there's no need to discuss 2's complement.  I find it interesting that when I use a 12 bit ADC (NI USB-6008), the unscaled numbers are multiples of 16 from 0 to 65520*, rather than integers from 0 to 4095 as I had expected.  You could say Labview puts the 12 bit number into the most significant 12 bits of the 16 bit space, leaving four zeroes at the LSB end. My old Data Translation 12 bit board and software returned 0 to 4095.

 

When I compare the unscaled (U16) numbers and the scaled (DBL) results for different channels of each ADC device, I see that each channel seems to use slightly different calibration coefficients.  I never calibrated the device, that I can recall.  Do the NI USB-9215A and the NI USB-6008/6009 devices come pre-programmed at the factory with unique ADC calibration coefficients? And does MAX read those from a ROM on the device when it is attached to the computer?

 

Thank you.

 

Bill

 

*For reasons I don't understand, the unscaled U16 values returned for saturating inputs on my NI USB-6008 are 1 and 65521, rather than 0 and 65520. But other unscaled values are exact integer multiples of 16.

 

0 Kudos
Message 3 of 4
(4,179 Views)

Hi Bill,

 

You can actually use a DAQmx Channel Property node and selecting the AI.DevScalingCoeff property by clicking on the property and selecting Analog Input»General Properties»Advanced»Device Scaling Coefficients.

 

You care also correct that each channel comes with its own calibration constants. As for the changed values when the device goes out of range, I suspect that the LSB is set to 1 to indicate the device has gone out of range.

 

Trevor B.
PSE
National Instruments
Message 4 of 4
(4,164 Views)