Since the system will be powered via batteries, I'm quite concerned regarding the power consumption.
I have the following ideas+questions:
Shut down IO Expander and Display
I propose the following:
turn off all LEDs of the display: the IO still consumes a little since it is ON
add a transistor that cut the power to the IO expander and the display using one AVR GPIO: zero current drain on both components
I think the second option is the best one. Are there any drawbacks? e.g. the power on the display side with the transistor will be less than 5V? How much less? Any better idea?
AVR low power mode
I've read here and there that the AVR can be put in low power mode. Will read more carefully about this later.
I suppose that I can use the encoder push button to revive it. It is used for something else when the firmware is in normal mode (e.g. start the countdown), but it can be switched to "wake up button" when the AVR goes in low power mode, right?
Main voltage control
Here is my main concern.
Arduino works at 5V, and with that voltage the AVR can be "overclocked" at 16MHz. With the standard 3.3V it will work at a lower frequency.
I see these options for my system:
use a 9V battery and add a LDO to generate stable 5V: that way I'm "safe" regarding the reliability of the voltage level of the board, even when the 9V battery is a little down. On the other side, I can't cut the power drainage of the LDO, so I'll always waste power while the system is in "sleep" mode.
use 4 1.5V batteries in series (I'll use rechargable NiMh batteries, with average 1.2V, so exactly 5V in total): if I put the AVR in low power mode, all the board will basically shut down, and I'll have less drainage with respect to solution 1; on the other side, when the batteries starts to discharge (e.g. all batteries are at 1V, so 4V total), the voltage may be to low to maintain the AVR performances
following option 1, add a power switch to simply disconnect the batteries from the board; simple, effective, yet a liiiittle less user friendly
I started the project in 2017, then left it for 7 years, and picked it up a couple of days ago. So I don't really remember the choices I made back then...
I suppose the display is common anode, since I send zeros to the IO expander to turn del LEDs on.
I added the IO expander since I thought I had to control 8*4 = 32 pins. Actually, I can control 8 + 4 (8 LEDs and 4 enable transistors) = 12 pins. This way I can avoid using the IO expander. (I suppose that's what you are trying to tell me)
Interesting
Awfully, I set the transistors' pin to LOW to turn them off. So, when the AVR goes to sleep, if it sets its outputs to Hi-Z, the pull-up wins and the transistors turn on; if they goes to LOW, the transistors will be turned off. I have to re-think this part if I want to have the display turned off when the AVR is in sleep mode.
Yes. If the 470R resistors produce enough brightness, the GPIO pins should be able to drive the display. That would be about 7mA per segment, 56mA in total.
What's confusing is that the digit drivers are set up as PNP transistors, but the symbols are NPN. NPNs will work, but reduce the voltage by about 0.7V. However, PNPs would require that the UNO and the display power up and down together (they are powered by the same supply), which I think is the case with your project.
Anyway, the display and the transistors may have part numbers printed on them. Perhaps you could report those numbers.
On the general question, for projects that will only be active a small percentage of the time, I have a bias toward switching the power completely off during the idle periods. Even though the Atmega328P can be put into deep sleep mode and draw essentially no current, the same is not true for the other parts of the Uno - the power indicator LED, the voltage regulator and the UART adapter chip. You could have the encoder button have a dual function of turning on the power and then serving as an input for other things after powerup. But the circuit would require a P-channel mosfet, an NPN transistor, and two diodes. If interested, I can post a schematic.
That and use a LiPo battery and a step-up converter like a MT3608. Add the charger to project. There are also 9v blocks that are actually LiPo with usb charger. In that case a buck converter to step down.
I don't have the parts at the moment. Will check the part number and report.
EDIT: I confirm I'm using NPN transistors (2N3904)
Notice that I will remove the UNO, and use a bare Atmega328P. So the sleep mode can be ok.
Also, I can switch to the internal 8MHz clock and have no problem with low voltage, given the graph posted by @ jremington
Didn't think about this. I have some spare LiPo charging controller (I bought a bulk of 5 while I needed a single one); I can use them and use the USB for recharging. Maybe I even have a spare mobile phone battery to use (4.2V).
Can be a great improvement on the system! Thanks for the idea
Well, less things you have to interact with, more likely you'll use it.
I'd like to have all the family use this, so having a single button to do everything is my preferred option.
Also, as said, it is an hobby project. Not a problem to tweak it in a second moment (ater some period of use/test, if it needs to be recharged too often).
Last but not least, I'd like to learn about actual AVR and hardware tricks to minimize power usage. No better way then try them irl!
Well this raises the issue of whether or not to use a regulator. It wouldn't be required, but there's an argument for using a linear regulator, possibly a 3.3V or even lower. They make very low dropout, low quiescent current, regulators these days, and the 328P will in fact draw less current running at 3.3V than at 5V, even at the same processor speed, and that difference might more than make up for whatever the regulator consumes. I would have to think about it more, but I don't think the regulator issue affects the display. That's for a linear regulator. The option of using a buck converter would depend on finding one with very low quiescent current.
There may be an option to eliminate all of the transistors and all of the segment resistors. Your circuit multiplexes by digit, where the common anode has to drive as many as eight segments at a time, which is more than a GPIO pin can handle. But you could instead multiplex by segment, which would switch the high current burden to the segment GPIO pins. However, only a maximum of four segments need to be driven at one time, which a GPIO might be able to handle without a transistor. It would depend on how bright the display needs to be. I believe the SevSeg.h library works with either option.
I have to take a look on the no-transistors version. Still thinking about the no-IO expander version
Less components means less wires to route, so it's generally a good idea. Regarding the power drainage, is it actually impactful to remove them? Will I gain mA, uA or nA?
I hate devices like that. Push once to do one thing and twice to do another, then hold for three seconds, blah, blah blah...Who can remember it all. I think it is the least user friendly interface you could come up with.
Good point, it is simple enough to just use a LiPo without any voltage change. A linear regulator is wasteful, a step-up or step-down will never have 100% efficiency. Using the voltage the way it comes out of the battery is preferred
I was also just thinking that it would be easier to just use a TM1637. It would contain a lot of circuitry but it would be efficient. and really simple to implement.
It's an encoder, i think it just turning and pushing, the functions are simple enough.
I agree with you.
But keep in mind that this is a dumb countdown timer. Click to power on (or whatever else), set the time with the encoder, click to start the countdown. Done.
As said, the idea to play with "low power tricks" is mainly to experiment and learn something about the topic.