ADC accuracy

Play with it! Please tell us which board you're using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tlerner
 
Posts: 3
Joined: Thu Mar 16, 2017 9:44 pm

ADC accuracy

Post by tlerner »

Hello,

I would like to use the teensy 3.5 for monitoring voltage of battery cells and recording data. I would be using a voltage divider properly to make sure each cell is within the 3.3V range. I am aware of the 13 bit resolution of the analog inputs but what I would like to know is how accurate this is?

Thanks in advance for your help.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADC accuracy

Post by adafruit_support_mike »

Generally speaking, a decent ADC is as accurate as its voltage reference.

The properties of an ADC itself are defined in terms of monotonicity (each output value corresponds to an input voltage higher than the previous one), linearity (if output C corresponds to a voltage V1, output NxC should correspond to voltage NxV1), and uniformity (the difference in input voltage between output C and output C+1 should be about the same for all C).

Assuming all those are suitably well behaved, the output values are defined as fractions of the ADC's reference voltage. If the reference is accurate and stable, the output values should be correspondingly accurate and stable.

Creating a really good voltage reference is a specialized job though. Most voltage regulators are only accurate to between 1% and 5% of their nominal value, and their job is to keep their output within a reasonable distance of the nominal voltage across a wide range of operating currents. Translating a 1% error to a 13-bit ADC means you can expect error of +/-82 LSB in any reading.

Our LM4040 voltage references are designed for 0.1% accuracy, or +/-8 LSB on a 13-bit ADC:

https://www.adafruit.com/products/2200

User avatar
tlerner
 
Posts: 3
Joined: Thu Mar 16, 2017 9:44 pm

Re: ADC accuracy

Post by tlerner »

I have never heard of LSB before. How can I calculate this/use this to calculate something else?

Thank you for your response. It was quite informative.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADC accuracy

Post by adafruit_support_mike »

Sorry.. 'LSB' is an acronym for 'Least Significant Bit'.

When used with ADCs, it means the smallest possible change in the output value.. from N to N+1 or N-1. That corresponds to an input voltage of 1/2^B times the reference voltage, where B is the number of bits in the ADC's ouput.

For a 13-bit ADC working from a 2.048v reference, 1 LSB would correspond to a voltage difference of 250uV at the input.

For the same ADC working from a 3.3v reference, 1 LSB would correspond to a voltage difference of about 403uV at the input.

Assuming the 3.3v reference was stable to within 1% of its nominal value, the expected error would be +/-33mV. Dividing that by 403uV gives us a total of about 82 LSB of error.

82 is roughly 2^6, which means the 6 least sigificant bits of the ADC's 13-bit output would have to be considered error. Only the 7 most significant bits (MSB) could be taken as accurate to within the limits of the system.

A 0.1% reference would be ten times more stable, and 10 is roughly 2^3. That means you could treat the 10 most significant bits of the ADCs output as an accurate measurement of the input, but would still have to consider the 3 least significant bits little more than a measurement of the reference error.

User avatar
tlerner
 
Posts: 3
Joined: Thu Mar 16, 2017 9:44 pm

Re: ADC accuracy

Post by tlerner »

I have been using a large number of the analog pins and many of them are working quite well. Thank you for your help up to this point.

There are some pins that are reading as very close to 0V (<.04V) even when there is voltage measured at the pin. (I measured the pins directly on the teensy with a multi-meter). When all of the pins are floating, these show a much lower voltage than the other analog pins.

Am I required to use a specific command to declare these pins as input pins?

Some of the pins that are not working correctly are pins A11, 31 (A12), and 32 (A13) but there are many more.

User avatar
adafruit_support_mike
 
Posts: 67446
Joined: Thu Feb 11, 2010 2:51 pm

Re: ADC accuracy

Post by adafruit_support_mike »

The voltage of a floating pin doens't have any useful meaning. It will be controlled by parasitic current in the chip or across the PCB.

If you're looking for information about the Teensy's ADC pins specifically, your best bet would be to check the PJRC forums:

https://forum.pjrc.com/

That's the official home of the Teensy, and Paul knows the hardware better than anyone.

User avatar
paulstoffregen
 
Posts: 444
Joined: Sun Oct 11, 2009 11:23 am

Re: ADC accuracy

Post by paulstoffregen »

Am I required to use a specific command to declare these pins as input pins?
On Teensy 3.x the pins have a special low power disable mode where all the pin's digital circuits are turned off. This is ideal for analog signals. All the pins start in this mode when the chip boots up, so if you haven't configured the pin it should be fine.

But if you have previously used pinMode or done other stuff with the pin, you can put it back into that special all-digital-disabled mode with pinMode(pin, INPUT_DISABLE);

Locked
Please be positive and constructive with your questions and comments.

Return to “Circuit Playground Classic, Circuit Playground Express, Circuit Playground Bluefruit”