This is an experimental project of switch mode power supply (SMPS) built with a tiny microcontroller. Battery powered LED lantern is a typical project for such experiments.
This project was originated at the time that building portable LED light was in vogue after 2011 To-hoku earthquake and tsunami. However I lost interested in the project and gave up the documentation because it had no interesting feature compared to other projects on the web. Recentry an AVR freak, Yuki, has built a pocket sized LED light controlled with an AVR. It inspired me and I restarted the documentation and finally opened it just now. This is the reason why led3 was a missing number and led4 was opened prior to it. There are many projects I did but only a half or less out of them are completed as open projects. I should make it a rule to make documentation every projects that I did :-)
Right image shows the built LED driver board and the circuit diagram. It is a simple boost converter and is controlled with a cheap microcontroller. Of course complex power supply, such as 3-phase inverter, is always controlled with a microcontroller. Also simple lighting ballast circuit is being shifted to microcontroller based control. I think this is to increase performance and function with minimal cost.
An Atmel ATtiny13A is used for SMPS controller in this project. The ATtiny13A is not intended for such use and cannot do advanced controls as SMPS microcontroller does but not bad for LED lantern and similars. It controls only switching cycle time depends on input voltage. The input voltage is divided by R1-R2 and input to integrated 10-bit A-D converter. The peak inductor current is detected by analog comparator with 400mV threshold voltage generated by R7-D2. Thus the peak inductor current is fixed to 800mA. PB3 is held high at off state to minimize power consumption and it achieves very low standby current less than 1μA. R6 is to pull-up the Vcc grater than 3V to drive Q1 with sufficient gate voltage. SW1 is to select the power state. The power state changes in order of OFF, High, Low and OFF by SW1.
To built it as a lantern, it should emit non-directional light to light up surrounding objects. Since typical LED is a directional light source, so that a mounting design of LEDs is required to emit non-directional light. In this project, four chip LEDs are mounted each side of a square aluminum rod. The aluminum rod also dissipate heat of the LED. The LED mountings, controller board and batteries are embedded in a cylindrical plastic case and diffuse the light with a mylar tracing film put inside the case.
SMPS control is the main function of the firmware. In this project, the output current control is done in open-loop because the LED lamp is easy to use unlike discharge lamp by its I-V characteristics. It is not accurate compared to closed-loop control but it is not a disadvanage for cheap LED light. Of course control parameters in the firmware need to be changed when load configuration, number of LED chips or output current, is changed.
In the boost converter, there are two operationg modes, continuous mode and discontinouous mode as shown in right image. If it always operates at discontinouous mode, Ip cut-off function to terminate on-state is not needed because the peak current Ip is determined by only Vi/L/Ton. However this contrller operates at continuous mode at High state, as the result it requires a Ip cut-off feature. Due to this requirement, integrated PWM modulator is not used and termination of on-phase is done by only Ip cut-off feature. As the result, switching wave form is generated by software at cycle-by-cycle. This SMPS control is driven in background process.
At the discontinouous mode, the switching cycle time TCYC is changed for constant current control. At the continuous mode, off-phase time toff is changed instead of cycle time to prevent sub-harmonic oscillation. Also the transfer function of discontinouous and continouous mode differ as shown in right image, so that the firmware operates in different function for constant current control. These operation is simplified from ideal operation and the accuracy of the constant current control is not good but sufficient for cheap LED light.
The low battery condition is indicated by flickeing light. When supply voltage lowers 2.1V, the light start to flicker. When supply voltage lowers 1.8V, the power state changes to OFF. If the supply voltage at start-up is less than 2.1V, it does not start and stay OFF state. The power cousumption at 2.5V supply voltage is 450/80mA(High/Low).