Powering off an 08M under software control

pjrebordao

Senior Member
In one of my current projects, I'm trying to implement a simple circuit to enable an 08M to power itself off.
My limited electronics experience and expertise has led me to believe that a simple setup involving a Darlington could do the trick, but so far it failed to do so...

Looking at the attached circuit, I'll explain my idea:

Pressing the S1 pushbutton would start the 08M, it's first line of code would be "high 4", thus "turning on" the Darlington and ensuring that power is present at VDD, even after the button is released. In practice, as soon as you release the button, the 08M stops...

Can anyone give me a clue on what's going on ?
 

Attachments

kranenborg

Senior Member
The idea and the circuit look OK, but I think that the voltage drop over the Darlington (Collector-Emitter) is significant (approx. 0.7V, as happens with any ordinary bipolar transistor) and may cause the effective Vcc as seen by the picaxe be lower. This happens exactly when lifting the switch. For an 08M with brown-out detection enabled this might give a problem as the Vcc may get below the brownout voltage, causing it to shut down. What is is battery voltage here?

Two options then (if the above analysis is right):
* Use a mosfet with very low gate threshold voltage as well as low R_DSon (BS170 is a well known example), you may get a lower voltage drop
* Remove the brownout detection at the 08M using DISABLEBOD as first command, this allows a much lower Vcc. Note that early 08Ms do not have this command and have brownout continuously enabled.

Option 1 is probably the best, but option 2 is interesting for quick testing as the circuit does not need to be changed. Still, I would turn to the mosfet eventually.

A different cause of problems may be the lack of a capacitor near the Vcc pin; the rapid Vcc voltage drop when releasing the button may cause problems too, causing the 08M to stop. Try a 0.1 uF first, increase to 1uF if the problem persists.

Hope that this gives a direction for further research ...

Regards,
Jurjen
 
Last edited:

pjrebordao

Senior Member
Jurjen, I'm using 4xAA cells for the supply. After reading your post, I went and measured a difference of about 0.5V between the supply coming from the cells and the one coming from the darlington, so that may be the cause...
I tried Disablebod at the start but made no difference, so I might really go the mosfet way.
Also, when you mention the lack of a capacitor, should it be between Vcc and ground ?

Regards,
Paulo
 
Last edited:

Peter M

Senior Member
If your using 4 fresh AA alkaline your supply could be as high as 6.5volts...
Far too high for a picaxe chip try 3xAA's or put 2 series diodes (1n4004 or equiv. (0.6v ea)) in line with the power switch and 1 in series with the transistor.
This will make the voltage closer when the switch is opened.

Also as above you need a capacitor, a 0.1uf to decouple noise and possibly the addition of 10-100uf to help smooth the transistion of voltage when the switch is opened (yes between +ve and 0v as close to the picaxe power pins as practical).

Mosfets are better for this job, as stated earlier.
 
Last edited:

Dippy

Moderator
I'll be interested to see how this goes as I have yet to see a single transistor solution to this.

KMoffett: Well done for all those links, you must have had a loooong coffee break.

@pj: Why not just go with the known solutions? I suspect all those have been produced by people who were trying to get the one-transistor solution. I know at least one was, because it was me.
 

pjrebordao

Senior Member
Dippy, I made some searches beforehand and did come up with those solutions involving Mosfets (notably by KMoffett), but for this project I was really striving for the lowest parts count, and also I couldn't understand why the transistor approach wouldn't work...
Now I know, nothing like a failure to teach you something.
 

KMoffett

Senior Member
Dippy,

Most of those links I had some involvement in, so it was a short coffee break. :) I thought of a single mosfet low-side switch but never tried it. Not sure if there is current path from Battery+ to Battery- through Vdd, P1, R1, with the power off. ???

Ken
 

Attachments

Last edited:

KMoffett

Senior Member
Dippy,

OK, break time's over!

08M's +V (#1) to +4.5V, 100K resistor (shunted by DMM) from ground to each of the open pins, one at a time:
#8: 3.26V
#7-#2: 2.85V

With the circuit in my schematic, there is 2.32V Vds when power is applied...so my conclusion is the mosfet will not completely turn off, so back to the two transistor solution. :(

Ken
 

KMoffett

Senior Member
Yup, two Mosfets or BPJ transistors or one of each. It seems like the only answer. But...there may be a flash of genius out there. ;)

Ken
 

sghioto

Senior Member
Ok, then one might use an analog switch such as a FSA4157 or equivalent. On resistance is 1 ohm and standby current is .1 ua, no resistors needed.



Steve Ghioto
 
Last edited:

sghioto

