I wanted to see if I could get a little insight on how these mode switching flashlight circuits work. The ones I'm referring to are typically powered by a single lithium ion cell and control a 1W to 10W LED. They come in different variations, some a little more complex than others, but they usually aren't much more than a micro controller, a mosfet, a diode, and some resistors and capacitors.
I probed one of the more simple ones and tried to draw a schematic. The components shown as a dashed line were unpopulated. I believe everything is accurately laid out except for the PWM pin(s). Pin 3 of the micro controller drives the mosfet, but I'm also seeing the same 176Hz square wave on pin 2 even though it doesn't appear to be connected to anything.
What I'm most interested in is how this circuit switches modes (Hi-Med-Lo-Strobe-SOS). When the light is on, quickly switching it off and then back on again changes to the next mode. My theory is that the diode not only protects against reverse polarity, but it also allows the capacitor to only discharge back into Vcc of the micro when power is cut off. The capacitor is relatively large (1206 package), which indicated to me that it could have a high capacitance if the voltage rating is only 6.3 or 4 volts. It could be as much as 100uF. I was thinking that this would allow the micro to remain powered up while it reads the change in voltage on one of its other pins. The problem is, all the other pins appear to be floating.
I'm completely new to micro controllers, so I apologize if this is a dumb question, but is it possible that the Vcc pin itself is sensing the drop in voltage?
To follow up a little bit, I connected channel one of the oscilloscope to the Vcc pin and channel 2 to the main switch. When power is cut off, it looks like there's roughly 45 milliseconds before the voltage at Vcc drops below 1.8V. I think that disproves my little theory since the micro controller will often change modes after a full second has passed.
Well that's about all I got. If you can help shed a little light, I'd really appreciate it. At some point once I get the hang of things, I'd like to duplicate this circuit with an ATTINY45 and stick it in a modded flashlight.