One of the challenge with wearable is you have to make the system last as long as possible on a battery. Most microcontrollers have different levels of awakeness (or sleepness, as you want), that fullfill different needs, with different current consumption.
The ATTiny 25/45/85, being a simple (and a bit old) microcontorller, has only three :
- Active : not really a sleep mode, it's when it's awake. Around 5mA (plus current from each pin)
- Idle : the CPU is stopped,but most of the peripherals still work. Around 1.2mA
- ADC noise reduction : some more things shutdown.
- Power-down : in this mode every clocks and peripherals are stopped, only the watchdog, external interrupts and reset are still enables. max 10uA of current consumption with watchdog, 2uA without.
You can enable sleep by manipulating the registers to set the options you need. Some functions are also available by including "avr/sleep.h" in you program. The documentation is well made, and there are a lot of tutorials about that online.
On the badge, deep sleep (power-down) is implemented as soon as the leds are stopped. There are two cases :
- Mode 1, dice : once the leds have been lit for a few seconds, the program goes to sleep until the button is pressed again. Before going to sleep the timer that handles the PWM is stopped and the interrupt is enabled so a button push can wake the program from sleep.
- All other modes : the sleep is a pause between two blinks, so the settings are the same as above, but we also set the watchdog timer to wake up the program every 125ms, to see if enough time as passed.
On wake up, the timer for led dimming is started again, the interrupt on the button is removed, and its state is forced to 0, otherwise after waking up, the program would account for that press and send back the system to sleep. The watchdog timer is also stopped.
On mode 1 (Dice), the battery last very long, several month by awaking the badge for a dice throw every now and then.
On other modes, the leds are lit almost all the time, battery only holds for about three hours.
One thing that could be made to lengthen the battery life would be to limit the duty cycle of the leds to 50%. The decrease in intensity would be light to the eye, but that would half the current consumption.
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.