Senior Member
Dippy,

Yes it does work. I did verify operation before posting the schematic.

Only problem one might have is the packaging. SC70 style case, very small surface mount device.

Steve Ghioto
 

MPep

Senior Member
Hi all,

I am wondering out loud here, but using a NPN Darlington with the PICAXE as the emitter load, with the base being driven by the PICAXE is just asking for trouble.
Reason being that the PIX would need to drive the base about 1.2 - 1.4 V higher than the Vcc of the PIX.

What about using a PNP transistor, with the base held high via a resistor. This switches it off.
Then have a PIX output drive LOW the base connection, via a suitable resistor, to turn it ON.

NOTE : I have used PIX instead of PICAXE, quicker to type.
Also, I has not tested the idea described here.

Actually, using the NPN Darlington could work if you PWM'd into a charge-pump, creating a higher voltage. Again, this has not been tried by me.
 

moxhamj

New Member
Does it matter if it doesn't turn off? Sleep and disablebod decrease the current down to lower than the self discharge rate of batteries. What is the application?
 

Tom2000

Senior Member
Perhaps there's a loophole that might make a low side single-device switch possible in certain cases.

For systems that don't connect to the outside world, you could derive a system zero volt bus that floats above ground. You could switch this bus to ground with a single BJT or MOSFET. All other devices in the circuit would use the 0V bus as their ground.

The 5 volt supply would be referenced to Gnd.

I've attached a sketch.

Tom
 

Attachments

KMoffett

Senior Member
Tom2000,
This will not work. Refer back to my posts on the 22nd. I tried it. There is a leakage path from Vdd through the I/O pin to your mosfet's gate, when you try to open the VSS pin. It won't turn off.
Ken
 

Tom2000

Senior Member
Tom2000,
This will not work. Refer back to my posts on the 22nd. I tried it. There is a leakage path from Vdd through the I/O pin to your mosfet's gate, when you try to open the VSS pin. It won't turn off.
Ken
Ken,

I missed your post while I was skimming this thread.

For the life of me, I don't know why your 2N7000 circuit doesn't work. I guess, rather than switching the output pin from a 1 to a 0, you'd have to switch it between an output and an input.

I'll have to fiddle with it in the morning, when I'm awake.

Thanks,

Tom
 

KMoffett

Senior Member
Tom,

The problem comes when you try to disconnect the ground from the Picaxe. The Picaxe can no longer pull the transistor's gate to ground to shut it off. The resistor was supposed to do that. But, I discovered that there is a leakage(?) path from the I/O pin that partially turns on the transistor, defeating the whole purpose. I'm interested to see if you find the same thing.

Ken
 

gengis

New Member
Back in reply #15 eclectic gave you a good pointer. The microchip site has a good idea in tip number 11. Downside is they say it turns off if you put it to sleep - but I think I'd look for something similar to their idea. (I haven't had a lot of success running 2N7000's from LV supplies - specifications are harder to deal with than just go-no go statements)


http://ww1.microchip.com/downloads/en/devicedoc/40040b.pdf


You could always use a joule thief to supply the mosfet and use the picaxe to turn it off. I think Dr Acula was mentioning something like this in one of his posts.
 

moxhamj

