Okay, so strange issue, I'm working on creating cell voltage monitoring which requires for this 12s pack requires 12 ADC samplings. Using the code I found where someone tested the ADC, I'm averaging 10k samples at 16 bit res (yes, I realize deviation can be large, but with what I'm doing accuracy is... not quite as necessary).
So, code setup goes as follows:
Now, all simple enough except the output:
So, the first 6 are accurate, then it seems to go into this ... odd loop that would make me think somehow addresses are wrong. So, then I tried ruling out the ADC giving back bad values by adding:
Which then left me with an actual accurate reading for A11, but then A6 started misbehaving:
Sad to say this is beyond my debugging capability. Any ideas?
So, code setup goes as follows:
Code:
long a1sum, a2sum, a3sum, a4sum, a5sum, a6sum, a7sum, a8sum, a9sum, a10sum, a11sum, a12sum;
n++;
a1sum += analogRead(35);
a2sum += analogRead(34);
a3sum += analogRead(23);
a4sum += analogRead(22);
a5sum += analogRead(21);
a6sum += analogRead(20);
a7sum += analogRead(19);
a8sum += analogRead(18);
a9sum += analogRead(17);
a10sum += analogRead(16);
a11sum += analogRead(15);
a12sum += analogRead(14);
}
long durT = millis() - oldT;
Serial.print((1000.0*n/durT),2);
Serial.print(" A0: "); Serial.print(((1.0*a1sum))/n,2);
Serial.print(" A1: "); Serial.print(((1.0*a2sum))/n,2);
etc...
Now, all simple enough except the output:
Code:
6891.80 A0: 19187.26 A1: 24935.47 A2: 48268.20 A3: 44111.05 A4: 48012.56 A5: 47133.35 A6: 49325.83 A7: -72890.23 A8: -45976.47 A9: 11202.86 A10: -88842.77 A11: -183154.95
6887.05 A0: 19145.72 A1: 24987.55 A2: 48300.83 A3: 44115.11 A4: 48016.87 A5: 47164.73 A6: 49338.12 A7: -26631.12 A8: 1849.90 A9: 59244.38 A10: -43542.94 A11: -171842.68
6891.80 A0: 19267.16 A1: 25081.17 A2: 48303.55 A3: 44111.86 A4: 48013.50 A5: 47143.04 A6: 49331.36 A7: 19618.39 A8: 49657.29 A9: 107269.72 A10: 1757.90 A11: -160487.34
6887.05 A0: 19262.19 A1: 25072.95 A2: 48296.72 A3: 44105.51 A4: 48017.32 A5: 47152.05 A6: 49324.69 A7: 65843.45 A8: 97473.30 A9: 155287.98 A10: 47048.69 A11: -149139.74
6891.80 A0: 19279.68 A1: 25120.30 A2: 48285.80 A3: 44094.17 A4: 47984.47 A5: 47164.89 A6: 49334.77 A7: 112086.17 A8: 145291.96 A9: 203299.95 A10: 92337.32 A11: -137830.00
6887.05 A0: 19297.13 A1: 24994.40 A2: 48272.36 A3: 44118.03 A4: 48013.43 A5: 47148.95 A6: 49333.12 A7: 158349.18 A8: 193128.40 A9: -178148.28 A10: 137637.22 A11: -126497.
So, the first 6 are accurate, then it seems to go into this ... odd loop that would make me think somehow addresses are wrong. So, then I tried ruling out the ADC giving back bad values by adding:
Code:
Serial.print(" "); Serial.print(a12sum/n); Serial.print( " " );
Which then left me with an actual accurate reading for A11, but then A6 started misbehaving:
Code:
6887.05 A0: 22161.88 A1: 28990.44 A2: 50307.50 A3: 46048.64 A4: 49742.89 A5: 49482.99 A6: 102591.18 A7: 97247.70 A8: 153806.56 A9: 100427.89 A10: 149287.09 13088 A11: 13088.95
Sad to say this is beyond my debugging capability. Any ideas?