I don't really have anything to add, except that I think a software-controlled boost-buck driver is a super-cool application for a microcontroller (no need for messing with PWM for dimming, simply vary the switch mode duty cycle, in software, to alter output current). So I'd love to see the final design!
[...] the LM358 isn't a rail to rail device so you loose some range... I would also give some thought to the Hall effect current sensors made by Allegro (ACH712) as they will produce a voltage that can be above Vcc/2 or below it at up to 185mV/amp, are inexpensive and don't require a sense resistor.
The attached schematic shows a simpler way for you to monitor the current and smooth the reading. Choose the ratio R2/R1 to get the range you need, and the capacitor in parallel with R2 to get the smoothing time constant you want.However, the average power supply current is not the same as the average LED current. Maybe you should be monitoring the peak current passed by the mosfet instead?
About the average LED current/ power supply current. I thought the power consume by the CPU and other components was negligible vs LED power (~0,7A to 3A).
I would also give some thought to the Hall effect current sensors made by Allegro (ACH712) as they will produce a voltage that can be above Vcc/2 or below it at up to 185mV/amp, are inexpensive and don't require a sense resistor. All in all they are at first glance an ideal solution and work off of 5 volts too. I took the liberty of attaching a data sheet.Bob
Alternatively, use a diode and capacitor to turn your current sense op amp circuit into a peak or average current detector, then you can modify the PWM amount according to the current, and use a supersonic switching frequency.
See attached peak detector schematic. R1 is the current sense resistor. (R2 + R3)/R2 defines the op amp gain, and C1 * (R2 + R3) defines the time constant, which should be large compared to 1/f where f is the PWM frequency.
Please enter a valid email to subscribe
We need to confirm your email address.
To complete the subscription, please click the link in the
email we just sent you.
Thank you for subscribing!
via Egeo 16