As 2021 comes to a close, the firmware in this project is something approximating an almost feature complete milestone. Prior to refining the firmware further, tests were conducted to evaluate power management, resource utilization, and robustness. A total of 30 tests were conducted covering 6 firmware configurations. The results of those tests were largely positive though more extensive stress testing of the the I2C peripheral implementation is necessary.
This section will describe the approach to power management, certain implementation details, and will end by discussing the findings and possible improvements.
Update: Since this was prepared, I have updated my test fixture and can now isolate the current to only what is consumed by the MCU itself. Hopefully I'll take a 2nd look at this and include mode tests now that I am not limited by setup.
MCU with default configuration, 800KHz sleep frequency, etc consumes ~750uA.
Prior to discussing test results this section describes the implementation used in this project. The mechanism and implementation details for tinyAVR Series-0/1 are described below. Depending on the configuration, the microcontroller will consume only 1% to 40% of the amount of power used in the always active case.
The following section covers the power management modes. Immediately following will be test the sequences used to perform measurements.
There are two strategies used to lower power consumption. The use of the sleep modes and reducing the frequency of the system clock. When the system clock is reduced, the ADC sampling rating is also effectively reduced.
Adjusting the sampling rate of the ADC at the peripheral had a marginal impact. As documented in
the datasheet, the electrical characteristics of the ATTINY402
seems to support this onservation.
Unfortunately the datasheet lacks good characterization across a wider set of operating conditions.
Group | PM Mode | Slowclock | Description | |
---|---|---|---|---|
1 | None | Disabled | 🔴 |
No power management functionality has been included in the firmware. This reduces the firmware size, |
2 | Idle | Disabled | 🔴 |
The CPU stops executing code. Active peripherals remain active and the CPU will begin executing
again when an interrupt is asserted. Entry Conditions:
Wake source exit conditions:
|
3 | Standby | Disabled | 🔴 |
A subset of of peripherals are able to continue operating in standby. As a result, power consumption is a function of the application and the choice of peripherals, and their configurations, etc. Entry Conditions:
The following peripherals are active in standby:
If requested the following will be active in standby:
Wake source exit conditions:
Inactive peripherals:
|
4 | Standby | 800KHz | 🟢 |
To reduce current consumption further the Fcpu is reduced to approximately 1MHz. |
5 | Powerdown | Disabled | 🔴 |
A small number of peripherals continue operate in this mode. Power consumption is a
function of the peripherals that have been configured to operate in powerdown mode. Entry Conditions:
The following peripherals are active in powerdown mode:
Wake source exit conditions:
As ADC is not available in powerdown mode, it is not possible for a user to wake the peripheral by the keypad. |
6 | Powerdown | 800KHz | 🟢 |
Same as above (4). The clock reduction provides no benefit in this example because the the clock is stopped entirely shortly there after. Worse yet, when it resumes, the I2C peripheral will be sluggish and slow to respond initially. In the prior example, the ADC continued operating and could respond to key presses and the I2C bus. |
See 2 for more details.
Sequence | Symbol | Use Case | |
---|---|---|---|
1 | Disabled |
No power management functionality has been included in the firmware. This reduces the firmware size, |
Symbol | Meaning |
---|---|
🔴 | Function disabled at compile time. |
🔵 | Function enabled, but not actively in use. |
🟢 | Function enabled, and actively in use. (i.e. I2C traffic, key presses.) |
Seq. | Variable | Test Case | RGBLed | Keypad | I2C |
---|---|---|---|---|---|
1A | Iidle | Default config; No I2C, LED, or Key activity. | 🔵 | 🔵 | 🔵 |
1B | Ii2c | Default config; I2C actively writing, no LED or Key activity. | 🔵 | 🔵 | 🟢 |
1C | Ikeypad | Default config; Sequence through key presses, I2C and LED inactive. | 🔵 | 🟢 | 🔵 |
2 | InKeyPad | Disable KeyPad at compile time; otherwise similar to Iidle. | 🔵 | 🔴 | 🔵 |
3 | InLow | Disable all functionality; Used to obtain effective lower limit. | 🔴 | 🔴 | 🔴 |
PM Support | Fstby | Flash | RAM | Iidle | % ⬇️ | Ii2c | % ⬇️ | Ikeypad | % ⬇️ |
---|---|---|---|---|---|---|---|---|---|
None | 🔴 | 2811 bytes | 185 bytes | 10.46mA | 12.54mA | 10.56mA | |||
Idle | 🔴 | 2843 bytes | 185 bytes | 4.04mA | 38.62% | 5.90mA | 47.05% | 4.04mA3 | 38.26% |
Standby | 🔴 | 3023 bytes | 185 bytes | 3.06mA | 29.25% | 5.94mA | 47.37% | 4.06mA | 38.45% |
Standby | 800 KHz🟢 | 3039 bytes | 185 bytes | 904uA4 | 8.64% | 5.94mA | 47.37% | 4.06mA | 38.45% |
... adjusted | ~850uA4 | ||||||||
Powerdown | 🔴 | 3023 bytes | 185 bytes | 68.2uA4 | 0.65% | 5.94mA | 47.37% | 72.0uA5 | 0.68% |
... adjusted | <10uA4 | ||||||||
Powerdown | 800 KHz🟢 | 3039 bytes | 185 bytes | 68.2uA4 | 0.65% | 5.94mA | 47.37% | 72.0uA5 | 0.68% |
... adjusted | <10uA4 |
Some results have been adjusted to compensate for a measurement error. The error applies to all measurements, but select measurements have been shown as adjusted above.4 For complete results covering all test cases see 6.
- There appear to be an issues with I2C errors when exiting standby. It may be due to a BusPirate's poor clock stretching support (which was a quick and dirty patch applied to bus pirate).
- Update test procedure to isolate I2C and other sources impacting power consumption.
Equipment Setup:
- Benchtop Power Supply: 5V, limit 200mA
- Multimeter: High side, set to mA range initially.
- BusPirate: To generate I2C traffic for test 1B.
Bench Configuration:
- ATTiny402
- Mounted on an SMT protoboard.
- 4x4 Keypad
- Powered & tested
- Microchip Snap4
- To load firmware
- RGB LEDs are unpowered
Limitations & Improvements:
- Isolate
ATTINY402
power rails because Ii2c is measuring the I2C open drain losses.- Snap4 and BusPirate contributed a sizable error to the measurements.4
- Buy a decent multimeter. I have good test equipment... but not a good multimeter.
- Need to replace BusPirate with something better.
- Load firmware for sequence 1.
- Disconnect BusPirate & Snap4.4
- Apply power and wait 10 seconds.
- Select MAX mode on the multimeter, wait 10 seconds.
- Record result for Iidle (1A).
- Connect buspirate; (Record offset, if any?)
- Run script to generate I2C traffic. (See scripts/traffic.py for example.) - I adapted the ledtest.py script to send 72 bytes to the LED page indefinitely.
- Reset statistics on multimeter, select MAX and wait 10 seconds
- Record the result for Ii2c (1B).
- Disconnect buspirate.
- Reset statistics on multimeter, select MAX.
- Press each key a couple times.
- Record the result for Ikeypad (1C).
- Load firmware for sequence 2 or 3.
- Disconnect BusPirate & Snap4.4
- Apply power and wait 10 seconds.
- Select MAX mode on the multimeter, wait 10 seconds.
- Record the result for InKeyPad (2) or InLow (3).
Footnotes
-
TWI peripheral is clocked using the `SCL` input. This imposes a limitation on certain use cases that are not used in this project. ↩ ↩2
-
DS40002318A ATTINY402 Datasheet, 11. Sleep Controller, Page 90 - 96 ↩
-
Typical keypad entry. To optimize computational performance the ADC's window comparator function is activated when the keypad input has reached a steady state. When rapidly alternating between a high value key and a low value key, Ikeypad will be between 4.04mA (Ikeypad(idle)) and 10.56mA (Ikeypad(none)). In practice, however, exceeding Ikeypad(idle) involves some level of button mashing. ↩ ↩2
-
Due to test setup when measurements were performed, there is an offset. It is particularly pronounced for the measurements in the uA. About 55uA to 65uA can be attributed to the Snap4 ICD. Thus, Iidle (and to a lesser extent Ikeypad) is overstated. For group 4, Iidle was \~850uA. For group 6 & 5, Iidle read out was \~4uA. It's sufficiently low that I do not place much faith the accuracy of the multimeter used. ↩ ↩2 ↩3 ↩4 ↩5 ↩6 ↩7 ↩8 ↩9 ↩10
-
Increase in current consumption attributed to current mirror in keypad. ↩ ↩2 ↩3
-
Full Results:
Grp.3 Seq.5 Vcc Fon Fstby RGBLed Keypad I2C PM Config Ityp Flash RAM 1 1A 5.0V 20MHz 🔵 🔵 🔵 None 10.46mA 2811 185 1 1B 5.0V 20MHz 🔵 🔵 🟢 None 12.54mA 2811 185 2 1C 5.0V 20MHz 🔵 🟢 🔵 None 10.56mA 2843 185 1 2 5.0V 20MHz 🔵 🔴 🔵 None 9.77mA 2234 176 1 3 5.0V 20MHz 🔴 🔴 🔴 None 8.93mA 432 4 2 1A 5.0V 20MHz 🔵 🔵 🔵 Idle 4.04mA 2843 185 2 1B 5.0V 20MHz 🔵 🔵 🟢 Idle 5.90mA 2843 185 2 1C 5.0V 20MHz 🔵 🟢 🔵 Idle 4.04mA 2843 185 2 2 5.0V 20MHz 🔵 🔴 🔵 Idle 3.57mA 2266 176 2 3 5.0V 20MHz 🔴 🔴 🔴 Idle 2.57mA 464 2 3 1A 5.0V 20MHz 🔵 🔵 🔵 Standby 3.06mA 3023 185 3 1B 5.0V 20MHz 🔵 🔵 🟢 Standby 5.94mA 3023 185 3 1C 5.0V 20MHz 🔵 🟢 🔵 Standby 4.06mA 3023 185 3 2 5.0V 20MHz 🔵 🔴 🔵 Standby 68.2uA 2446 176 3 3 5.0V 20MHz 🔴 🔴 🔴 Standby 68.2uA 630 2 4 1A 5.0V 20MHz 800KHz 🔵 🔵 🔵 Standby 904uA 3039 185 4 1B 5.0V 20MHz 800KHz 🔵 🔵 🟢 Standby 5.94mA 3039 185 4 1C 5.0V 20MHz 800KHz 🔵 🟢 🔵 Standby 4.06mA 3039 185 4 2 5.0V 20MHz 800KHz 🔵 🔴 🔵 Standby 68.2uA 2462 176 4 3 5.0V 20MHz 800KHz 🔴 🔴 🔴 Standby 68.2uA 646 2 5 1A 5.0V 20MHz 🔵 🔵 🔵 Powerdown 68.2uA 3023 185 5 1B 5.0V 20MHz 🔵 🔵 🟢 Powerdown 5.94mA 3023 185 5 1C 5.0V 20MHz 🔵 🟢 🔵 Powerdown 72.0uA 3023 185 5 2 5.0V 20MHz 🔵 🔴 🔵 Powerdown 68.2uA 2446 176 5 3 5.0V 20MHz 🔴 🔴 🔴 Powerdown 68.2uA 630 2 6 1A 5.0V 20MHz 800KHz 🔵 🔵 🔵 Powerdown 68.2uA 3039 185 6 1B 5.0V 20MHz 800KHz 🔵 🔵 🟢 Powerdown 5.94mA 3039 185 6 1C 5.0V 20MHz 800KHz 🔵 🟢 🔵 Powerdown 72.0uA 3039 185 6 2 5.0V 20MHz 800KHz 🔵 🔴 🔵 Powerdown 68.2uA 2462 176 6 3 5.0V 20MHz 800KHz 🔴 🔴 🔴 Powerdown 68.2uA 646 2