Digital  Flashlight  Design  Experiment

 

 

     I would coin the phrase “digital flashlight” to categorize any flashlight that contains a microcontroller (MCU).  Of course digital flashlight must use LEDs, but LED flashlight is not necessary a digital one.

 

     Figure 1 is the circuit for digital flashlight design experiment. It contains only a few components in addition to the LEDs.  We would like to draw some guidelines from this experiment.  Note the supply voltage is 4.5V, and those inter-related component values are already chosen for best fitted. The LEDs are connected in serial instead of parallel.

                                    

 

                                         Figure 1.  Digital flashlight experiment circuit

 

 

    Basically the circuit is a voltage booster or step-up switching voltage converter, which converts the 4.5V supply to higher voltage for the serial LEDs. The number of LEDs should be two or more.

 

     The circuit uses ATtiny11 (U1) as a charge pump and operates as follows. When the MCU outputs a logic High to the gate (G) of the 2N7000 N-channel MOSFET, it turns Q1 ON between drain (D) and source (S), hence the right side of inductor L1 is shorted to ground. During this period the 4.5V power supply charges L1 so that its current increases from zero to a peak value Ipk linearly (Figure 2), as long as the inductor is not saturated (That’s why choosing the right inductor is important, see Source information later).

 

                              

                                       
                                      Figure 2.  Charge pump current versus time.


 
 

     Then the MCU outputs a logic Low, Q1 turns OFF so the current can’t flow to ground, but the inductor’s stored energy will induce a high voltage to keep current flowing. So the Schottky diode D2 conducts and the capacitor C2 is charged until the current becomes zero. The LEDs will be turned ON when the capacitor’s voltage reaches the LEDs total forward ON voltages.

 

     Because of MCU’s widely available and inexpensive, plus its small footprint, using microcontroller in LED flashlight is attractive.  This is particularly true for the Atmel 8-pin ATtiny11L, which works down to 2.7V and costs only 52 cents each [1].  Listing 1 is the assembly program we use here for the MCU as a charge pump.

 

 

LISTING 1.  Program for ATtiny11L as Charge Pump

 

;CPUMP.ASM: control FlashLight LEDs uisng ATtiny11L at 1 MHz

;When Voltage boost pump ON=7 NOPs, Ton=7us

 

.include "TN11def.inc"

.cseg

.org 0

;---------------------------------------------------------------

Start:

        sbi     ddrb, 2       ; make Portb.2 an output

        Cbi     portb, 2      ; pump=OFF to begin

Again:

        sbis    ACSR, 5       ; skip next instruction if Vs=>.6V

        Sbi     portb, 2      ; pump=ON for 7 NOPs (7uS)

        nop

        nop

        nop                            

        nop

        nop

        nop

        nop                            

        Cbi     portb, 2      ; pump=OFF

        rjmp    Again        

;----------------------------------------- 

 

 

 

      This program is so simple that it takes only 26 bytes of program memory.  The most important idea is the charge pump control function.  The instruction  Sbi   portb, 2 ‘ tells the MCU to output a logic High to turn on the charge pump. Because the MCU works at 1 MHz by its internal oscillator, each NOP takes 1uS to execute, so the ON time is Ton=7uS.  Similarly, ‘Cbi  portb, 2’ tells the MCU to output a logic Low to turn off  the charge pump.

 

     Instruction ‘sbis  ACSR, 5’ needs more explanations. First, sbis means “skip next instruction if bit# is set.”  Here the bit number is bit5 of the MCU internal register ACSR, its full name is Analog Control and Status Register.  Its bit5 is the comparing output of the ATtiny11 Analog Comparator pins PB0 and PB1.

 

     Refer back to Figure 5, ATtiny11L has two analog input pins: PB0 and PB1, where PB0 acts as variable input Vs, while PB1 is set up at fixed reference voltage, in our case it’s set to Vr=0.6V by Silicon diode 1N914.  If and only if Vs is equal or larger than Vr,  bit5 of ACSR is set, so the charge pump will not turn on, but stay idle; Otherwise it will keep charging for 7uS every cycle.  Because Rs=27W, when Vs=0.6V the current flowing LEDs will be I= 22mA, that’s the normal LED forward ON current.

 

     Figure 2 illustrates the charge pump current versus time.

                                

     There are two formulas that govern the circuit operation. The first one holds the relationship between supply voltage Vin, indoctor L, its peak current Ipk and MCU’s ON time Ton:

 

                     Vin = LIpk/Ton                                  (2)

 

For instance, from Vin=4.5V, L=100uH, Ipk=300mA, we can calculate Ton=7uS. This is exactly what we chose for the charge pump ON time in program CPUMP.ASM.

 

     The second formula describes the power of voltage booster related to inductor L, peak current Ipk and its switching frequency f:

 

                                                                2

                      P = ˝ L(Ipk) *f                                  (3)

 

Therefore, without changing component values, the circuit’s switching frequency f will increase when adding more LEDs, because adding more LEDs needs more power to light them up. You can easily test the correctness of this formula. For example, if you change the number of LED from 2 to 4, and measure the switching frequency in each case, you will get the frequency ratio=2.  In my experiment I actually got f2=15KHz, f4=31KHz respectively.

 

     However, when the number of LED equals 5 or more, measurement indicates that Vs becomes always less than 0.6V.  That means Vs can no longer keep up with Vr for more LEDs.  Why?  The reason is, under the circuit particular components, the energy stored in L has all been used up or exhausted. The frequency had been increased to its possible highest so that in Figure 2  “idle” time becomes zero. So even though the charge pump continues to work every cycle, but there will be no more energy than its maximum can be delivered to LEDs.

 

     In other words, with the number of LED equals 5 or more, we can safely remove the MCU’s analog comparator circuit components R1, D1, and R2, without having to worry about LEDs being overdriven. This is an advantage we can take.  Remember R2 also wastes some energy in vain (heat), although it was needed as voltage sensing component here.

 

 

 

 

 

          Serial  5-10  LED  Digital  Flashlight

 

 

     Because Vs cannot follow Vr when the number of LED equals 5 or more, so we can remove some components from the experiment circuit without having problem, as shown in Figure 3.  Correspondingly we should also remove the instruction ‘sbis  ACSR, 5  from software, since the analog comparator is no longer used. This new program is now called CPUMP1.ASM and it takes only 24 bytes.

                              

                                Figure 3.  Digital flashlight (5 LEDs) circuit

 

 

 

                  Figure 4.   the 9 LED circuit and reflector before assembling

 

     We can use this new circuit hardware and software program to build any 5-10 LED digital flashlight.  As a practical example, I built a 9 LED flashlight on the base of my  another fancy flashlight that has a bulky body and reflector (Figure 4). 

 

     The control circuit contains only 6 small components that were mounted on a perfboard that measured less than 1 square inch.  The 9 LEDs were soldered on another circular perfboard. Before assembling and gluing them in the body, the whole circuit must be connected together and tested to avoid any error.

 

     This is a super bright LED flashlight.  The 4.5V (3-AA cells) battery supplies 150mA current, and the 9-LEDs output 30V at 20mA. So the input power is 675mW, output power is 600mW, and the circuit efficiency is pretty high: 88%. The main reason is that in this case there is no resistor used, and the ATtiny11 takes only 2-3 mA.