Parcourir la source

Add FET swtich for battery ADC

tags/v1.9
tmk il y a 9 ans
Parent
révision
2015027da3
2 fichiers modifiés avec 19 ajouts et 0 suppressions
  1. 7
    0
      keyboard/hhkb_rn42/MEMO.txt
  2. 12
    0
      keyboard/hhkb_rn42/rn42/battery.c

+ 7
- 0
keyboard/hhkb_rn42/MEMO.txt Voir le fichier

- deep sleep MCU and BT module(keyboard is not used for long time) - deep sleep MCU and BT module(keyboard is not used for long time)
- deep sleep MCU and turn off BT module(keyboard is not used and not connected) - deep sleep MCU and turn off BT module(keyboard is not used and not connected)
- Battery ADC; switching, high resistance - Battery ADC; switching, high resistance
- switching gnd end of divider with PF4
- high resistor 100K/1M?
capacitor 10nF
http://www.eevblog.com/forum/beginners/measuring-battery-voltage-without-consuming-current/


Improving: Improving:
- BT LED; connecting, linked, sleeping, deep sleeping - BT LED; connecting, linked, sleeping, deep sleeping
- Battry LED; blink(using timer?) - Battry LED; blink(using timer?)
- move rn42 to protocol directory when it becomes reusable stack - move rn42 to protocol directory when it becomes reusable stack
- LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256). - LUFA sendchar should be buffered and serial_uart.c buffur size is too large(256).
- ADC resolution
AVR120
AVR32138


Testing: Testing:
- Factroy reset doesn't work; need to **test again** 10K pull-up is too high? - Factroy reset doesn't work; need to **test again** 10K pull-up is too high?

+ 12
- 0
keyboard/hhkb_rn42/rn42/battery.c Voir le fichier

ADMUX = (1<<REFS1) | (1<<REFS0); ADMUX = (1<<REFS1) | (1<<REFS0);
ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0); ADCSRA = (1<<ADPS2) | (1<<ADPS1) | (1<<ADPS0);
ADCSRA |= (1<<ADEN); ADCSRA |= (1<<ADEN);

// ADC disable voltate divider(PF4)
DDRF |= (1<<4);
PORTF &= ~(1<<4);
} }


// Indicator for battery // Indicator for battery
// Returns voltage in mV // Returns voltage in mV
uint16_t battery_voltage(void) uint16_t battery_voltage(void)
{ {
// ADC disable voltate divider(PF4)
DDRF |= (1<<4);
PORTF |= (1<<4);

volatile uint16_t bat; volatile uint16_t bat;
//ADCSRA |= (1<<ADEN); //ADCSRA |= (1<<ADEN);




//ADCSRA &= ~(1<<ADEN); //ADCSRA &= ~(1<<ADEN);


// ADC disable voltate divider(PF4)
DDRF |= (1<<4);
PORTF &= ~(1<<4);

return (bat - BATTERY_ADC_OFFSET) * BATTERY_ADC_RESOLUTION; return (bat - BATTERY_ADC_OFFSET) * BATTERY_ADC_RESOLUTION;
} }



Chargement…
Annuler
Enregistrer