# Slowly moving to tiny-land

A project log for Yapolamp

An experimental torch/flashlight intended to be safer for eyes, completely inspired by and built upon the TritiLED project

Simon Merrett 07/17/2019 at 11:460 Comments

This log is about transferring from pulsing the classic inductor driver with an ESP8266 that is powered separately (and therefore Vpulse = 3.3V, even when Vcapacitors = 1.8V) to an ATtiny402. It's no secret that I'm a fan of this chip but this phase took me to places in the datasheet I have never been before...

The big news is that the megaTinyCore for the new 0 and 1 series ATtiny chips for Arduino is available. More details coming soon on my #ATtiny 0 Series programming on the cheap project but somehow having the ATtiny402 in the Arduino IDE just helped me speed things up with development. At the moment, while the core is new, I do still check if something that breaks on the Arduino IDE side works on Atmel Studio before admitting it's my fault!

# BLUF

The 2S 3P arrangement doesn't take kindly to Vpulse < 2.4V. This means we're losing 0.6V/(4.8V - 1.8V) = 20% of our anticipated operating voltage range. This won't necessarily translate into 20% of our run-time but it is significant.

# But First

Before we get into the goodness of the microcontroller, there are issues to report... Since last time, I have implemented a quadratic calculation for the number of microseconds the pulse should last for any given voltage. It works well (until brightness drastically drops off at 2.4V. I have tried altering the equation to significantly increase the pulse duration approaching 1.8V (from 17uS to 40uS) to no avail.

What could the cause be? Well, my first instinct was the MOSFET, although this part (OnSemi FDT439N) is rated for a VgsThreshold of 0.67V typical and 1V max. I could understand it complaining about 1.8V perhaps but I would expect 2.3V to be fine... This seems a likely contender because immediately that I swap the pulse back to 3.3V, the LEDs do brighten, although not as good as they should be.

I realise that we're getting to some very low voltages for discrete silicon parts that I can buy and solder together, but I was somewhat disappointed to find that 30% of my voltage range has gone missing!

My next contender for disappointing component is the inductor. It has resistance, so reduced voltages are going to struggle more. Not sure. What I do know is that I saw the inductor voltage trace on my oscilloscope struggle and then fail to reach the required voltage to discharge through two LEDs in series, as Vcapacitor passed below 2.4V. Which gave me an idea to revert to the no-no of driving LEDs - 1S manyP.  Hold that thought.

# The Burden of Control

In the last log, when I reported a 4mins 30second run-time, I was careful to caveat that this was not paying for the energy used by the pulsing microcontroller; it was just the LEDs drawing from the supercapacitors. This time, I whipped out my trusty (totally untested) ATtiny402 and tried to get some pulsing going. I set the clock to 5MHz, which is deemed safe down to 1.8V, turned brown-out detection etc off and got it blinking. I managed to get it down to running at 1.5V in this mode and 1.7V at 10MHz but YMMV and there was hysteresis, ie you needed a couple of hundred mV above those to restart, once it crashed. Not for the faint-hearted. I do wonder what you could get down to while running the internal 32kHz oscillator and consuming less than 10uA. maybe a shiny new single AAA cell would even be able to get one going at 1.5V... Ah, distractions...

Anyway, after impressing me with the operating voltage, I re-tuned to  5MHz and gave it some pulsing on the LED driver MOSFET gate. Success. That last couple of sentences makes it sound way easier than I found it but that's my fault for insisting upon learning how to do single shot pulses using TCB0 on the ATtiny. There's a thread on AVRfreaks alluding to my woes and recording the code which works for me. I hope to recount my tales of TBC0 and Event System glory on the #ATtiny 0 Series programming on the cheap project one day. I had forgotten that although the peak sawtooth current is 14mA per LED, that equates to 3 x 14mA when they are in a 2S 3P arrangement. So adding a few mA for the microcontroller while running isn't as big a deal as I thought and I will not look into power saving techniques on the ATtiny402 while pulses are frequently required during "fully on" mode. We can look at going to 1MHz another time, as well as ADC and other peripheral disabling etc.

# Run baby, run

So how long does it last now, with a uC sipping at the capacitors and the operating range being 20% less than before? Surprisingly well. I got 4mins 5 seconds from 4.8V - 2.4V and I'm rather happy with this. However, the only thing niggling at me before we go and make another, smaller board for this is whether a 1S 6P arrangement, like Yapolamp Beta, is what we really need. SPICE says that the pulse times would have to be nearly twice as long, suggesting that a smaller inductor may be a good move. Maybe I'll try it with the current development board and a bodge before heading back to kicad. There's no guarantee that the 1.8V - 2.4V range will become usable at 1S 6P, so that probably needs trying first.

One thing is for sure - I'm looking forward to putting my first ATtiny402 on a project PCB.