AVR power control

Go To Last Post
34 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi Guys,

Some month ago i read anywhere here a thread on how to get an AVR switch itself off and with a switch on again. It was a circuit with 2 transistors (as far i can remember). But i can't find the Thread again. So please help me find that circuit again, or if you want to think about the following:

I want the ATMega to shutdown power with an I/O Port.
The Circuit is powered again when a switched is pressed.
Now the ATMega locks the power control so that the switch can be released.
The ATMega should be able to sense the state of the switch, to detect when it's pressed if running.
Would be Great if you find a solution with FET's ( Power Consumption is not more than 200mA)

Hava a look at my web page -> http://www.tobiscorner.at.tf

Last Edited: Mon. Sep 6, 2004 - 08:58 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could this work?

Attachment(s): 

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
This was my post; here is the circuit.

Attachment(s): 

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could you describe which signal is for doing what?

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Signals description:
BUT1, BUT2 go to power button with on-resistance <= 1K
(Battery voltage must be present on BUT1)
ON is active-high signal from AVR to keep circuit powered
PRS is active-low signal to AVR to detect power button press

Powering-on algorithm:
1. Press button.
2. CPU starts and performs necessary initializations
3. CPU waits for PRS signal to be high (button released) during at least 100-200ms (antibouncing)
4. CPU activates ON signal high
5. CPU activates a vector for low-level "power-off" interrupt fired by PRS signal
6. Main program starts

Powering-off algorithm:
1. Press button.
2. CPU executes "power-off" ISR in which performs necessary actions (saving smth, etc...)
3. Not leaving ISR, CPU waits for PRS signal to be high (button released) during at least 100-200ms (antibouncing)
4. CPU activates ON signal low

good luck!

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Great, thank you.

Do you think my circuit will work?

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Do you think my circuit will work?

Try it ! :) Imho, no. Your circuit is voltage repeater, not power switch. And the voltage you're going to repeat, will be taken from a divider R2D1R3. Wrong... To make a switch, use p-channel mosfet as in example, or pnp bipolar transistor, emitter (source) to input, collector(drain) to output.

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Micklecat, could one use a normal bipolar NPN transistor instead of Q10A ? Is there some reason for using a FET here?

Thanks in anticipation,

John Brown

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

btw, I forgot one step in power-on algorithm between steps 2 and 3:
2a. CPU waits for PRS signal to be low (button pressed) during at least 500ms. This must be done to prevent "accidental" power-on caused by unintentional short-time keypress or ESD.

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Micklecat, could one use a normal bipolar NPN transistor instead of Q10A ? Is there some reason for using a FET here?

I love mosfets :D The main reason is that IRF7309 has two mosfets in one SO-8 case

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

micklecat wrote:
I love mosfets :D The main reason is that IRF7309 has two mosfets in one SO-8 case

Thank you for that info, i think i will take your circuit!

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
The main reason is that IRF7309 has two mosfets in one SO-8 case

I thought that might be the case, one more point; when you say "BUT1, BUT2 go to power button", do you mean the BUT1 is one side of the switch and BUT2 is the other?

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Isn't it possible to connect BUT2 direct to an AVR Input?

Why didn't you use the SHDN Pin of the MAX1675 DC/DC Converter?

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

John_A_Brown wrote:
Quote:
The main reason is that IRF7309 has two mosfets in one SO-8 case

I thought that might be the case, one more point; when you say "BUT1, BUT2 go to power button", do you mean the BUT1 is one side of the switch and BUT2 is the other?

I think it's that way.

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Isn't it possible to connect BUT2 direct to an AVR Input?
Why didn't you use the SHDN Pin of the MAX1675 DC/DC Converter?

Yes I used SHDN pin, but it wasn't visible; it is connected to Q10A gate and pulled down to GND via 100K resistor.
Yes it is possible of course to connect BUT2 directly to AVR.
Power-on algorithm is not correct... AVR must hold ON high before releasing power button.

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've put your circuit in my new design. The best: it doesn't require more space. The two FET's are in a single SO8 Package and for the 2 diodes i took two Schottky Types in a single SOT23 Package. I've connected BUT2 directly to the AVR. So i hope this will work. Thank you, again.

Hava a look at my web page -> http://www.tobiscorner.at.tf

Last Edited: Wed. Sep 8, 2004 - 12:04 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

What are the implications of having BUT1 directly connected to the AVR? Doesn't this mean that the AVR port pin will be connected to Vcc momentarily before the chip has power? Also, although it may not be relevant in Floe's case, the original circuit should allow a voltage regulator AFTER the FET switch, I believe. Let's suppose you had a 12V battery, and a 5V regulator, you wouldn't want to connect the 12V directly to the AVR port pin. My only interest in this is that I currently use a similar system, but the Micklecat circuit has a couple of improvements.

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
What are the implications of having BUT1 directly connected to the AVR? Doesn't this mean that the AVR port pin will be connected to Vcc momentarily before the chip has power?

Thats' why I didn't do it; I followed my old habit - always protect inputs with transistor keys or in other way.
However, my circuit doesn't have overvoltage protection at all (this wasn't the task). If 12V appear on the battery, it will go not only to port pin, but thru MAX1675 body diode directly to VCC. Transistor key won't save my circuit, therefore, it isn't necessary.
If use linear regulator instead of 1675 - yes, transistor will provide protection for AVR input.

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Does in my casel 3.6V on a I/O Pin before VCC damage the AVR?
If yes i have to build the transistor into the circuit. Or does anybody know a simplier (less parts) solution?

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,

