Maker Pro
Maker Pro

Microcontroller controlled by pushbutton for LED flashlight

Sorry, had a ton of work to get caught up on today. Hopefully I can find some time tomorrow to do a voltage vs. current test on that driver. I can also experiment with the effect a paralleled resisitor has on the driver's operation. Any guestimate on the resistor value that would be needed, so I have a starting point?
 

KrisBlueNZ

Sadly passed away in 2015
Without doing any calculations, I'd suggest you try a 10 µF smoothing capacitor between VDD and 0V (to run the micro and provide gate bias for the MOSFET) and a resistor of around 33Ω. But you can't really test how the switching will affect the driver unless you have your PIC and your N-channel MOSFET to switch the current to the driver at regular intervals. Then you could measure the voltage across the driver's own reservoir capacitor to see how quickly it falls. But that will be affected by the type of LED used with the driver.

In other words, even if you can get everything working on your bench, some minor change by the driver board's manufacturer, or by the end user, could screw it up. This is why I've repeatedly warned you that you're probably relying too much on undocumented, undefined, and poorly controlled parameters of external components over which you have no control or influence, and that you could be getting yourself into an unwinnable future situation where your MOSFET-based switch board cannot be made to work.
 
I don't have the PIC or MOSFET here yet. I just wanted to experiment with this driver to find the lowest value resistor I can use that won't mess with the mode switching operation.
 

KrisBlueNZ

Sadly passed away in 2015
Just connecting a resistor across the LED driver won't cause a problem. It will just waste some power. It's only when you interrupt the power supply to the LED driver that the driver's operation will be affected. And then, it's not just the resistor value that will determine whether the micro in the LED driver resets or not.
 
OK, a couple more quick question... With a 33 ohm resistor in place, and a 3.7v cell installed, how long will it take to completely charge that 10uF cap? The reason I ask is that 33 ohm resistor will cut the run time by approximately 14%. Approximately how long would that 10uF cap be able to run the PIC and gate? Lastly, in the first version circuit you posted, what is the reason for having 2 caps across VSS and VDD? Couldn't the 10uF supercap do the job alone?
 

KrisBlueNZ

Sadly passed away in 2015
It would take about 2 ms to charge 10 µF from 0V practically all the way to the battery voltage. The capacitor wouldn't ever fully discharge though, so 1 ms would be a closer estimate.

If the PIC goes into sleep mode, its average current could be lower than 10 µA, using less than 50 µJ per second. The MOSFET gate, once charged, requires no current; its capacitance is around 5 nF so if charged from a PIC output with no gate resistor, it will charge in under 10 µs requiring less than 0.5 µJ so that's not significant compared to the PIC's load.

If we recharge the smoothing capacitor 10 times per second, at 10 µA load current and allowing for a 1V drop in VDD voltage every 100 ms, the reservoir capacitance only needs to be 1 µF.

If the resistor is increased from 33Ω to 330Ω a 1 µF reservoir will take about 1 ms to recharge and must be recharged every 100 ms. So the LED duty cycle would drop from 100% to 99%.

So here's my suggestion. Use 1 µF for the reservoir capacitor on your switch board, and use 330Ω across the LED driver to provide the top-up current for that reservoir capacitor. Have the PIC switch the MOSFET OFF for 1 ms every 100 ms. I believe that should work safely. My calculations have all been conservative.

I specified a separate decoupling capacitor (CD) and reservoir capacitor because I was thinking the reservoir capacitor would be a tantalum or aluminium electrolytic, which is not suitable for decoupling. But if the reservoir capacitor is only 1 µF you could easily use an X7R ceramic and CD wouldn't be needed.
 
Sorry, I'm confused. I thought we abandoned the idea of pulsing the MOSFET off to recharge the cap.

Edit: Approximately how long would a 10uF cap run the PIC with the MOSFET in the on state?
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
No, we haven't abandoned that idea. Without a separate feed from the battery, the only way to get voltage to charge the reservoir is by turning the MOSFET OFF periodically.

Assuming 10 µA current consumption (PIC in sleep state), and a maximum VDD voltage drop of 1V, with a 10 µF reservoir cap the PIC run time will be:
dT = C dV / I
= 10×10-6 × 1 / 10×10-6
= 1 second.

I don't think a supercap is the answer; too big and too expensive, and would take too long to charge.
 
OK, I would like to get all the parts ordered to build a couple protos. So, is the plan to use a Schottky or P channel MOSFET? What would be a good choice for the reservoir cap? Thanks!
 

KrisBlueNZ

