Go Down

Topic: Arduino Due: Minimum reading of "20" on analog inputs on some PCBs (Read 5389 times) previous topic - next topic


I have personal experience of this, because the SAM3X chip is also used in the Duet controller board for the Ormerod 3D printer, which I contribute towards firmware for. The SAM3X chip unfortunately has horrendous ADC gain and offset error tolerances. These errors can be up to about 64LSB in 12-bit mode according to the datasheet, far worse than the atmega series processors used on other Arduinos.

To calibrate the ADC you need to have 2 known voltages available. One should be close to but slightly above ground, the other should be close to but slightly below the analog reference. You can provide these voltages using a 3-resistor voltage divider. It's no use calibrating at ground and at Vref, because the linear range of some of these chips doesn't quite extend that far.
Formal verification of safety-critical software, software development, and electronic design and prototyping. See http://www.eschertech.com. Please do not ask for unpaid help via PM, use the forum.


Here a quote from STM32F103 data sheet:
The ADC has an built-in self calibration mode. Calibration significantly reduces accuracy
errors due to internal capacitor bank variations. During calibration, an error-correction code
(digital word) is calculated for each capacitor, and during all subsequent conversions, the
error contribution of each capacitor is removed using this code.
Analog-to-digital converter (ADC)
Calibration is started by setting the CAL bit in the ADC_CR2 register. Once calibration is
over, the CAL bit is reset by hardware and normal conversion can be performed. It is
recommended to calibrate the ADC once at power-on. The calibration codes are stored in
the ADC_DR as soon as the calibration phase ends.
1 It is recommended to perform a calibration after each power-up.
2 Before starting a calibration the ADC must have been in power-off state (ADON bit = '0') for
at least two ADC clock cycles.

Looks like Atmel has not implemented this nice feature in its uCPU. So, external circuitry, if its just 3 resistors would be necessary, and than some code to measure at start-up time and subtract this offset later on. Things may get complicated when gain and differential mode in use. 

Go Up