New Member
There are some circuits that just take a long time to build. Lots of ideas on this one work in theory. Then come the leakage paths and chips not really being off as one of their power pins is still connected (it probably doesn't matter if it is the ground or the power pin - to be off then both really need to be disconnected). I'm not sure how picaxes behave when one of their power pins is connected and volts are fed into another pin.

One sure fire way to turn off a picaxe is to use a 5V latching relay with SPDT contacts. Use a cap eg 1000uF on the power supply of the picaxe so there is enough energy to move the relay contacts as it is disconnecting its own power supply. I picked up a whole lot of latching relays once when they were on special from Rockbys - only $1 each though ususally they are $4 or so. Disconnect both the power and the ground to the picaxe.
 
You would think that the combined brain power here would have produced an answer by now. I am also intreigued to find a solution because I would like this feature in a project I am working on. I had not given this part any thought, expecting it would be easy.

Perhaps the answer is all around each and every one of us in the computer. You push the power button and the computer comes on. Press it again, and it will go off (or ask you what to do!). You can also turn off your computer through the start menu. There may be some information about this in the documentaion of the computer. I shall check...

If all else fails, then the last resort could be to ditch the idea of using transistors, etc, and make it more mechanical. You could push a switch down, which latches with the pin of solenoid. To turn the power off, set outputX high, causing the solenoid to retract, releasing the switch, cutting off power to the entire circuit, and the solenoid automatically resets.
Yes, I know it is crude, but it would work!
 

BCJKiwi

Senior Member
I've tried the Microchip circuit on a 14M.
At this stage it does not latch on. It runs as long as the switch is on.

I'm using BAT85 diodes and the only N-Channel Mosfet I have which is an MTP3055E.
What I don't know is the optimum values for either of the Rs or Cs, can anyone oblige please.

The circuit is powered off 3 batteries and the gate voltage is around 9V when the switch is closed but immediately drops to VBatt and stays there.

Code:
#picaxe 14M
pwmout 2,0,1  '2Mhz 50% duty cycle oscillator for charge pump
high 3    'LED to monitor timing
pause 35000   '35 secs - 1000 ~ 1 sec
sleep 15   '35 secs - 1 ~ 2.3 secs
 
Last edited:

moxhamj

New Member
BJCKiwi - is this a voltage doubler circuit you mean? I've just built one using a 555 where it had 1k between pin 8 and 7, 100k between 7 and 6, C=0.01uF giving a square wave of 1khz. You could do the same thing on a picaxe of course, but a 555 can source/sink 200mA and a picaxe only 20mA. Charge transfer caps were 10uF.
 

Dippy

Moderator
ComicSoftware: "Yes, I know it is crude, but it would work!"
- yup, ideal for a micropower circuit.

And, let's be honest. If Microchip people, who may have an inkling about electronics, can't do it then what chance have we.

And as for that Charge pump style Microchip circuit. That takes more space than a couple of SMD transistors/resistors AND may waste a PWM output too.
Just give in to the force....
 

KMoffett

Senior Member
Cosmic Software.

It's been done before and posted. Attached circuit is Push-On/Push-Off/Program-Off.
Works every time. Zero power when off. No leakage paths. The big challange seems to be to do it with one transistor, mosfet, or small IC. :D

Ken
 

Attachments

BCJKiwi

Senior Member
Have the Microchip circuit working.

Code:
#PICAXE 14M
pwmout 2,249,500      '4kHz oscillator for charge pump
high 3                'LED to monitor timing
pause 35000        '35 secs - 1000 ~ 1 sec
sleep 15           '35 secs - 1 ~ 2.3 secs
Using a pwmout to test with but as indicated on the Microchip tip #11 any pin that oscillates will do.

The R/C on the pwmout is 390R/1uF, the Diodes are both BAT85s, the filter cap is 0.01uF and the bleed resistor is 100k and the N-Channel FET is an MTP3055E.

The gate voltage is around 8V with a 4.8VBat. total circuit current 9.5 mA

There is no measurable current from the battery supply (even the uA scale on the multimeter shows 0.00) once the sleep command is issued as the trick here seems to be that once the sleep command is issued the pwm stops so there is no drive to the gate. So this is not a low power mode but a true off - the sleep command being used to stop the oscillator, rather than changing to a low power mode.

The initial trial attempted to use high frequency and low C values.
After the Drs input, switched to higher C and lower frequency which did give higher gate voltage but the final key was the higher bleed R.

Am sure smaller C values could be achieved with higher frequency as that is the basis of Maxims charge pumps in the the max232 and dc-dc boost converters.
 
Last edited:

Dippy

Moderator
BCJ,

So does this man the m'chip circuit uses a lot more power when 'on' ?

Can you tell me the real benefits over a 2 transistor + coupla resistors circuit?
(Cost? PCB space thru-hole/smd? On-state current?)

I'm not really surprised there is b-all current as you've switched the FET off.

And this MTP3055E "NPN FET", is this a new device?
 
OK, I am not as tired as when I posted my last post, so my new idea ought to be better.

Why not create a small bistable with a 555 timer chip. The trigger switch (pin 2) could be used to turn it on, and the reset switch (pin 4) could be replaced with a picaxe output pin, and set high to reset. The picaxe could be powered through a transistor from pin 3.

I do not have time to draw a diagram, but this is something similar that I found on google. I have not given any thought to how you would power the 555, but that should be easy to resolve, just by tapping into pin 3, and connecting it to a relay or another transistor.



I will give this a go later if I can find time.
 
Last edited:

hippy

Technical Support
Staff member
If going for an external chip/transistor/FET solution, one should also consider a PICmicro / PICAXE. An extension to having the main PICAXE power off, the main PICAXE can be powered from one ( or more ) of the power-control PIC; 25mA per pin, 100mA max with four pins.

Such a power-controller can spend most of its time asleep drawing uA's, waking up only to see if the 'on' button is pushed. It can also be configured to turn off if not kicked by the master or under master control. In fact, it can be programmed to behave exactly as required; checking frequently for a button push to come back on after being turned off, checking less frequently after a while to minimise battery drain when in storage. It would even be able to monitor battery voltage so it can cleanly switch power and avoid corruption in the master PICAXE.

The advantage of a second PIC/PICAXE approach is that there's very little change needed to the main PICAXE software and no need about how to design that to achieve lowest consumption. Careful / correct design only needs to apply to the power control itself which greatly simplifies the overall design. On top of that, it works for everything ( up to 100mA ), not just PICAXE's. A spare 08M is often easier to find than other components which have to be sourced separately.

One current saving tip - By putting a LED+R on an output pin, and the top of the LED back to an ADC, there's be no wasted current drain until the PIC/PICAXE powered up that pin, measured the battery voltage.

I don't have the equipment to measure below 1mA but it would be nice to see someone do this as a project. I wouldn't think it would be that hard.
 

Dippy

Moderator
Mmmm... isn't this all getting a bit complicated/expensive for what was a simple 2 transistor design, which if using FETs, would consume only fractions of uA in 'OFF' mode?

A 555 idea I'm sure would work but it's quiescent consumption when 'off' doesn't lend itself to micropower battery powered devices. Ditto a PIC.

I'm sure both these ideas will achieve what you want, but I'd just like someone to explain the point?

In addition, if you are designing a little device which takes a PP3 + regulator you can have the 2-Tran (was that a precursor of a well know programming language) BEFORE the regulator. Why a PP3? Well some of these little handheld boxes take them. That rules out the PIC approach.

There didn't seem to be many positive comments on the idea using the solid state switch a while back from Steve.

And, of course, with the transistor approach you will have a lot of options on load capacity.
 
Last edited:

Tom2000

Senior Member
This is getting out of hand. Here's a simpler approach.

If you need external components to power down your Picaxe, you might as well use components that are going to be of some use to you, not just dead weight.

One way to do this is to incorporate a 5 volt LDO regulator equipped with an enable pin, such as the Sharp PQ050RDA1SZH. You need an LDO regulator in your battery-powered circuit in any case. You might as well use it as a power switch, too.

I've attached a sketch to propose how this might be accomplished. A pushbuttton between the enable pin and battery +V bootstraps the regulator on. A Picaxe output going high shortly after the program starts holds the enable pin high.

To power down, send a low to the enable pin.

Tom
 

Attachments

Dippy

Moderator
True Tom, but that method still uses a helluva lot more 'OFF' power than the 2-tran method. Significant in micropower circuits with small bats. But that's a handy regulator to know about nonetheless. H 4 Cs.

Have you tried it to make sure it works under all conditions? (Transients / Sleep watchdog etc.)

I think there's quite a lot of info here for the constructor to take his/her pick. Unless someone's got something refreshing then it's almost time to put this to bed.

PLEASE NO MORE "I haven't tried this but I'm sure it'll work" circuits !!! :)
 
