Hello,
I could use some advice troubleshooting an issue where the minimum readings of the ADCs on the Arduino Due are greater than 0. In other words, using this code:
analogReadResolution(12);
value = analogRead(0);
For example - the value is always between 20 and 4095. Here's a bit more background about the issue. I just received 200 circuit boards back from the PCB company. 38 of those PCBs have issues with the ADCs not reaching "0". But even those 38 vary in their low-end readings. 20 is the worst case. Here's a table that shows test readings:
PCB2# An0 Min An1 Min An2 Min An3 Min An4 Min An5 Min Average
16 0 0 0 0 1 0 0.17
17 0 0 0 0 1 0 0.17
20 0 0 0 1 0 0 0.17
22 0 0 0 0 1 0 0.17
34 0 0 0 1 1 0 0.33
10 0 0 1 0 2 0 0.50
19 0 0 0 2 1 1 0.67
28 1 0 1 1 0 1 0.67
23 1 1 0 0 2 1 0.83
13 1 0 1 1 1 2 1.00
24 1 0 1 1 2 1 1.00
25 1 1 2 0 1 1 1.00
31 1 1 1 2 1 2 1.33
3 2 2 2 3 2 2 2.17
15 2 3 2 3 2 3 2.50
12 1 2 3 4 4 4 3.00
6 5 5 5 5 5 5 5.00
27 4 6 6 6 6 6 5.67
14 6 6 7 7 7 6 6.50
32 6 7 6 8 8 7 7.00
8 6 9 7 6 7 8 7.17
11 9 7 9 8 7 7 7.83
18 8 7 8 8 7 9 7.83
26 9 8 8 8 7 7 7.83
33 8 8 9 8 8 8 8.17
38 8 9 8 9 9 7 8.33
1 5 9 10 10 7 10 8.50
5 10 8 9 10 10 9 9.33
29 7 8 8 8 19 8 9.67
4 11 10 11 11 11 11 10.83
30 12 12 10 12 12 12 11.67
36 13 12 13 13 13 13 12.83
2 13 14 13 13 13 13 13.17
7 16 16 15 15 15 15 15.33
37 15 16 16 17 12 16 15.33
9 18 18 19 19 19 18 18.50
35 19 18 19 20 19 20 19.17
21 20 20 22 22 22 22 21.33
For the ADC inputs above with minimum values greater than ~4, connecting the ADC input pin directly to ground still will not yield a 0 ADC result. The only way to get a 0 value is to input a slightly negative voltage.
It's worth pointing out that the inputs on any one PCB tend to have the same lower-bound for all of the analog inputs. To me, this doesn't appear to be an issue with the code, since a code problem would normally affect all of the modules, not just 38 of them. If it were an obvious PCB design flaw, again I would expect it to affect all of the modules. Could the Arduino Dues have been damaged during soldering to the PCB? Or, maybe this is some issue with the reference voltage?
I've attached the schematic for the PCB board having trouble. Thanks for any advice you might have.
Here's the test code:
int analog0 = 10;
int prevAnalog0 = 10;
int analog1 = 10;
int prevAnalog1 = 10;
int analog2 = 10;
int prevAnalog2 = 10;
int analog3 = 10;
int prevAnalog3 = 10;
int analog4 = 10;
int prevAnalog4 = 10;
int analog5 = 10;
int prevAnalog5 = 10;
int digital22 = -1;
int prevDigital22 = -1;
int dacVal = 0;
long previousStamp = 0;
unsigned long currentStamp = 0;
void setup()
{
// Set the Due's analog read resolution to 12 bits. It defaults to 10.
analogReadResolution(12);
analogWrite(DAC1,dacVal);
previousStamp = millis();
pinMode(22,INPUT);
Serial.begin(9600);
while (! Serial);
Serial.println("Equation Composer I/O Test");
Serial.println("");
}
void loop()
{
currentStamp = millis();
if (currentStamp - previousStamp > 2000)
{
previousStamp = currentStamp;
if (dacVal == 0)
dacVal = 255;
else
dacVal = 0;
analogWrite(DAC1,dacVal);
}
analog0 = analogRead(0);
analog1 = analogRead(1);
analog2 = analogRead(2);
analog3 = analogRead(3);
analog4 = analogRead(4);
analog5 = analogRead(5);
digital22 = digitalRead(22);
// if(analog0 != prevAnalog0)
if (1)
{
prevAnalog0 = analog0;
Serial.print("An 0: ");
Serial.println(analog0);
}
// if(analog1 != prevAnalog1)
if (1)
{
prevAnalog1 = analog1;
Serial.print(" An 1: ");
Serial.println(analog1);
}
// if(analog2 != prevAnalog2)
if (1)
{
prevAnalog2 = analog2;
Serial.print(" An 2: ");
Serial.println(analog2);
}
// if(analog3 != prevAnalog3)
if (1)
{
prevAnalog3 = analog3;
Serial.print(" An 3: ");
Serial.println(analog3);
}
// if(analog4 != prevAnalog4)
if (1)
{
prevAnalog4 = analog4;
Serial.print(" An 4: ");
Serial.println(analog4);
}
// if(analog5 != prevAnalog5)
if (1)
{
prevAnalog5 = analog5;
Serial.print(" An 5: ");
Serial.println(analog5);
}
if(digital22 != prevDigital22)
{
prevDigital22 = digital22;
Serial.print(" Dig22: ");
Serial.println(digital22);
}
}