There was a recent thread on the GCS reporting wrong battery voltages. My new Tiny 2.11 does just that! So I added the line:
----- Original Message ----
From: Michel GORRAZ <address@hidden>
To: address@hidden
Sent: Thursday, 1 May, 2008 1:48:23 PM
Subject: Re: [Paparazzi-devel] Blank GCS frame!
Hello guys,
Please, don't change the resistors : it's useless
because you can easily compute the "coefficient" used in "tiny_2_1.h" and
it's dangerous
because if you use a wrong value, you can DESTROY the ADC input !!!
In " #define VoltageOfAdc(adc) ( coeff *adc) " let :
- adc = raw value of the ADC input measuring battery voltage. LPC2148 are 10bits ADCs, so the raw value in software always between 0 and 2^10 (=1023)
- Vref = LPC2148 ADCs ref voltage = LPC2148 main power supply = 3.3v
- R1, R2 = resistors made up the bridge of the battery voltage measurement system (see schematic)
- R1 between Vbattery & ADC input
- R2 between ADC input & ground
The general formula to compute the coefficient is :
coeff = ( Vref / ( 2^10 - 1 ) ) x (1 + R1/R2)
coeff = ( 3.3 / ( 1024 - 1 ) ) x (1 + R1/R2)
coeff = 0,0032258 x (1 + R1/R2)
For example :
Tiny 1.1 : R7 = 15k, R15 = 3.3k => coeff = 0,0178885630
Tiny 2.1 : R1 = 15k, R2 = 3.3k => coeff = 0,0178885630
Tiny 2.11 : R1 = 10k, R2 = 1.5k => coeff = 0,0247311828
But, it's an approximate value because of the dispersions of the components :
- resistors values (+/-1% or 5%)
- power supply (not exactly 3.3v)
- etc.