Supplying power to the PIC12F508 through a transistor.

I'm trying to supply power to a PIC12F508 via a transistor, so it can turn itself off once it has finished working to save power.

The Idea is for the push button to supply power to the chip, which sets GPIO5 high on power up, so turns on the transistor, allowing power to continue flowing to the chip after the button is released.

The PIC turns on correctly when the button is pressed, but will not remain on, despite power being supplied to the transistor from GPIO5.

Another possible issue is that while the chip works properly, it continues to put a high on GPIO4, lighting the LED while VSS is disconnected.

I have checked that the code functions correctly, and have tested this without the additional lines from the programmer.

Any suggestions would be appreciated.

Picture of Supplying power to the PIC12F508 through a transistor.
sort by: active | newest | oldest
gmoon6 years ago
Like a lot of uC's, this PIC has a "sleep mode," which only draws 0.1 uA (microAmp, not milliamp). They can be configured to wake on I/O.

Seems like a simple (better) solution.
The Skinnerz (author)  gmoon6 years ago
I think it is probably easier to just use a normal switch, and put it into sleep mode, seeing as the battery should be good for nearly 40 hours on full power.

I'm going to have another go at putting a transistor in first, even if it is just something to learn from.

Thanks to everyone for all the help so far.
I think you need to use a PNP transistor here. When the micro is running, VDD will be at 5V. The output on the GPIO will be no greater than this, so I cant see how you would get any base current to flow through the NPN transistor to turn it on so that the micro can operate after the switch is released. Thats the problem with using an NPN transisor (or N channel FET) as a high side switch, without additional drive circuitry)

I would use a PNP transitor, with the emitter connected to the 5V supply, and the collector connected to the VDD pin of the micro. Connect a resistor (say 10k) from the base back to 5V, to pull it up so as to keep it off when it should be off. Then connect the base to your GPIO via a resistor, say 1k.

Once the micro is up and running (before the button is released) set the GPIO low, which will let current flow through the base of the transistor to turn it on so that it can be the pathway for the power once the button is released. When everything is done, set the GPIO high, which will turn off the base current and let everything power off.

I hope that made sense. Let me know how it turns out.
Good Luck!
The Skinnerz (author)  LargeMouthBass6 years ago
I have set it up as you suggested, and it will turn on and off, depending on the voltage applied to the base. However, the I/O pin appears to still be able to sink current while the device is off, so the base voltage drops, and the transistor turns on.

What about using an NPN transistor on the VSS side?
One quick thing to try would be a smaller resistor value for the pull up to 5V used on the base (try 1k instead of the 10k that I suggested earlier). This would pull the transistor up more firmly, so it would be less likely to be turned on by any leakage through the IO pin. At the same time, use a higher value resistor from the micro output to the base (mayabe 5k or 10k instead of the 1k that I suggested earlier. This would limit the amount of leakage current through the IO pin, when the micro is powered off, but should still let enough current flow through the base of the PNP to turn it on when you want it on.

If that quick fix doesn't work, I'll need to scratch my head a bit more...
The Skinnerz (author)  LargeMouthBass6 years ago
Tried varying the resistance between the base and the I/O, with 1k between the base and +5V. At about 50K it stops tuning on without the button, but will not stay on when released.

I'm going to try putting an NPN on the VSS side.
Use a MOSfet instead - effectively zero leakage when its off.