Push button to power ON controller - Page 1
Forum section: electronics / projects

author: HackerMy
author_rank: Contributor
timestamp: November 30, 2020, 01:33:22 pm
content: 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

author: bson
author_rank: Unknown
timestamp: November 30, 2020, 08:02:03 pm
content: 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.

author: homebrew
author_rank: Frequent Contributor
timestamp: November 30, 2020, 08:51:15 pm
content: Does this really work as is?I would imagine that the uC would be powered through the pull up resistors R6, R10 constantly ...

author: HackerMy
author_rank: Contributor
timestamp: November 30, 2020, 10:41:10 pm
content: 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).

author: HackerMy
author_rank: Contributor
timestamp: November 30, 2020, 10:51:03 pm
content: 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...

author: Peabody
author_rank: Super Contributor
timestamp: November 30, 2020, 11:56:16 pm
content: 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.

author: HackerMy
author_rank: Contributor
timestamp: December 01, 2020, 12:44:36 am
content: Quote from: Peabody on November 30, 2020, 11:56:16 pmWhen 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!QuoteD2 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)QuoteI 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.

author: HackerMy
author_rank: Contributor
timestamp: December 01, 2020, 01:31:04 am
content: Can I use the internal PULLUP resistor on instead of R7. Will it be enough to keep the Reset pin HIGH?

author: Peabody
author_rank: Super Contributor
timestamp: December 01, 2020, 04:51:29 am
content: Quote from: HackerMy on December 01, 2020, 12:44:36 amWell, 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.

author: HackerMy
author_rank: Contributor
timestamp: December 01, 2020, 05:07:34 am
content: QuoteMCU 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.QuoteI can confirm on 100% that this is correct - doesn't back-power the MCU .

author: Peabody
author_rank: Super Contributor
timestamp: December 01, 2020, 05:21:51 am
content: 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.

author: james_s
author_rank: Super Contributor
timestamp: December 01, 2020, 06:15:55 am
content: 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.

author: HackerMy
author_rank: Contributor
timestamp: December 01, 2020, 01:24:33 pm
content: Quote from: Peabody on December 01, 2020, 05:21:51 amI 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.

author: HackerMy
author_rank: Contributor
timestamp: December 01, 2020, 03:30:49 pm
content: Quote from: james_s on December 01, 2020, 06:15:55 amPlease read post #4

author: Peabody
author_rank: Super Contributor
timestamp: December 01, 2020, 03:40:34 pm
content: 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.

author: HackerMy
author_rank: Contributor
timestamp: December 01, 2020, 05:27:19 pm
content: Quote from: Peabody on December 01, 2020, 03:40:34 pmCorrect!QuoteCould be, but doesn't answer why doesn't back-power trough R6 or R10QuoteAgree! 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 connectorQuoteIt 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 :-)

author: james_s
author_rank: Super Contributor
timestamp: December 01, 2020, 06:06:37 pm
content: Quote from: HackerMy on December 01, 2020, 03:30:49 pmI 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.

author: Peabody
author_rank: Super Contributor
timestamp: December 01, 2020, 09:42:05 pm
content: Quote from: HackerMy on December 01, 2020, 05:27:19 pmNo 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.QuoteWhat 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.

author: HackerMy
author_rank: Contributor
timestamp: December 02, 2020, 04:52:18 am
content: QuoteWithout 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

author: Peabody
author_rank: Super Contributor
timestamp: December 02, 2020, 06:00:42 am
content: I just don't understand what's going on. Even with R5 installed, with the mosfet off, where is this voltage coming from?

author: HackerMy
author_rank: Contributor
timestamp: December 02, 2020, 07:15:19 am
content: Quote from: Peabody on December 02, 2020, 06:00:42 amProblem Solved! I had Athmel Ace connected to the chip, and it was back-powering the MCU. R5 is gone too. Thank You!

author: Peabody
author_rank: Super Contributor
timestamp: December 02, 2020, 02:36:43 pm
content: You're welcome. Glad you got it working.