Author Topic: Push button to power ON controller  (Read 1795 times)

0 Members and 1 Guest are viewing this topic.

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Push button to power ON controller
« on: November 30, 2020, 01:33:22 pm »
Hi everyone!
Please see the attached schematic and give me suggestion if i can improve it. I am new in electronics, and i do not thing what i made is the best design-it is working but....it is using too much components. Can i do it with less elements without losing the efficiency.
What it is doing: Powers on a MCU with one of the Push buttons(SW1 or SW2 or J1) and Latching it(with D2 Output), and returning the status of the buttons to the MCU trough   A2 and A3 inputs. Button J1 is optional to start the MCU without latching.
Thank you in advance
« Last Edit: December 02, 2020, 07:17:22 am by HackerMy »
 

Offline bson

  • Supporter
  • ****
  • Posts: 2429
  • Country: us
Re: Push button to power ON controller
« Reply #1 on: November 30, 2020, 08:02:03 pm »
Why not use the deep sleep of the µC instead of this latching business?  On power on, go straight to deep sleep.  Connect the buttons to the wake pin(s) and/or GPIO ports to read them (depending on the µC).  This way all you need is a few pullups.  Deglitching is easily handled in software.
 

Offline homebrew

  • Frequent Contributor
  • **
  • Posts: 293
  • Country: ch
Re: Push button to power ON controller
« Reply #2 on: November 30, 2020, 08:51:15 pm »
Does this really work as is?

I would imagine that the uC would be powered through the pull up resistors R6, R10 constantly ...
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #3 on: November 30, 2020, 10:41:10 pm »
Yes it is working right now on a breadboard. The MCU doesn't get power from those resistors. When i measure the consummation in OFF mode is less then 0.1uA(according to my multi meter).
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #4 on: November 30, 2020, 10:51:03 pm »
Honestly i have no idea why(may be security reasons...) but one of the points in the project is to cut off the power to the device. The easiest way to do so is to add an power switch button, but there is no place to add it. So i am forced to do this external stupidity to make it happen. This is one of the projects where they design the device before making the control for it. Now i am adding the control and i have to compensate the bad mechanical design...
« Last Edit: November 30, 2020, 10:55:31 pm by HackerMy »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2138
  • Country: us
Re: Push button to power ON controller
« Reply #5 on: November 30, 2020, 11:56:16 pm »
The pullup resistors on A2 and A3 should be connected to Vcc, not Vcc_5.  Or you can configure A2 and A3 as INPUT_PULLUP, and do away with those resistors entirely.

I'm not sure how D2 and J1 work. If you press that button, the diode will block the 5V from D2, so it seems D2 will always read low.  So is your software reading A2 and A3, and if both are high it concludes J1 must have been pressed?  If so, you don't ever need to read D2, so you don't need R5.  The transistor will stay off unless there is actual current flowing through the base.  You don't need to bias it low. (Others may disagree.)

Also, you need to disconnect VCC_5 from pin 1 of the processor.  You can't have any connection from Vcc_5 to the processor, or it will back-power the processor through the protection diodes when the mosfet is off.
 
« Last Edit: December 01, 2020, 12:00:57 am by Peabody »
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #6 on: December 01, 2020, 12:44:36 am »
The pullup resistors on A2 and A3 should be connected to Vcc, not Vcc_5.  Or you can configure A2 and A3 as INPUT_PULLUP, and do away with those resistors entirely.

When i connect them to Vcc the PFET is ON all the time, but i will try to use the internal PULLUP resistors on the inputs and eliminate R6 and R10-thanks! DONE! R6 and R10 are gone. With internal PULLUP resistors is working. Thanks again!
Quote
I'm not sure how D2 and J1 work. If you press that button, the diode will block the 5V from D2, so it seems D2 will always read low.  So is your software reading A2 and A3, and if both are high it concludes J1 must have been pressed?  If so, you don't ever need to read D2, so you don't need R5.  The transistor will stay off unless there is actual current flowing through the base.  You don't need to bias it low. (Others may disagree.)
D2 is an OUTPUT when it is HIGH it keeps the transistor on. J1 is optional. If J1 will be used, D2 has to be in LOW state and the transistor will be on only while the J1 is pressed.(or this is my intention but for now i did not even try this part, but should work)

Quote
Also, you need to disconnect VCC_5 from pin 1 of the processor.  You can't have any connection from Vcc_5 to the processor, or it will back-power the processor through the protection diodes when the mosfet is off.
I just install the R7 resistor and there is no effect - the MCU dos not get power from pin1. But this will be the same for A2 and A3 [pin2 and pin3] - they also are connected to Vcc_5 trough R6 and R10 but the MCU doesn't get back power from them.
« Last Edit: December 01, 2020, 01:20:52 am by HackerMy »
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #7 on: December 01, 2020, 01:31:04 am »
Can I use the internal PULLUP resistor on instead of R7. Will it be enough to keep the Reset pin HIGH?
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2138
  • Country: us
