| /FollowMe/analog.c |
|---|
| 5,7 → 5,7 |
| #include "analog.h" |
| volatile int16_t Adc0, Adc1, Adc2, Adc3, Adc4, Adc5, Adc6, Adc7; |
| volatile uint16_t Adc0, Adc1, Adc2, Adc3, Adc4, Adc5, Adc6, Adc7; |
| volatile uint8_t ADReady = 1; |
| /*****************************************************/ |
| /FollowMe/analog.h |
|---|
| 3,7 → 3,7 |
| #include <inttypes.h> |
| extern volatile int16_t Adc0, Adc1, Adc2, Adc3, Adc4, Adc5, Adc6, Adc7; |
| extern volatile uint16_t Adc0, Adc1, Adc2, Adc3, Adc4, Adc5, Adc6, Adc7; |
| extern volatile uint8_t ADReady; |
| void ADC_Init(void); |
| /FollowMe/led.h |
|---|
| 10,13 → 10,13 |
| #endif |
| #ifdef USE_FOLLOWME |
| #define LEDGRN_OFF PORTB |= (1<<PORTB0) |
| #define LEDGRN_ON PORTB &= ~(1<<PORTB0) |
| #define LEDGRN_TOGGLE PORTB ^= (1<<PORTB0) |
| #define LEDGRN_OFF PORTB |= (1<<PORTB1) |
| #define LEDGRN_ON PORTB &= ~(1<<PORTB1) |
| #define LEDGRN_TOGGLE PORTB ^= (1<<PORTB1) |
| #define LEDRED_OFF PORTB |= (1<<PORTB1) |
| #define LEDRED_ON PORTB &= ~(1<<PORTB1) |
| #define LEDRED_TOGGLE PORTB ^= (1<<PORTB1) |
| #define LEDRED_OFF PORTB |= (1<<PORTB0) |
| #define LEDRED_ON PORTB &= ~(1<<PORTB0) |
| #define LEDRED_TOGGLE PORTB ^= (1<<PORTB0) |
| #endif |
| void LED_Init(void); |
| /FollowMe/main.c |
|---|
| 154,10 → 154,9 |
| // AVcc = 5V --> 5V = 1024 counts |
| // 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= 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; |
| // voltage divider R2=10K, R3=3K9 |
| // UAdc4 = R3/(R3+R2)*UBat= 3.9/(3.9+10)*UBat = UBat/3.564 |
| UBat = (3 * UBat + (64 * Adc4) / 368) / 4; |
| DebugOut.Analog[8] = UBat; |
| #endif |
| ADReady = 0; |