Saturday 22 June 2019

The slow guy

"There is more to life than simply increasing its speed."
Mahatma Gandhi

We have been trying to reduce the power requirements of the solar candle project by increments in order to extend the useful available light after the big yellow goes down for the night, and one possibility that seemed promising was buried deep in the datasheet for the attiny13a.

We always thought that people who pore over datasheets need to get out more, but here we are looking at reducing the current requirements of a microcontroller by telling it to process commands at the rate of 128kHz instead of the previous 1.2MHz. The datasheet (page 125 onwards) makes the following observation.

Reduce speed and voltage = reduced current
The promise is like every typical electronics quest we have embarked upon in that various technical requirements must be met in order for any possible magic to occur. Firstly, there must be a way of communicating with such a slow sleepy chip - and this is done by updating the firmware on a typical usbasp programmer and bridging a couple of jumpers as per this excellent tutorial from our good friend Łukasz. The resultant programmer can then communicate safely and effectively with the attiny13a at tortoise speeds.

Two programmers connect and a slow guy emerges
So a quick breadboard experiment showed that a standard chip galloping along at 9.6MHz consumes 4.3mA doing candley-goodness, but that it's current reduces to 1.3mA at 1.2MHz and finally a miserly 400μA at 128kHz. Setting the clock fuses using this very useful site results in a command line for avrdude along the lines of "avrdude -c usbasp -p t13 -P /dev/ttyS0 -b 250 -U lfuse:w:0x7b:m -U hfuse:w:0xff:m" (yep, that'll do your head in).

Finally the new code should contain the line "#define F_CPU 128000UL" and then after compiling and uploading - presto a slow guy doing the same stuff as usual, but using less current - noice!

This aspect of the project coincided nicely this week with the arrival of PCBs from China which have been slightly redesigned to include a 100nF decoupling capacitor for stability of voltage to the microcontroller, as well as smd sized diodes (circled below) to further reduce the footprint of the PCB - simply awesome (and fun to solder with our new soldering station).

The finished product flanked by the bare PCBs, note SMD diodes
There is little more to do now apart from fiddling a bit with the inductor specs (shown above as 1/4W and 47uH), and then looking for a nice container for the electronics which throws a warming light and has room somewhere for the solar panel. Some more sunshine would be great but then again if these slow guys work well in the depths of a Tassie winter then that augurs well for longer burn times as the sunshine increases later in the year.




No comments:

Post a Comment