Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize power consumption #74

Open
mortenfyhn opened this issue Dec 15, 2023 · 7 comments
Open

Minimize power consumption #74

mortenfyhn opened this issue Dec 15, 2023 · 7 comments
Labels

Comments

@mortenfyhn
Copy link
Owner

mortenfyhn commented Dec 15, 2023

The entire device (measured on battery input at 4.1 V):

  • Active: 50-60 mA
  • Sleep: 0.5 mA @ 4.1 V = 2.05 mW

The load cell + amplifier (measured on 3.3 V line):

  • Active: 10 mA
  • Sleep: 0.0 uA

The displays (measured on battery line at 4.1 V):

  • Active: 50 mA
  • Sleep: 190 uA @ 4.1 V = 0.78 mW

The push button uses a small amount of power when pressed and nothing when not pressed.

So where is the remaining 1.27 mW going?? An 328P in deep sleep shouldn't use nearly that much.

Standby: 0.5 mA gives around 100 days.
Usage: 50 mA gives around 24 hours.
So if I use it, say, twice a day, 5 min brew + 5 min timeout each time, that's 20 minutes usage per day + 1420 minutes standby. That's 16.7 mAh (usage) + 11.8 mAh (standby) = 28.5 mAh -> 42 days, assuming 1200 mAh battery.
Very back of the envelope.

@mortenfyhn
Copy link
Owner Author

mortenfyhn commented Dec 31, 2023

  • Do the displays use more power in standby because they're hooked up to the battery line instead of the 3v3 line? -> They're on the 3v3 now

@mortenfyhn
Copy link
Owner Author

The TM1637 driver has a parameter bool on. I wonder if the power consumption is changed by this, when all segments are off:

https://github.com/avishorp/TM1637/blob/82214be06742bf187fab4f29aaabb64c289eaae0/TM1637Display.h#L49-L51

@mortenfyhn
Copy link
Owner Author

Maybe switch to an ATtiny1614 eventually

@mortenfyhn
Copy link
Owner Author

Some profiling of the active state loop of today's version (235c0ac):

task description approx. duration (us)
1 check for button press 8
2 wait for hx711 ready (irrelevant)
3 read from hx711 800
4 compute grams [1] 80
5 add value to filter 80
6 get filtered value 1000
7 compute hysteresis 60
8 format scale segments 450
9 set scale segments 23 150
10 update timer display 34 250
11 check for steady state 700
12 check activity timeout 8

[1]:

const float weight_in_grams = hysteresis_.compute(filter_.getValue());

@mortenfyhn
Copy link
Owner Author

mortenfyhn commented Dec 29, 2024

However by using

https://github.com/bremme/arduino-tm1637

instead of

https://github.com/avishorp/TM1637

the write to segment duration is much shorter:

(I've also added some exp decay smoothing with factor 0.1)

task description approx. duration (us)
1 check for button press 8
2 wait for hx711 ready -
3 read from hx711 746
4 compute grams 76
5 add value to filter 70
6 get filtered value 963
7 compute hysteresis 53
8 format scale segments 481
9 set scale segments 1015
10 update timer display 1503
11 check for steady state 700
12 check activity timeout 14

Here's the diff: dbe9ff6

@mortenfyhn
Copy link
Owner Author

So that means we for each 100 ms iteration (HX711 is configured for 10 Hz output), we work for 5-6 ms, and then do nothing (busy loop) for the remainder.

Note that the above is all with -Os.

Next:

  • Actually implement sleeping and interrupt wake for when the HX711 is ready
  • Try to squeeze even more speed improvements?

@mortenfyhn
Copy link
Owner Author

Anyway come back to this after standalone MCU PCB without arduino board.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant