Electronic – What happens to other component’s power consumption, when uC is switched to low-power mode

gpiolow-powermicrocontrollersleep

Currently, I am using a uC (Atmel ATtiny85-PU20), which will eventually run battery powered, and I am trying to reduce power consumption of entire circuit to maximise time between battery changes. Apart from the uC this circuit has:

  1. SR HC-04 ultrasonic range sensor module
  2. This ISM band (433MHz) ASK/OOK transmitter module

While I understand how to put the uC into sleep mode, only to wake-up every 8 seconds using the watch-dog timer interrupt, I was wondering, what happens to the peripheral components/modules during this time ?

My initial thought was to put a NPN BJT as a switch, controlled by a GPIO pin, to switch the Vcc fed to the 2 modules, but is the behaviour of such a switch defined when uC goes to sleep state ?

Best Answer

Basically, the (internal) peripherals are shut off when the AVR goes to sleep. Which modules shut down depends on what sleep mode you enter into. The tinyx5 has three sleep modes: Idle, ADC Noice Reduction, and Power Down. Unless you need something to continue working while it sleeps, I would suggest the "Power Down Mode" which still allows the watch dog to function if that is what you will use to wake it up.

The internal modules are all driven by clocks scaled down from the CPU clock. If the clocks to any one module are turned off, then that module will stop functioning until the clock(s) turns back on. Theoretically, these modules will draw zero current when they are shut down, although there is always some level of leakage.

In addition to sleep modes, there are many steps you can take to ensure your circuit does not draw much power during operation, at least as far as the AVR is concerned. Here are a few ideas. All of these steps are outlined in the datasheet:

  1. Disable unused module clocks using the PRR register
  2. Shut off the analog comparator: ACSR |=_BV(ACD);
  3. Never leave floating pins - always use a pullup or pulldown resistor.
  4. Use a lower voltage power source (Vcc >= 2.7V for tinyx5, 1.8V for tinyx5V)
  5. Lower the CPU clock by changing the clock prescale values in CLKPR
  6. Disable the ADC when you are not using it: ADCSRA &= ~_BV(ADEN);
  7. Disable the digital input buffers you aren't using with DIDR0

As far as shutting down external peripherals, you could easily do that with a transistor as you have suggested. The I/O pins are static latches they retain their state when the AVR goes to sleep, so you could (in software) turn them off before you go to sleep and turn them on when you wake up. I would suggest you use a logic level N-channel MOSFET to connect/disconnect the devices from their ground supply (low-side switching), as long as the FET Gate threshold voltage is a bit lower than your AVR supply voltage so it fully turns ON from a high output. The MOSFET is not drawing any current through the gate when it is on (once the gate capacitor has been charged) unlike an NPN BJT which will continuously draw current while it is on. Either way, you should use an external pull down resistor (10k or so) to make sure the transistor stays off when it is supposed to be off. This will draw a bit of current, so a weak pull down is recommended (5V through 10k is only 0.5mA, 50uA through 100k).

You could also use this trick to turn off the external devices any other time you aren't using them; although they might need a bit of time to fully turn back on when you do need to use them or else they will give you strange results:

  1. Turn On Device
  2. Delay for a few milliseconds (whatever the recommended startup time is)
  3. Read sensor/ transmit data
  4. Delay for a few milliseconds
  5. Turn off device