Quote:
Does in my casel 3.6V on a I/O Pin before VCC damage the AVR?

Nothing terrible will happen. AVR will be powered from io pin thru internal diode, just read the "IO ports" chapter in any AVR datasheet. Theoretically, AVR will begin work; even without VCC :)
If you want to protect pin from overvoltage, you can simply use a zener.
But if you want to feel completely safe, I'd recommend you to use transistor.

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Have you tested the circuit or is it untested? Will the FETs work with only 3V?

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Have you tested the circuit or is it untested? Will the FETs work with only 3V?

Yes. It is a commercial product.

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:o

Attachment(s): 

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Thank you ap9805411, but i'm gonna usr micklecat's circuit.

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Thank you ap9805411, but i'm gonna usr micklecat's circuit.

I'm going with the floe on this, Micklecat's circuit allows the power on switch to be used for other purposes. I have already used a circuit like ap9805411 (strange name!), but I don't like dedicating a switch to the power on function.

John Brown

Four legs good, two legs bad, three legs stable.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
...I don't like dedicating a switch to the power on function.

Exactly that's why i'm using Micklecat's circuit. It's seems to be secure enough for my application because of the Lion+ Pack the input voltage can't be higher than the Mega32L max operating volatge (during charging the volatge is 4.2V). Because i want to build a small MP3 Player i only want to use a ALPS Push & Lever Button. So i can use the Push contacts for powering ON & OFF and for selecting menu items.

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
because of the Lion+ Pack the input voltage can't be higher than the Mega32L max operating volatge (during charging the volatge is 4.2V).

Hi,
I didn't quite catch what did you mean by saying this, but just in case: remember that max1675 has internal diode. If input voltage will be higher than output voltage (3,3V) - it will go thru diode directly to output. If you use linear regulator instead - everything OK.

Cats never lie. At least, they do this rarely.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

How about a single-chip device from Microchip?
http://ww1.microchip.com/downloads/en/DeviceDoc/21350c.pdf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'm not using the DC/DC Converter. My Inputvolatge is max 4.2V and at this voltage the Mega-L series works fine. I do not need a voltage regulator, just need the power on/off circuit.

Hava a look at my web page -> http://www.tobiscorner.at.tf

Last Edited: Fri. Sep 10, 2004 - 06:28 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You can just apply the one of:
TC1054, TC1055 ... TC1186 from Microchip in very small 5-pin SOT23-A package.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

micklecat, i've got a problem with your circuit...
Today i got my PCB and assembled the parts. But the circuit is always powered! If the Gate of the N-Channel FET (Pin 2) is ground the upper P-Channel FET does not close completly. So I got a VCC that is about 600mV lower than the input voltage. If the Power Button is pressed VCC goes up to the Input Voltage with about >10mV Voltage loss. The only change i made was that i used a 10k resistor instead of the 100k resistor. Please help me...

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theFloe wrote:
micklecat, i've got a problem with your circuit...
Today i got my PCB and assembled the parts. But the circuit is always powered! If the Gate of the N-Channel FET (Pin 2) is ground the upper P-Channel FET does not close completly. So I got a VCC that is about 600mV lower than the input voltage. If the Power Button is pressed VCC goes up to the Input Voltage with about >10mV Voltage loss. The only change i made was that i used a 10k resistor instead of the 100k resistor. Please help me...

I think I know what is wrong with your circuit, I made a similar circuit a year ago, which by the way works fine.

Q10B has to be mounted "the wrong way" in the schematic, you should switch the Source and the Drain to make it able to turn off.
The reason is that all MOSFET's has an internal reverse voltage protection diode inside.
The diode is placed from Drain to Source, so if you place the MOSFET the way you would normally place a MOSFET, the diode wil always conduct when the MOSFET is turned off.
This means that the VCC voltage will be about 0.6V below the battery voltage because of the diode forward voltage drop.

Please check that the Q10B Source is connected to the battery and Q10B Drain is connected to the microcontroller's VCC.

VCC in micklecat's schematic is connected to the Drain and is the pin that should be connected to the microcontroller's VCC.

It's also important to mount R28 from the Q10B's gate-source to prevent the gate from floating when Q10A is turned off.

The protection diode from Drain to Source is mounted in all MOSFET's, eventhough it is not shown in all MOSFET datasheets. You can confirm this by using a multimeter to do a diode test between Drain and Source of any MOSFET.
Remember the diode is of course reversed on a P-channel MOSFET compared to a N-Channel.

When you make a circuit like this, you should remember always to use "Logic-level" MOSFET's. Normal MOSFET's has too high Gate threshold level to turn on properly at such low voltages.
But the IRF7309 shwon in the schematic should work fine, because the Gate Threshold Voltage is only 1.0V.

Last Edited: Fri. Sep 24, 2004 - 10:52 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

You're right... i mixed Drain & Source... Thankx...

Hava a look at my web page -> http://www.tobiscorner.at.tf

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

:D
if that circuit wasn't working, I'd already die from starvation 2 yrs ago :wink:

Cats never lie. At least, they do this rarely.