Hi all,
I've got an infrared remote control transmitter that I made for my DSLR camera.
The remote uses three AAA cells and is powered up all the time.
The hardware is an ATTiny85 processor with a 16 mhz SMD crystal, two 18pF caps and a 1 meg resistor across.
Reset is tied to VCC via a 10K resistor, the other 3 pins are connected as follows:
PB0 - tied low through a 100K resistor and connected to the base of an NPN BJT via a 220 ohm resistor. The BJT drives the IR LED, which is connected between VCC and the collector of the BJT through a 2,2 ohm resistor.
PB1 - tied to VCC via a 100K resistor, currently not used.
PB2 - tied to VCC via a 100K resistor and is pulled to ground via a pushbutton (this sends the IR command).
I measured the supply current by placing a 10K resistor across my voltmeter, then putting the voltmeter and "shunt" in series with the battery pack. I got 0.27 volts, which across 10K is 27 microamps.
So far, so good... but my problem is that the battery pack seems to get sucked dry in a day or two (without the remote even being used).
Am I missing something or testing it wrong? I don't see how it can draw 27 uA but kill 3 brand new AAA alkaline cells in two days. What the heck is going on here?
By the way, here's the part of the code that sets up the timer, sets up the power save stuff and puts the board to sleep... is there anything wrong here?
// setup the timer for interrupts
void timerInit (uint32_t rate)
{
cli(); // disable interrupts
enable = 0; // zero all...
busy = 0; // ...ISR...
count = 0; // ...vars
IO_OUT = 0x00; // all pins off (no pullup)
IO_DDR = 0x00; // all pins inputs
MCUCR = 0x00; // clear MCU control register
GIMSK = 0x00; // clear interrupt mask register
// set timer 0 (8 bit) to CTC mode, carrier freq. this times the IR pulses.
TCCR0A = _BV(WGM01); // mode 2 (CTC) OCR0A = top
TCCR0B = _BV(CS00); // set F_CPU/1
OCR0A = ((F_CPU / (rate * 2)) - 1); // double rate because we toggle
TIMSK = _BV(OCIE0A); // enable interrupt on OCR0A match
// shut off everything not used
MCUCR |= _BV(PUD); // disable port pullups
ADCSRA = 0x00; // disable ADC
power_adc_disable(); // power down ADC
power_timer1_disable(); // power down timer 1
power_usi_disable(); // power down USI
sleep_bod_disable(); // turn off brown-out detector
set_sleep_mode (SLEEP_MODE_PWR_DOWN); // set CPU sleep mode
sei(); // interrupts on
}
int main (void)
{
uint8_t n; // generic
timerInit (IR_FREQ); // setup 8 bit timer for IR carrier frequency
while (1) {
cli(); // disable interrupts
GIMSK |= _BV(INT0); // enable INT0 to trigger active low
sleep_enable(); // enable CPU to be powered down
sei(); // interrupts on
sleep_cpu(); // power down cpu (all clocks stopped)
// debounce start button (in case it's tied to SELECT)
n = 10; // init debounce
while (n--) {
if (IO_PIN & BUTTON) { // if button bounced up...
n = 10; // ...reload debounce count
}
delayMS (5);
}
// send shutter command
sendCmd (shutter, 3, 0); // data, repeat 3 times, no inter-command delay
// wait for button to be RELEASED
// (prevent repeat if button held down)
n = 10; // init debounce
while (n--) {
if (! (IO_PIN & BUTTON)) { // if button pressed...
n = 10; // ...reload debounce count
}
delayMS (5);
}
}
}
Any ideas will be appreciated.