Subversion Repositories Projects

Compare Revisions

Regard whitespace Rev 274 → Rev 275

/FollowMe/analog.c
22,7 → 22,7
// Digital Input Disable Register 0
// Disable digital input buffer for analog adc_channel pins
DIDR0 = 0xFF;
// external reference, adjust data to the right
// external reference AREF, adjust data to the right
ADMUX &= ~((1 << REFS1)|(1 << REFS0)|(1 << ADLAR));
// set muxer to ADC adc_channel 0 (0 to 7 is a valid choice)
ADMUX = (ADMUX & 0xE0) | 0x00;
/FollowMe/main.c
150,8 → 150,9
// the voltage at the voltage divider reference point is 0.8V less that the UBat
// because of the silicon diode inbetween.
// voltage divider R2=10K, R3=1K
// UAdc4 = R3/(R3+R2)*(UBat-0.8V) = 1k/(1k+10k)*(UBat-0.8V) = (UBat-0.8V)/11
UBat = (3 * UBat + (69 * Adc4) / 128 + 8) / 4;
// UAdc4 = R3/(R3+R2)*UBat= 1k/(1k+10k)*UBat = UBat/11
// UAdc4 = R3/(R3+R2)*UBat= 3.9k/(3.9k+10k)*UBat = UBat/3.564
UBat = (3 * UBat + (69 * Adc4) / 128) / 4;
DebugOut.Analog[8] = UBat;
#endif
ADReady = 0;