Sadly passed away in 2015
272661.002.GIF
OK, here's an updated schematic. I removed the separate decoupling capacitor and specified the reservoir capacitor, CR, as 1 µF. It should be a multi-layer ceramic (MLCC) with X7R dielectric such as http://www.digikey.com/product-detail/en/C1608X7R1C105K080AC/445-1604-1-ND/634399.

The P-channel MOSFET idea won't work, I'm afraid, because of the MOSFET's body diode. With its drain connected to the reservoir capacitor and its source connected to the incoming voltage on WP1, the body diode will be pointing to the right, so each time the N-channel MOSFET turns ON, to energise the LED driver, it will discharge the reservoir capacitor! So I think a Schottky diode is the best bet.

I've added the charge resistor across the LED driver.

I didn't explain the "PPn" items. They represent pads or connection points for programming the PIC. They're numbered to match the IC pin numbers. As I said, I don't think you need separate pads for them; you can just make a jig using spring-loaded pins that make contact with the solder on the device's pins.
 
The PICKIT3 arrived today. The software that was included is MPLAB IDE V8.70, which according to Microchip's software archive page is rather old. There are newer versions of MPLAP IDE available, but only for 32 bit Windows. I am running 64 bit Windows 7. They seem to have done away with MPLAB IDE and are offering MPLAB X IDE, which is approximately 3x larger. Is this the software I need? Also, I noticed on the connector pinout that a 10k pullup resistor is place in between Vdd and Vpp. Is this something I need to incorporate into the switch board, the board I use to program, or not at all?
 
Last edited:

KrisBlueNZ

Sadly passed away in 2015
Yes, get MPLAB X.

You don't need that pullup resistor on your board as long as you enable the weak pullups on the GPIO port via the -GPPU bit in the PIC's configuration register.

The -MCLR/VPP pin is used during programming, but you can (and often do) configure the PIC to ignore it during operation, because the PIC includes a power-on reset and a brown-out circuit, so an external reset signal often isn't needed. The pin can even be used as a general purpose input pin (but not an output), if you're short on I/O, which you aren't in this case.

But it mustn't be left floating. That's why the weak pullup must be enabled. You'll want to enable the weak pullups on the GPIO port anyway so you can avoid an external pullup resistor for the pushbutton.

See section 5 of the PIC10F200 data sheet for details.
 

KrisBlueNZ

Sadly passed away in 2015
Hi again Jeff. I found a few more Schottky diodes with better specs than the ones I listed on the schematic. They have lower forward voltages, which will ensure maximum voltage on the reservoir, which means maximum gate bias for the MOSFET(s) and lowest ON-resistance. They're also a bit cheaper than the other suggestions, even with the addition of the zener (see below).

LSM115JE3 (Microsemi): http://www.digikey.com/product-detail/en/LSM115JE3/TR13/LSM115JE3/TR13CT-ND/1634547

VS-10BQ015-M3/5BT (Vishay): http://www.digikey.com/product-detail/en/VS-10BQ015-M3/5BT/VS-10BQ015-M3/5BTGICT-ND/4810669

PMEG2010EA (NXP): http://www.digikey.com/product-detail/en/PMEG2010EA,115/568-5035-1-ND/2209939

They're listed from best (and most expensive) to least expensive. Even the cheapest one will be very good.

They're rated for only 15~20V reverse voltage and could be damaged, so I suggest connecting a zener in parallel. Here's an updated schematic.

272661.003.GIF
 
OK, I'll get a couple of the Microsemi. Just curious - as we are using batteries as a power source, what conditions would expose the diode to a damaging level?
 

KrisBlueNZ

Sadly passed away in 2015
Handling - electrostatic discharge during installation, and changing the batteries if they're not rechargeable. Possibly. Maybe I'm being over-cautious. The junction capacitance of the diode will absorb a lot of energy but it's still possible for the diode to be damaged. Perhaps you should have a place for the zener but not install it, and see whether you have any returns.
 
All of the components arrived today. I have a PIC wired up and connected to the PICKIT3. I am able to communicate with the PIC with MPLAB IPE. I can read and erase, so I assume I'm connected properly. Where do we go from here?
 
I feared that something bad had happened to Kris and sadly found out today that he has passed away. Kris was a mentor to so many. I have all the components lined up on the bench with no clue what to do next. He was such a large part of this project that it feels wrong to continue without him. I had thanked Kris many times along the way and I just wanted to say thank you to every one else that took the time to help with this.
 

(*steve*)

¡sǝpodᴉʇuɐ ǝɥʇ ɹɐǝɥd
Moderator
I am sure that there are people here that will try to pick up from where Kris keft off.

I'll have a quick read through this thread and see if I can offer you some quick pointers. I will do my best to pick this up.
 
Top