Re: Push button to power ON controller
« Reply #8 on: December 01, 2020, 04:51:29 am »
The pullup resistors on A2 and A3 should be connected to Vcc, not Vcc_5.  Or you can configure A2 and A3 as INPUT_PULLUP, and do away with those resistors entirely.

When i connect them to Vcc the PFET is ON all the time, but i will try to use the internal PULLUP resistors on the inputs and eliminate R6 and R10-thanks! DONE! R6 and R10 are gone. With internal PULLUP resistors is working. Thanks again!

Quote
I'm not sure how D2 and J1 work. If you press that button, the diode will block the 5V from D2, so it seems D2 will always read low.  So is your software reading A2 and A3, and if both are high it concludes J1 must have been pressed?  If so, you don't ever need to read D2, so you don't need R5.  The transistor will stay off unless there is actual current flowing through the base.  You don't need to bias it low. (Others may disagree.)
D2 is an OUTPUT when it is HIGH it keeps the transistor on. J1 is optional. If J1 will be used, D2 has to be in LOW state and the transistor will be on only while the J1 is pressed.(or this is my intention but for now i did not even try this part, but should work)

Quote
Also, you need to disconnect VCC_5 from pin 1 of the processor.  You can't have any connection from Vcc_5 to the processor, or it will back-power the processor through the protection diodes when the mosfet is off.
I just install the R7 resistor and there is no effect - the MCU dos not get power from pin1. But this will be the same for A2 and A3 [pin2 and pin3] - they also are connected to Vcc_5 trough R6 and R10 but the MCU doesn't get back power from them.

Well, either your drawing doesn't reflect how you actually have things connected, or I just don't understand how this stuff works.  I don't understand how connecting the A2 and A3 pullups to Vcc could cause the mosfet to turn on, but enabling internal pullups doesn't do that.  They are the same thing.

And I don't understand why connecting Vcc_5 to three processor pins through resistors would not back-power the processor.  Dave has a video on that subject.

Have you said what processor you're using?  Are you sure you have the mosfet oriented correctly, with the source on Vcc_5 and the drain on Vcc?  Anyway, I'm going to stop offering suggestions until someone explains to me what's going on.

 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #9 on: December 01, 2020, 05:07:34 am »
Quote
Have you said what processor you're using?  Are you sure you have the mosfet oriented correctly, with the source on Vcc_5 and the drain on Vcc?  Anyway, I'm going to stop offering suggestions until someone explains to me what's going on.
MCU is ATtiny13A and Yes what is on the drawing the same connections are on the breadboard and the MOSFET is oriented correctly. But there is small possibility i could have made wrong connection when i connected the resistors to Vcc and the MOSFET was ON all the time. I will double check that tomorrow and let you know.
Quote
And I don't understand why connecting Vcc_5 to three processor pins through resistors would not back-power the processor.  Dave has a video on that subject.
I can confirm on 100% that this is correct - doesn't back-power the MCU .
« Last Edit: December 01, 2020, 05:16:49 am by HackerMy »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2138
  • Country: us
Re: Push button to power ON controller
« Reply #10 on: December 01, 2020, 05:21:51 am »
And the diodes are oriented as shown in the drawing?  Then I have to admit I just don't understand.  When the power is off, is the voltage on the ATTiny's Vcc pin at ground as it should be?  If so, how could connecting it to A2 through a resistor cause the power to turn on?  Well, perhaps someone else can provide better help than I can.
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Push button to power ON controller
« Reply #11 on: December 01, 2020, 06:15:55 am »
The correct way to do this is by using the deep sleep mode, it exists exactly for this sort of application, no external components required.
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #12 on: December 01, 2020, 01:24:33 pm »
And the diodes are oriented as shown in the drawing?  Then I have to admit I just don't understand.  When the power is off, is the voltage on the ATTiny's Vcc pin at ground as it should be?  If so, how could connecting it to A2 through a resistor cause the power to turn on?  Well, perhaps someone else can provide better help than I can.
I think i found the reason of that, and of course it is my mistake. When i connected R6 and R10 to Vcc i accidentally connect R1 to the Vcc too - i think that make some seance now why mosfet is on all the time.
But with the INPUT_PULLUP i did not mess with the breadboard and it was working as expected.
« Last Edit: December 01, 2020, 02:43:04 pm by HackerMy »
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #13 on: December 01, 2020, 03:30:49 pm »
The correct way to do this is by using the deep sleep mode, it exists exactly for this sort of application, no external components required.
Please read post #4
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2138
  • Country: us
Re: Push button to power ON controller
« Reply #14 on: December 01, 2020, 03:40:34 pm »
Ok, so you've removed R6, R7 and R10, and the only remaining connection to Vcc_5 is through J1 when it's pressed.  That should mean the Vcc pin is at ground when the power is off, and the mosfet should work properly.

I think I found the reason why connecting Vcc_5 to the reset pin didn't back-power the processor.  It appears the reset pin is involved in high-voltage flashing of the chip, and therefore doesn't have the protection diode to Vcc.  Section 18 of the datasheet shows the absolute maximum voltage on reset as 13V, versus Vcc + 0.5V for all the other I/Os.

