Microcontroller controlled by pushbutton for LED flashlight

Hop

Newly Enlightened
Joined
Feb 11, 2015
Messages
3
Location
Venice, Florida, USA
Earlier this year, someone posted in another electronics forum a problem he was having inserting a push-button controlled MOSFET switch in series with the negative (return) lead of a programmable constant-current LED controller. A high-power 10W LED (with its controller board) is located at one end of the flashlight atop a LiIon cell, with one wire connected to the positive terminal of the cell. The other wire on the controller is connected to the metal flashlight case. To complete the circuit, a push-button switch on the other end of the flashlight connects the negative terminal of the LiIon cell to the metal flashlight case.

The problem was to replace the mechanical push-button switch with a small dome-switch controlling a power MOSFET. There were other operational considerations that would be handled by programming a Microchip PIC10F200 microprocessor. Basically, the dome switch provides an input to the microprocessor and the microprocessor provides a gate drive signal to the MOSFET. All of this would be powered through the LED controller by placing a 330 ohm resistor across the two controller wires. This resistor provides a current path from the positive terminal of the LiIon cell to the metal flashlight case when the LED is off.

The purpose of all this was to replace a low-current capability mechanical switch with a MOSFET that could easily switch six or more amperes. The entire circuit has to fit on a 14mm diameter circuit board using surface-mount components attached to only to one side of the board. The other side of the board is reserved for a spring contact to the negative end of the LiIon cell.

Several weeks into this project the original poster noticed that when the MOSFET was conducting (LED in the flashlight is on), there would be no power to operate the PIC since the MOSFET effectively connects the negative terminal of the LiIon cell to the flashlight case, which is serving as the positive supply terminal for the PIC. Prior to turning the MOSFET on, power to operate the PIC is supplied by the voltage between the negative terminal of the LiIOn cell and the flashlight case. In this case, the negative terminal of the LiIon cell served as the negative or ground rail (Vss) and the flashlight case as the positive rail (Vdd). Thus, the PIC is powered as long at the MOSFET is off.

The easiest "solution" to this problem of power going away when the flashlight is on would be a wire from the positive LiIon battery terminal to the push-button circuit board on the other end of the flashlight. Alas, this would be a mechanical nightmare for the OP. A slot would need to be milled inside the body (which is sized for AA cells), an insulated wire inserted in the slot, and somehow the whole thing fixed in place with something... epoxy perhaps. Or, if the ID could be enlarged slightly, a plastic liner could perhaps be fitted and the wire embedded in the liner. For whatever reasons, the additional wire was deemed impossible to add. So someone proposed an alternative solution: an energy storage capacitor that is re-charged when the MOSFET is off and provides power to the PIC when the MOSFET is on. With the MOSFET on, it would be turned off for one millisecond approximately every one hundred milliseconds to keep the capacitor charged through the 330 ohm resistor. The human eye would not notice a one millisecond flicker every tenth of a second. Voila! Problem solved, just add some code.

From the get-go I was worried that interrupting power to the programmable LED mode controller, even for one millisecond, would have the effect of telling it to re-program. It is, after all, controlled by a microprocessor and those puppys respond quickly. I haven't heard from the OP for quite some time, so I don't know how his "Flashlight Project" turned out. I am tempted to order an LED controller board and see how it responds to millisecond interruptions of power. Perhaps the on-board microprocessor could be programmed to ignore such "glitches" or perhaps it already does ignore brief power interruptions by means of its own "hold-up" capacitor.

I am a newbie to this forum, but I would appreciate some advice on where to go from here. The PIC10F200 works as intended, sleeping most of the time, waking up for one millisecond every 135 milliseconds to recharge a one microfared energy storage capacitor. I am a retired electrical engineer with an electronics hobby. This will likely be my one and only adventure with flashlights.

73 de AC8NS
Hop
 
Last edited by a moderator:
Reviving this old thread because I have started work again on the Flashlight Project after some initial failures.

A separate "coin cell" of appropriate dimensions could work for the purpose of keeping the PIC micro-controller "powered up" and ready to control a MOSFET that would replace the "clicky switch," but I reject this approach, at least initially, because it adds a layer of complexity to a simple project: a programmable LED flashlight with a rechargeable lithium ion battery.

I recently regained contact with the OP who manufactures very high-end, high-quality, high-power LED flashlights. He sent me one of his flashlights so I could try out some ideas he has. He discovered a circuit that uses a CMOS flip-flop (which has very low power requirements), toggled by a dome-type (low current) push-button switch, to directly turn on a high-current MOSFET switch. No microprocessor required. The circuit would be powered by "leakage current" through a large-valued resistor installed in parallel with the LED controller. Unlike the PIC "solution" there is never any need to interrupt the MOSFET current, except to change flashlight modes by multiple quick presses of the dome switch. During the time the flashlight LED is OFF, i.e., most of the time, an energy-storage capacitor is recharged by the bypass current around the LED controller. The current requirements of the CMOS flip-flop plus the MOSFET are small... on the order of a few microamperes... so once the energy-storage capacitor is charged, it should be able to operate the MOSFET switch for many hours before enough charge is lost to turn the MOSFET off. Note that the energy-storage capacitor charges ONLY when the flashlight is OFF, so leaving the flashlight OFF will ensure it will be "ready to go" the next time it is turned ON.

At this point in time, I have removed two screws securing a pocket-clip to the flashlight. This exposed two threaded holes that allowed me to thread some silver-plated, Teflon-insulated, stranded hook-up wire through the holes. I soldered one end of each wire to the flashlight clicky switch, thereby placing these two wires in parallel with the switch.

My next step is to see if a suitable MOSFET can be driven to allow amperes of current to flow through the LED controller. This requires that I be able to send a finite train of a specific number of pulses to the MOSFET gate-source terminals to turn on the MOSFET and place the flashlight in high-intensity or so-called "turbo" mode. Once I have accomplished that task, my friend and I will know for certain whether a MOSFET can replace the functionality of the clicky-switch.

Assuming the results of the MOSFET current test are satisfactory, the next step is to configure the CMOS flip-flop and dome-switch to allow user-initiated LED driver mode changes. Assuming that works, the final step is to incorporate all this in the tail-end of the flashlight, replacing the clicky-switch with a circuit-board-mounted dome switch, the CMOS flip-flop, a power MOSFET, and a compression spring to make contact with the negative terminal of the battery.

I am getting older (79 if I make it to June 25, 2023), and my health is not a good as it used to be, but I try to find time (after doing the tasks in my wife's "honey do" jar) to work on this project. LEDs are becoming more powerful and I suspect that a MOSFET switch will soon be necessary for the latest generation of portable, battery-operated, LED flashlights and floodlights.

As a side note, building the logic that will allow a selectable number of pulses to be applied to the LED controller will also allow me to determine (with my bench digital storage oscilloscope or DSO) how short a period of time can to allocated between pulses without a mode change. I look forward to finding out that little factoid!

73 de AC8NS
Hop
 
Last edited:

Latest posts

Top