Last edited:

BCJKiwi

Senior Member
Dippy,
My post was intended to confirm the viability of the Microchip circuit and to provide a working example as the Microchip circuit did not have any values.

So does this man the m'chip circuit uses a lot more power when 'on' ?
Most of the current reported was going to the monitor LED

Can you tell me the real benefits over a 2 transistor + coupla resistors circuit?
(Cost? PCB space thru-hole/smd? On-state current?)
I'll leave that up to you to decide. I'm sure there are plenty of small/smd component options for the Microchip circuit as well.
Ken's two transistor circuit has 2 transistors, 3 resistors and 1 cap and uses an output.
The Microchip circuit has 1 transistor, 2 resistors and 2 caps and uses an oscillating output, which, as microchip point out, could be 'free' if using a chip with external oscillator capability which is not being used.

I'm not really surprised there is b-all current as you've switched the FET off.
Agreed. Others had suggested that the Microchip circuit would consume current as the PICAXE was in sleep mode. Just confirming that the PICAXE is actually off.

And this MTP3055E "NPN FET", is this a new device?
Sorry, it was late when I wrote this up - the FET is an N-channel of course, not an NPN transistor.

Tom,
Agree that the regulator with on/off is simple and elegant when you need a regulator but many have been asking for the 1 transistor circuit for battery operated systems - i.e. no regulator.
 
Last edited:

Tom2000

Senior Member
Sorry Tom, I must be going daft, where do you get 0.5uA OFF current in the Data Sheet?
Dippy, I found that right at the top of the data sheet, in the Features section:

3.Low dissipation current
(Dissipation current at no load: MAX. 8mA
Output OFF-state dissipation current: MAX.5μA)
Tom
 
Top