Close

Auto-pulse, auto-brightness

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 MerrettSimon Merrett 07/15/2019 at 12:520 Comments

Last time we noted that the 2.2mH inductor was going to need long pulse-discharge periods to drive the planned 6x LEDs for the next version of #Yapolamp . I thought I would go for a 1mH inductor but plumped for a 680uH one instead. I ordered it a while ago and can't remember why I picked it - probably price!

Dynamic Pulse Calculation & Generation

Now the pulse durations required for the 680uH inductor driving 6x LEDs at the most efficient sawtooth profile (see previous log) vary almost inverse proportionally to the voltage of the supercapacitors that are powering this version. I took the pulse durations calculated by spice at 1.8V, 3.3V and 4.8V, which represent the lower, nominal and upper operating voltages that I expect. I then measured the ADC counts for the 3.3V (actually 3.29V) and 5V (actually 4.82V) rails on the Wemos D1 mini R2 when put through my 2.2K/2.2K Ohm voltage divider. I put them into Excel and used a linear trendline (to start with - we can always improve this) to work out how to calculate a pulse duration for every voltage between 1.8V and 4.8V.

So using this, we can make our pulse calculation code as follows:

pulseOn = 25 - ((analogRead(A0) + 21) / 42);

 The  /  42 is the equivalent to * 0.024. I add 21 to the ADC read because 21/42 = 0.5 and because integer maths rounds to a floor, rather than normal rounding, adding 0.5 has the effect of implementing normal rounding (both up and down, rather than solely down).

Results

This works! From a fully charged pair of 3F supercapacitors in series at 4.85V, the discharge brightness is pretty even over the full range of voltages down to 1.8V. Here's one of the moments that the pulse duration is increased to maintain the peak sawtooth current (as indicated by the increased duration of the discharge of the inductor in the trace):

I set the ADC-based recalculation of the pulse length at 10Hz and this seems fine for adjusting the pulse (brightness) not only during the discharge but also the MUCH faster charge phase - that's right, this torch can be fully-on with constant brightness during charging of the supercapacitors from the USB battery bank!

This test also now allows us to better estimate the run-time for a given capacitor charge. Bear in mind that we will have to add in the microcontroller current burden to the calculation but from this experiment, our 3F capacitors give us a 4 mins 36 seconds run time from full to 1.8V (and the LEDs are still bright at this point - just can't be sure the microcontroller will keep going below this voltage). 

Auto-pulse points to address in future:

Next steps

So now I have proved we can achieve a constant-ish brightness from a wide range of supply voltages, I'm confident we can now start to design a more compact PCB for a V1.1 beta (oh dear - will we ever leave beta-land?!). However, before that, I need to find a microcontroller that will handle our UI (button), operating mode and pulse calculation and generation. I also need to decide how many Farads we want to pack in with this little torch. Stay patient - this may take me some time...

Discussions