Maker Pro
Maker Pro

Microcontroller controlled by pushbutton for LED flashlight

Thankyou Steve. Yes sorry my bad, I should have explained what I wanted. Sorry Jeff. Thing is not knowing what level someone is at which could lead to someone feeling like they being treated like a child. I am aware of this so maybe I assume too much.
Adam
 
Here is my circuit diagram. I know it's a bit different to yours. I just have it powered all the time and I am driving an LED so I can see what is happening. And my port GPIO,0 is different as we know. The may help in understanding why it's not working. When I have time I'll make a small modification where I will take a link from T1 collector and connect it to the anode of SD1 and move the MCLR pull up power +V line to the cathode of SD1 . This should then allow the PIC to run from the capacitor. and a link to the circuit working. The first part is me pressing switch on and off before 500 ms and then pressing for longer so it remains on. You can't see the cap charge pulses they are too short. I then turn it off.


Thanks
Adam

FLASH_LIGHT_SCH.PNG
 
Last edited:
I would like to request a couple of changes to the design before this gets wrapped up. These changes will probably occur anyway for different reasons, but here are mine:
1) The Schottkey diode absolutely needs to be substituted. The one I purchased (http://www.digikey.com/product-detail/en/0/LSM115JE3/TR13CT-ND) is huge and won't fit on a 14mm round board. Also, it is taller than the switch and will interfere with it it's actuation.
2) I know we have all discussed changing to a larger capacitor for electrical reasons, but I would like to go larger for mechanical reasons also. The one I have (http://www.digikey.com/product-detail/en/0/445-1604-1-ND) is so tiny that I have trouble working with it, even under magnification. I would welcome a larger footprint.

That's it. I know you all started to cringe when you read the first sentence. Sorry about that. :)

I know there's a few reasons that my circuit is not behaving the same as Adam's. One certain possibility is that I screwed up the asm file while editing it. Another thing I just thought of is the posiblility of the files ending up slightly altered after the zip/unzip process. If you think this could happen, we could exchange raw, uncompressed files via email instead...
 
Design changes no problem. Are you thinking of making several of these? If so I will produce a manufacturing standard PCB for you if that's ok. With silk screen and solder resist and a proper connector so you can program it. I think the issue with the circuit is just the capacitor can't sup enough current for the circuit. I propose a design change where we use a larger value capacitor and I actually switch the power to charge this through another transistor. We wont be limited by size then as the transistor within reason will charge any size almost instantly so you won't notice any flicker from the LED module.
Adam
 
Where will the transistor get it's (+) supply from when the MOSFET is on and there is no potential across it? If your still planning on pulsing the LED off to charge, won't the 330 ohm resistor limit the charge rate?
 
In your circuit you built you didn't have the 330R installed I guessed this was a maybe component. I'll take the feed from the battery where the 330R connects. The transistor will turn on a short while after when the MOSFET turns off.
Adam
 
The 330 ohm resistor is built into the LED driver, not mounted on the board. The electronic switch will have no access to the (+) bat terminal, as it is at the other end of the flashlight.
 
The 330 ohm resistor is built into the LED driver, not mounted on the board. The electronic switch will have no access to the (+) bat terminal, as it is at the other end of the flashlight.
Oh ok I thought this was something Kris added. Can we change this value ? The above circuit won't make any difference then sorry.

Edit. Ah hang on, the 300R is parallel to the unit. It might work if the unit can supply enough current through itself when switched off.
 
The resistor value can be increased, but not decreased, as it is already making a significant impact on the run time of the battery. In your latest drawing, LED1 does not exist. In it's place is an LED driver, that powers the LED's. The driver (as seen in post 55) has a PIC and MOSFET's in it also. The LED's are out of the circuit when power to the driver is cut. We have already determined that the light engine itself is incapable of supplying enough current to keep the cap charged, so the 330 ohm resistor was added in parallel (post 60 explains this).
 
Ok so it will work. The additional transistor will be off and only when the original Mosfet turns off will it turn on. Only long enough to charge the cap which could be only a few micro seconds. It will then switch off and won't add additional drain to the circuit.

I am off for a few hours now might catch you later :)
Adam
 
Kris had already considered charging the cap with a P channel MOSFET instead of the diode, but the idea was abandoned (idea was suggested in post 60, abandoned in post 70).
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I'm going to have to take another look at the circuit and the specs for the PIC to try to reproduce Kris' calculations.

Adam, have you set all the magic bits in the PIC to turn off the brownout detection? -- this will allow the device to operate from a lower voltage (with some risk...)
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
The resistor value can be increased, but not decreased, as it is already making a significant impact on the run time of the battery.

Can you explain that? I assume the LED draws significant current and the amount going through the resistor should be a tiny fraction of that.
 
Can you explain that? I assume the LED draws significant current and the amount going through the resistor should be a tiny fraction of that.

Originally, Kris wanted to use a 33 ohm charge resistor. I calculated this to cause a 14% decrease in battery run time if the flashlight was operated at medium level, which would be completely unacceptable. He then changed that value to 330 ohm, which drops that to under 2%, which is much better. I think I can get away with telling customers that this switch impacts run time less that 2%. If this number gets larger, I will have a hard time selling it.
 
Are you thinking of making several of these? If so I will produce a manufacturing standard PCB for you if that's ok.

If we can get this circuit working without any glitches throughout the entire useful range of a Li-Mg battery (2.8v - 4.2v), I will probably start with making 100 of them.
 
I'm going to have to take another look at the circuit and the specs for the PIC to try to reproduce Kris' calculations.

Adam, have you set all the magic bits in the PIC to turn off the brownout detection? -- this will allow the device to operate from a lower voltage (with some risk...)
Hi Steve. I have not touched the brownout, I'll take a look.
Adam
 
Sorry I didnt get time today to look at this. Been busy decorating. Now having a few Ciders again. Still got a lot to do so might try tommorow.
Ads
 
Top