There is also a question whether you need an external pullup on the reset pin.  I think you probably don't, and it can be left open.  But you would have to test that.  If an external pullup is required though, I would connect it to Vcc, not Vcc_5, just because that's where it's supposed to go.

And I still don't think you need the pulldown resistor on D2.
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #15 on: December 01, 2020, 05:27:19 pm »
Ok, so you've removed R6, R7 and R10, and the only remaining connection to Vcc_5 is through J1 when it's pressed.  That should mean the Vcc pin is at ground when the power is off, and the mosfet should work properly.
Correct!
Quote
I think I found the reason why connecting Vcc_5 to the reset pin didn't back-power the processor.  It appears the reset pin is involved in high-voltage flashing of the chip, and therefore doesn't have the protection diode to Vcc.  Section 18 of the datasheet shows the absolute maximum voltage on reset as 13V, versus Vcc + 0.5V for all the other I/Os.
Could be, but doesn't answer why doesn't back-power trough R6 or R10
Quote
There is also a question whether you need an external pullup on the reset pin.  I think you probably don't, and it can be left open.  But you would have to test that.  If an external pullup is required though, I would connect it to Vcc, not Vcc_5, just because that's where it's supposed to go.
Agree! More reasonable will be to be connected to Vcc, but i will use the reset pin as a IO pin, but just for clear it completely:The attiny does have an internal pull-up to VCC, but its quite weak (~100k iirc), so environmental conditions could cause a spontaneous reset. If you're worried about this, you should use an external pull-up resistor. It means using an extra component, but it's safer, especially if your reset pin is routed to a programming connector
Quote
And I still don't think you need the pulldown resistor on D2.
It appears i need it. If i remove it the mosfet is ON all the time, and this time i did not mess with the connections i just removed it :-)
 

Offline james_s

  • Super Contributor
  • ***
  • Posts: 21611
  • Country: us
Re: Push button to power ON controller
« Reply #16 on: December 01, 2020, 06:06:37 pm »
The correct way to do this is by using the deep sleep mode, it exists exactly for this sort of application, no external components required.
Please read post #4

I read it.

I'll say it again, the correct way to do this is to use the deep sleep mode. That's why it is there.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2138
  • Country: us
Re: Push button to power ON controller
« Reply #17 on: December 01, 2020, 09:42:05 pm »
Could be, but doesn't answer why doesn't back-power trough R6 or R10

No it doesn't.  Maybe the resistors are too high valued for it to make any difference, but if there's a protection diode from A2 to Vcc as the datasheet says, then connecting Vcc_5 through a 10K resistor should result in a current of about 430uA if Vcc is at ground when the power is off.  But at this point it doesn't matter since you've eliminated the connection.

Quote
Quote
And I still don't think you need the pulldown resistor on D2.
It appears i need it. If i remove it the mosfet is ON all the time, and this time i did not mess with the connections i just removed it :-)

What is the voltage on D2 if you remove the resistor?  If it's 5V, where is that coming from?  You don't have the internal pullup enabled on D2, do you?  Anyway, my point is that a bipolar transistor will not conduct unless there is base current.  So if D2 is a plain input, with no pullup, or if it is a low output, there's no current available to the transistor base.  You shouldn't have to pull the base down to turn off the transistor.
« Last Edit: December 01, 2020, 09:44:24 pm by Peabody »
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #18 on: December 02, 2020, 04:52:18 am »
Quote
What is the voltage on D2 if you remove the resistor?  If it's 5V, where is that coming from?  You don't have the internal pullup enabled on D2, do you?  Anyway, my point is that a bipolar transistor will not conduct unless there is base current.  So if D2 is a plain input, with no pullup, or if it is a low output, there's no current available to the transistor base.  You shouldn't have to pull the base down to turn off the transistor.
Without R5 on D2 i have 2.10V, and 1.48V on Vcc.. I guess it is enough to switch the transistor ON and activate the mosfet. I have 30mV on D2, and 400mV on Vcc with R5 installed
« Last Edit: December 02, 2020, 05:01:58 am by HackerMy »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2138
  • Country: us
Re: Push button to power ON controller
« Reply #19 on: December 02, 2020, 06:00:42 am »
I just don't understand what's going on.  Even with R5 installed, with the mosfet off, where is this voltage coming from? 
 

Offline HackerMyTopic starter

  • Contributor
  • Posts: 18
  • Country: ca
Re: Push button to power ON controller
« Reply #20 on: December 02, 2020, 07:15:19 am »
I just don't understand what's going on.  Even with R5 installed, with the mosfet off, where is this voltage coming from?
Problem Solved! I had Athmel Ace connected to the chip, and it was back-powering the MCU.  R5 is gone too. Thank You!
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2138
  • Country: us
Re: Push button to power ON controller
« Reply #21 on: December 02, 2020, 02:36:43 pm »
You're welcome.  Glad you got it working.
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf