Author Topic: Push button power circuit for Arduino... trying to modify it for 12V input  (Read 15576 times)

0 Members and 1 Guest are viewing this topic.

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Hi All,

I found this circuit that allows for the use of a momentary push button to power on an arduino and then the arduino provides the "hold" signal to continue the power latching on.

https://sites.google.com/site/wayneholder/pushbutton-power-on-off-for-arduino

I have an application where I will have a ~12.6V input power from (3) 18650 batteries in series (when fully charged). Unfortunately there are a few components not rated for this type of input voltage (max 8V). I have tried to find equivalent components with a higher max input voltage... so I replaced the TPS27081A with a Si3865DDV... same foot print and pinout... I also replaced the P channel mosfet FDV302P with BSS84 so that the max GS voltage is above 12V.

I think that should do it... however, based on the circuit in the link I provided it would seem that when the pushbutton is pressed and the p-channel mosfet gate is pulled low, the "BTN" line that would go to the Arduino would see my battery voltage of ~12V ? It would also seem that pin 5 (ON/OFF) of the TPS27081A (or in my case the Si3865DDV) would also see the 12V ? The Arduino can only handle 5V input and the Si3865DDV can handle up to 8V on pin 5...

Am I understanding this circuit correctly? I don't want to fry either of them...

If I put a resistor ahead of the supply pin on the P channel mosfet, would it work with R2 to create a voltage divider? I'm just not sure what effect R1, the diode, and R3 would have on trying to create this voltage divider to get down to 5V

If anyone can help me out with these few details I would really appreciate it!

Thank you
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2548
  • Country: us
First:
  The max input voltage of the Si3865DDV is 12V.  It would be suitable with a 9V battery. 
   But, your 12.6V battery is too high and you would not drive the input to its max voltage.

Second:
   i would put something together with discrete transistors instead.  This could be a starting point.

   
Edit-  A little more thought.
« Last Edit: May 16, 2019, 03:01:52 pm by MarkF »
 
The following users thanked this post: doublec4

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
I have no experience with parts like the TPS27081A, and don't really understand the example circuit.  But it looks like you are right about excess voltages being applied to inputs.  I don't have a solution, but offer the attached circuit which is a simpler approach.  Perhaps it will give you an idea of how to solve the problem.  For example, you might look at moving the BTN input over to the push button, but protected by a diode, so in effect it is active low instead of active high.  Did the example circuit ever work with an Arduino at anything above a 5V power source?
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Thanks to both for the reply. So it seems that with both of these solutions they could work. Searching google for more "latching power" circuits I found a few more examples:

https://randomnerdtutorials.com/latching-power-switch-circuit-auto-power-off-circuit-esp32-esp8266-arduino/

https://electronics.stackexchange.com/questions/193641/simple-inline-latching-power-switch

However, with all of these examples looking similar in approach, it would seem that once the circuit is powered on, pushing the button would not yield any change in "input" to the micro controller.

I'm trying to have one button that would serve as the "ON" button, and button presses after could still be read by the Arduino to perform other functions. Finally, the "long press" would turn the device off. The long press would be handled by software and then killing the pin that is holding the transistor on, so that doesn't really have anything to do with the circuit.
 

Offline MarkF

  • Super Contributor
  • ***
  • Posts: 2548
  • Country: us
Take a look at this circuit.  You would need to regulate your 12V battery to 5V before this circuit.  LM7805 and a few capacitors to feed it.

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/microcontroller-latching-on-off

« Last Edit: May 16, 2019, 08:39:42 pm by MarkF »
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
I have no experience with parts like the TPS27081A, and don't really understand the example circuit.  But it looks like you are right about excess voltages being applied to inputs.  I don't have a solution, but offer the attached circuit which is a simpler approach.  Perhaps it will give you an idea of how to solve the problem.  For example, you might look at moving the BTN input over to the push button, but protected by a diode, so in effect it is active low instead of active high.  Did the example circuit ever work with an Arduino at anything above a 5V power source?

At first glance I didn't think this would detect the button press after the Arduino was powered on, but looking at it again I believe I see it will, as you said, detect the "active low"

So when everything is off at first, and the button is initially held on, the P channel gate gets pulled low and it allows the 12V to reach the regulator and turn on the Arduino. First line of code should hold the output high, triggering the base on the N channel and allowing the P channel mosfet to continue to be turned on. The blocking diode doesn't allow the 12V to pass to the Arduino, but that "input" pin should have the internal pull up set. There will be a ~7V differential across the blocking diode, but I guess that doesn't matter?

Now that everything is on, the next momentary button push will pull that line low, everything will remain on, and the input pin should pull low and I can detect that with the Arduino. I can time the duration of the button push and if sufficient, kill power to the output pin, turning off the base of the N channel once the button is released. The release of the long press will also set the P channel gate high again, now killing the whole circuit.

Is this the correct interpretation Peabody? Also, what is the purpose of the 2.2uF cap? Is this to handle the bouncing of the switch?

 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Here's a somewhat simpler version than MarkF's one, also using discrete MOSFETs and one I/O pin.  It does need two diodes, but if you use BAT54C, you get two in one package.



The button turns on the P-MOSFET when pushed, and also pulls the Arduino GPIO low so button pushes can be detected. The diodes keep the GPIO level and PMOS gate level separate.   

To keep the power on after the user releases the button, enable the GPIO's weak pullup, which keeps the N-MOSFET gate high, which keeps the P-MOSFET on.  N.B. The N-MOSFET gate pulldown *MUST* be large compared to the Arduino internal weak pullup, which is max. 50K.

To turn the power off, the Arduino sets the GPIO to Output Low.  Power off will be delayed if the user is holding the button down.  Unlike Mark's, holding the button down wont force poweroff if the Arduino is crashed.

A 330R resistor is included to protect against mistakes like setting the GPIO to Output High while the button is pushed.

LTspice sim attached (including model of Arduino code controlled behaviour).
« Last Edit: May 17, 2019, 12:42:36 am by Ian.M »
 
The following users thanked this post: SomerledDesign, doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Take a look at this circuit.  You would need to regulate your 12V battery to 5V before this circuit.  LM7805 and a few capacitors to feed it.

http://www.mosaic-industries.com/embedded-systems/microcontroller-projects/electronic-circuits/push-button-switch-turn-on/microcontroller-latching-on-off



Thanks again Mark, I did some more poking around that website and found the same circuit being used with 5-18V input but no microcontroller attached. As soon as they integrate a uC they put the input voltage down to 5V so that the I/O pin only sees 5V max.

I would rather not put a regulator in front of this circuit as there will always be some current draw. The 7805 isn't very efficient when the circuit is on, I'm not sure about when it is off, but either way, this device (warning LED system) will be in storage most of the time and I would like the regulators to be in the "switched" portion of the circuit. The MOSFETS and other components should theoretically have sub micro amp draw when everything is off.

So perhaps I can make do with the circuit with the following modification, see my attachment. I've moved the input to the switch similar to what Peabody posted above. I can set it to PULL_UP and therefore would detect the button push as an active low. I would lose the ability to turn off the circuit through the software, but the long button press to drain the latching cap would still work. You can see where I also inserted my 5V buck regulator to bring the voltage down to the proper supply for the Arduino.

The reason I am using a 12V source is because I have some high powered LEDs that require the 12V input to power. Elsewhere in my circuit I am driving those LEDs with solid state relays from the Arduino.

Please let me know what you think about this?
 

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Here's a somewhat simpler version than MarkF's one, also using discrete MOSFETs and one I/O pin.  It does need two diodes, but if you use BAT54C, you get two in one package.



The button turns on the P-MOSFET when pushed, and also pulls the Arduino GPIO low so button pushes can be detected. The diodes keep the GPIO level and PMOS gate level separate.   

To keep the power on after the user releases the button, enable the GPIO's weak pullup, which keeps the N-MOSFET gate high, which keeps the P-MOSFET on.  N.B. The N-MOSFET gate pulldown *MUST* be large compared to the Arduino internal weak pullup, which is max. 50K.

To turn the power off, the Arduino sets the GPIO to Output Low.  Power off will be delayed if the user is holding the button down.  Unlike Mark's, holding the button down wont force poweroff if the Arduino is crashed.

A 330R resistor is included to protect against mistakes like setting the GPIO to Output High while the button is pushed.

LTspice sim attached (including model of Arduino code controlled behaviour).

Very cool, thank you Ian!

Some questions about this circuit, bear with me please, I'm learning :)

When the circuit is "ON" and the button is pressed, I understand that the GPIO has been set to PULL_UP and will detect the button push as an active low. But what effect does this have on the N MOSFET? Will it temporarily turn it off? I understand the state of the P MOSFET won't change as the gate continues to be pulled low even with a momentary push. But now when the button is released and during the time it takes for the GPIO to switch back to 5V PULL UP high, does this create any unwanted effects? Or is this where C1 somehow comes into play? If that is not the purpose of C1, can you explain what it is doing? I understand that R1 is pulling the P MOSFET high when the circuit is "OFF".

Also... let's say I wanted to "have my cake and eat it too..." and I wanted the ability to kill the whole circuit if the Arduino freezes up like in the example Mark posted...

So let's say my Vin goes to my 5V buck regulator...  Can we somehow implement an RC circuit from my regulated 5V line to the N MOSFET gate line? That way a long button press could drain the RC circuit, essentially forcing my regulator output low, then causing the arduino to die, thereby the GPIO and that gate to all go low... would that turn off the P MOSFET? Maybe its a silly question? EDIT: I feel like although the regulator would short to ground and the arduino would likely turn off, it would turn right back on after the long button push is released because the P channel hasn't been turned off.

Thanks again to everyone for the great examples and discussion so far!
« Last Edit: May 17, 2019, 01:40:37 am by doublec4 »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us

Is this the correct interpretation Peabody? Also, what is the purpose of the 2.2uF cap? Is this to handle the bouncing of the switch?

Yes, that's right.  The Arduino pins are protected from high voltage, and this method can shut off power to the regulator, so the entire circuit is truly off.  Also note that the Arduino could power down the circuit entirely on its own so long as the push button is NOT being pressed.

I don't remember why the capacitor is there, but here is the video from which I screen captured the circuit.  It may be useful for you to follow what he's doing from the beginning, and you will see that he takes at least one wrong step, but finally arrives at the working system thanks to that second diode.

You may need to pick a different MOSFET to deal with the 12V supply, but otherwise, I think this works pretty well, and I don't think it could be much simpler.


 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca

Is this the correct interpretation Peabody? Also, what is the purpose of the 2.2uF cap? Is this to handle the bouncing of the switch?

Yes, that's right.  The Arduino pins are protected from high voltage, and this method can shut off power to the regulator, so the entire circuit is truly off.  Also note that the Arduino could power down the circuit entirely on its own so long as the push button is NOT being pressed.

I don't remember why the capacitor is there, but here is the video from which I screen captured the circuit.  It may be useful for you to follow what he's doing from the beginning, and you will see that he takes at least one wrong step, but finally arrives at the working system thanks to that second diode.

You may need to pick a different MOSFET to deal with the 12V supply, but otherwise, I think this works pretty well, and I don't think it could be much simpler.



From watching the video, one thing that I did not expect from the behavior of the P channel MOSFET was around the 5:00 minute mark, he only has to momentarily pull the gate low ("de-energize" as he says) and then it effectively latches even when floating, allowing current to flow to the LED. The same thing applies for when he pulls the gate high for a second, it energizes the gate and now stays "OFF" when floating.

Obviously with the gate constantly trying to get pulled high from the 1M resistor from V+ to gate it will always default to OFF when the gate isn't pulled to GND.

 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us

From watching the video, one thing that I did not expect from the behavior of the P channel MOSFET was around the 5:00 minute mark, he only has to momentarily pull the gate low ("de-energize" as he says) and then it effectively latches even when floating, allowing current to flow to the LED. The same thing applies for when he pulls the gate high for a second, it energizes the gate and now stays "OFF" when floating.

Obviously with the gate constantly trying to get pulled high from the 1M resistor from V+ to gate it will always default to OFF when the gate isn't pulled to GND.

Yes, in theory if the gate is charged, or discharged, it will stay that way if not connected to anything.  It might be interesting to see how long it would stay on.  But I've never seen a design that relies on that, even for short periods.  And as you say, in this case the mosfet needs to be biased off, which  the 1M resistor does.

A couple other comments:

With regard to Ian.M's idea of using the same I/O pin to maintain power and read the state of the push button, you'll need to consider whether Section 14.2.3 of the 328P datasheet applies ("Switching between Input and Output").  The requirements included there have messed me up more than once.

For turning off the power if the processor freezes up, remember that this is pretty much what the watchdog timer was invented for.  So you might take a look at that option.


 
The following users thanked this post: doublec4

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
With regard to Ian.M's idea of using the same I/O pin to maintain power and read the state of the push button, you'll need to consider whether Section 14.2.3 of the 328P datasheet applies ("Switching between Input and Output").  The requirements included there have messed me up more than once.
Section 18.2.3 in the full datasheet.

That's one of the reasons I included the 330R resistor., as accidentally shorting a high output to ground via the button during development is undesirable.   However, even without it, its manageable.    At power on the GPIO is an input so simply set the port bit to enable the weak pullup.  It remains an input till you need to power off.  Disable the pullup by clearing the port bit, and it will shortly power off due to the 1Meg resistor discharging the NMOS gate.  To speed up the power off, immediately after disabling the pullup, make the GPIO an output, and it will output 0 and rapidly shut off the MOSFETs.

N.B. For the button to be used as an input without problems after the button is released,  C1 & R1 must be chosen to provide a long enough time constant to keep the P-MOSFET on while the GPIO pullup is recharging the N-MOSFET gate to turn it back on.
 
The following users thanked this post: doublec4

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19522
  • Country: gb
  • 0999
The input to the regulator needs to be switched, rather than the MCU.

Here's a quick sketch. I didn't bother simulating the MCU or code. It's just a voltage source which turns off, after a second from when it's turned on. A pull-down might be required on the MCU output, to stop it from floating high, after the power has been removed. The short transients over 6V are nothing to worry about, as the MCU will be designed to resist such short overvoltages, without any damage.

There's no need for a MOSFET with a maximum gate voltage over the supply voltage, just use a potential divider.
« Last Edit: May 18, 2019, 08:45:45 pm by Zero999 »
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca

From watching the video, one thing that I did not expect from the behavior of the P channel MOSFET was around the 5:00 minute mark, he only has to momentarily pull the gate low ("de-energize" as he says) and then it effectively latches even when floating, allowing current to flow to the LED. The same thing applies for when he pulls the gate high for a second, it energizes the gate and now stays "OFF" when floating.

Obviously with the gate constantly trying to get pulled high from the 1M resistor from V+ to gate it will always default to OFF when the gate isn't pulled to GND.

Yes, in theory if the gate is charged, or discharged, it will stay that way if not connected to anything.  It might be interesting to see how long it would stay on.  But I've never seen a design that relies on that, even for short periods.  And as you say, in this case the mosfet needs to be biased off, which  the 1M resistor does.

A couple other comments:

With regard to Ian.M's idea of using the same I/O pin to maintain power and read the state of the push button, you'll need to consider whether Section 14.2.3 of the 328P datasheet applies ("Switching between Input and Output").  The requirements included there have messed me up more than once.

For turning off the power if the processor freezes up, remember that this is pretty much what the watchdog timer was invented for.  So you might take a look at that option.

Thanks, I looked into the WDT and it seems like a viable solution for a hang up... I suppose on a reset, depending on the capacitance of whatever is keeping the P MOSFET gate on, the output driving the N channel would go low since the uC is resetting and the whole circuit may just turn right off. Then it would require user input (button press) to turn back on. Does this sound right?
 

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
With regard to Ian.M's idea of using the same I/O pin to maintain power and read the state of the push button, you'll need to consider whether Section 14.2.3 of the 328P datasheet applies ("Switching between Input and Output").  The requirements included there have messed me up more than once.
Section 18.2.3 in the full datasheet.

That's one of the reasons I included the 330R resistor., as accidentally shorting a high output to ground via the button during development is undesirable.   However, even without it, its manageable.    At power on the GPIO is an input so simply set the port bit to enable the weak pullup.  It remains an input till you need to power off.  Disable the pullup by clearing the port bit, and it will shortly power off due to the 1Meg resistor discharging the NMOS gate.  To speed up the power off, immediately after disabling the pullup, make the GPIO an output, and it will output 0 and rapidly shut off the MOSFETs.

N.B. For the button to be used as an input without problems after the button is released,  C1 & R1 must be chosen to provide a long enough time constant to keep the P-MOSFET on while the GPIO pullup is recharging the N-MOSFET gate to turn it back on.


Good to know! Is there somewhere in the datasheet for the N MOSFET that I should be looking to see how long it would take to charge the gate at a particular voltage/current?

Also, with regards to the WDT the same strategy could be applied to this circuit to kill power on a code hang up? The WDT reset could potentially take long enough to drop the high output on the GPIO and kill the whole circuit... or the decay with the 1M resistor could be slow enough that it might survive the reset and turn on in time to continue charging the gate...

 

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
The input to the regulator needs to be switched, rather than the MCU.

Here's a quick sketch. I didn't bother simulating the MCU or code. It's just a voltage source which turns off, after a second from when it's turned on. A pull-down might be required on the MCU output, to stop it from floating high, after the power has been removed. The short transients over 6V are nothing to worry about, as the MCU will be designed to resist such short overvoltages, without any damage.

There's no need for a MOSFET with a maximum gate voltage over the supply voltage, just use a potential divider.


Thanks for putting that together! I'm going to try and walk through my understanding of the circuit, please let me know if my interpretation is correct...

Okay, so similar to the other circuits we have a P channel whose gate is being biased high when everything is "OFF" and U1 is off as a result.

Then the button is pressed and this drives the gate on M2 high, pulling the gate on M1 low through the voltage divider R1/R2... C1 should also get charged in the process? Even when the button is released, C1 should keep M1 on long enough to drive the MCU_OUT high and latch M1 on through M3.

Now I am a little unclear of what is happening with MCU_IN and how it would see ~5V using the shottky and R3. Is this some kind of resister/diode divider or what is happening there? Any explanation on that part would be really appreciated!

Looks like I'm going to have to buy a bunch of components and bread board some stuff :) Also going to have to figure out how to use LTSpice!



« Last Edit: May 21, 2019, 06:04:52 pm by doublec4 »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
I'm not sure what options you have for the WDT on Arduinos.  The AVR datasheet says it can be configured to reset the system when it times out, or to generate an interrupt (presumably non-maskable).  In interrupt mode, you could just program what you want to happen if things ever get there.  But I don't remember whether the standard Arduino fuse settings lock it into reset mode.  You'll have to research that.

 
The following users thanked this post: doublec4

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19522
  • Country: gb
  • 0999
Thanks for putting that together! I'm going to try and walk through my understanding of the circuit, please let me know if my interpretation is correct...

Okay, so similar to the other circuits we have a P channel whose gate is being biased high when everything is "OFF" and U1 is off as a result.

Then the button is pressed and this drives the gate on M2 high, pulling the gate on M1 low through the voltage divider R1/R2... C1 should also get charged in the process? Even when the button is released, C1 should keep M1 on long enough to drive the MCU_OUT high and latch M1 on through M3.

Now I am a little unclear of what is happening with MCU_IN and how it would see ~5V using the shottky and R3. Is this some kind of resister/diode divider or what is happening there? Any explanation on that part would be really appreciated!

Looks like I'm going to have to buy a bunch of components and bread board some stuff :) Also going to have to figure out how to use LTSpice!
Yes, that's right.

Regarding MCU_IN: R3 limits the current and the Schottky diode starts conducting, if MCU_IN exceeds 5V, by about 0.3V. In other words it acts as a voltage clamping circuit.
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
I'm not sure what options you have for the WDT on Arduinos.  The AVR datasheet says it can be configured to reset the system when it times out, or to generate an interrupt (presumably non-maskable).  In interrupt mode, you could just program what you want to happen if things ever get there.  But I don't remember whether the standard Arduino fuse settings lock it into reset mode.  You'll have to research that.

I will look into it, thanks!
 

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Thanks for putting that together! I'm going to try and walk through my understanding of the circuit, please let me know if my interpretation is correct...

Okay, so similar to the other circuits we have a P channel whose gate is being biased high when everything is "OFF" and U1 is off as a result.

Then the button is pressed and this drives the gate on M2 high, pulling the gate on M1 low through the voltage divider R1/R2... C1 should also get charged in the process? Even when the button is released, C1 should keep M1 on long enough to drive the MCU_OUT high and latch M1 on through M3.

Now I am a little unclear of what is happening with MCU_IN and how it would see ~5V using the shottky and R3. Is this some kind of resister/diode divider or what is happening there? Any explanation on that part would be really appreciated!

Looks like I'm going to have to buy a bunch of components and bread board some stuff :) Also going to have to figure out how to use LTSpice!
Yes, that's right.

Regarding MCU_IN: R3 limits the current and the Schottky diode starts conducting, if MCU_IN exceeds 5V, by about 0.3V. In other words it acts as a voltage clamping circuit.

Thanks for the reply again. I looked up voltage clamping circuits and came across quite a few that look like the one I have attached.

There is an extra diode to GND with many of these ESD clamping circuits. I'm trying to find a good explanation of how/why it works but am still searching. In this circuit, can you explain why the extra diode to GND is not present? In the meantime I am still searching online for the explanation of how this works (how to select the diode(s)/resistor to get the desired voltage/current limit to the MCU_IN pin))

Thanks again for everything, this has been really helpful so far. Learning lots!
 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19522
  • Country: gb
  • 0999
Thanks for putting that together! I'm going to try and walk through my understanding of the circuit, please let me know if my interpretation is correct...

Okay, so similar to the other circuits we have a P channel whose gate is being biased high when everything is "OFF" and U1 is off as a result.

Then the button is pressed and this drives the gate on M2 high, pulling the gate on M1 low through the voltage divider R1/R2... C1 should also get charged in the process? Even when the button is released, C1 should keep M1 on long enough to drive the MCU_OUT high and latch M1 on through M3.

Now I am a little unclear of what is happening with MCU_IN and how it would see ~5V using the shottky and R3. Is this some kind of resister/diode divider or what is happening there? Any explanation on that part would be really appreciated!

Looks like I'm going to have to buy a bunch of components and bread board some stuff :) Also going to have to figure out how to use LTSpice!
Yes, that's right.

Regarding MCU_IN: R3 limits the current and the Schottky diode starts conducting, if MCU_IN exceeds 5V, by about 0.3V. In other words it acts as a voltage clamping circuit.

Thanks for the reply again. I looked up voltage clamping circuits and came across quite a few that look like the one I have attached.

There is an extra diode to GND with many of these ESD clamping circuits. I'm trying to find a good explanation of how/why it works but am still searching. In this circuit, can you explain why the extra diode to GND is not present? In the meantime I am still searching online for the explanation of how this works (how to select the diode(s)/resistor to get the desired voltage/current limit to the MCU_IN pin))

Thanks again for everything, this has been really helpful so far. Learning lots!
There will be one of those clamping circuits, inside the MCU, for every IO pin. It shorts any input voltages outside the supply rails.  If the current is too high, it will either destroy the diode and/or cause the MCU's power supply voltage to increase or decrease, depending on the polarity of the pulse.

The idea behind using a Schottky diode was you don't have to rely on the MCU's input protection diodes. No additional diode to 0V is required, because the pulse is only positive, never negative. D1 could be removed to use the MCU's internal protection diode. R3 limits the current to a safe level.
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Okay, so I wanted to follow up on this thread. I went ahead and bread boarded all of the circuits presented here as well as a few others I found on the web... I did my best to find equivalent through hole components for the breadboard

Some notes...

Peadbody's circuit
  • BC414 was replaced with BC547ATACT
  • After long periods of being disconnected from any power supply, the first time the +/- leads are connected, the circuit turns on automatically.
  • After that, everything works predictably. If you disconnect the +/- power supply leads from the circuit and reconnect them again within ~minute or so, the circuit does not automatically power on

MarkF's circuit
  • IRF7319 was replaced with IRF7309
  • BAV99 was replaced with 1N4454
  • uC turns on momentarily when button is pushed but does not latch
  • Played with a few resistor and cap values on the switched power side to see if I could get it to latch but could not. Triple checked by circuit and everything looks good... not sure why it won't latch.

Ian.M circuit
  • IRF7207 was replaced with SFT1342-W
  • BSS123 was replaced with TN0610N3
  • BAT54 was replaced with BAT85S
  • Works as expected, no weird behavior

Zero999 circuit
  • FDC638P was replaced with NDP6020P
  • 2N7002 was replaced with VN2222LL
  • BAT54 was replaced with BAT85S
  • Similar to Peabody circuit, after long periods of being disconnected from any power supply, the first time the +/- leads are connected, the circuit turns on automatically. Everything works as expected after this.
  • Then I tried pulling down the uC output line with 10K resistor, and this somewhat eliminates the problem of automatic turn on after long periods of being disconnected. Now after long periods, connecting +/- to the circuit the uC turns on for a split second and then turns back off almost immediately. From here, everything works as expected again.

Thank you to all for your contributions! If you guys have any more ideas as to why some of these circuits will "auto-on" the first time they are connected to a power supply please let me know.

 
The following users thanked this post: Ian.M

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
In the case of my circuit, I suspect the problem is that if the capacitor is completely discharged, then when power is connected it will take some time for the charge to build up through the 1M resistor.  During that period, the mosfet will be ON, and if that takes long enough, the processor will turn on and stay on.  My understanding from the video is that the capacitor is there only so you won't need to hold the button down until the processor boots up.  If that's not important to you, then you might try it without the capacitor and see if that fixes the auto-turnon problem.

 
The following users thanked this post: doublec4

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19522
  • Country: gb
  • 0999
In the case of my circuit, I suspect the problem is that if the capacitor is completely discharged, then when power is connected it will take some time for the charge to build up through the 1M resistor.  During that period, the mosfet will be ON, and if that takes long enough, the processor will turn on and stay on.  My understanding from the video is that the capacitor is there only so you won't need to hold the button down until the processor boots up.  If that's not important to you, then you might try it without the capacitor and see if that fixes the auto-turnon problem.
My circuit has the same issue, for the same reason.

No need to omit the capacitor, just move it.
 
The following users thanked this post: doublec4

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
Thanks to both.

Zero999 I moved the cap as per your suggestion and success, that works  :)

Peabody, I basically did the same thing, I took the 2.2uF cap and moved it in parallel with the 1M resistor and it works flawlessly now as well.

 

Offline Zero999

  • Super Contributor
  • ***
  • Posts: 19522
  • Country: gb
  • 0999
Yes, I should have set the simulator to start with the supply voltages at 0V, which would have shown this issue.
 
The following users thanked this post: doublec4

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
I see that doublec4 (Chris) has put all these designs into a video, and posted a link to that in the Tutorials section of the Arduino Forum. Nice work, Chris.  Here's the video link:



He likes Ian.M's circuit best, and I do too.

I guess the next step is to integrate a battery charging circuit into this.  :-)

 

Offline doublec4Topic starter

  • Regular Contributor
  • *
  • Posts: 119
  • Country: ca
 :-+

Thanks! Couldn't have done it without you guys!
 

Offline chris.munc

  • Newbie
  • Posts: 1
  • Country: za
Oops I am trying to design for a 9 volt battery, as i said I'm a newbie. Will start looking for that on the forum.

Hi all, I’m a bit of a newbie here, dabbled a bit, but have always been keen to try microcontrollers.  Just bought myself an Arduino beginners kit, with the intention of building a simple ultrasonic distance comparator.  In my wanderings of the internet I came across the above video (many thanks doublec4), and also found that I liked, Ian.M's circuit, so much so that I have reproduced it in tinkercad.  I’m not sure if this hyperlink will work for you but here it is https://www.tinkercad.com/things/k5xWaD0dLv1-attiny-soft-latching-power-supply-, otherwise just search for “ATTiny Soft Latching”, in the circuits section.

Now for the real purpose of my visit, please could you chaps help me with alternative components.  Would an IRF9530 work for the p mosfet, a 2N7000 work for the n mosfet, and two 1N5818’s for the Schottky diodes (again apologies, I would like to do this project with a 9v battery not 12v).

Many thanks.

PS here is a screen shot of the tinkercad project

« Last Edit: July 24, 2019, 03:59:44 pm by chris.munc »
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
As long as the Arduino (or other MCU) is running at 5V, your choice of MOSFETs will be O.K.   If you need to run at 3.3V, you'd need something with a lower max. gate threshold voltage than a 2N7000.

Small signal Silicon diodes (e.g. 1N4148) would be better than 1A Schottky diodes - the leakage current and junction capacitance of 1N5818 may be excessive.
« Last Edit: July 24, 2019, 07:33:14 pm by Ian.M »
 
The following users thanked this post: chris.munc

Offline MrFollies

  • Contributor
  • Posts: 10
  • Country: au
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #31 on: October 28, 2021, 01:47:54 am »
As long as the Arduino (or other MCU) is running at 5V, your choice of MOSFETs will be O.K.   If you need to run at 3.3V, you'd need something with a lower max. gate threshold voltage than a 2N7000.

Small signal Silicon diodes (e.g. 1N4148) would be better than 1A Schottky diodes - the leakage current and junction capacitance of 1N5818 may be excessive.

Hello Ian..

In your design (and the 9v idea above), what voltage is the GPIO seeing?
I'm keen to use this circuit for both rPi and esp32 MCUs both of which are happily powered by 5V but don't want anything higher than 3.3V on the inputs.
I can use a logic shifter I guess, but that might break the output design.

I'd like to understand how to convert your design to work with a 5V power supply but with 3.3V tolerant GPIO pins.
Is it possible?
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #32 on: October 28, 2021, 03:08:39 am »
Due to the diodes, the GPIO pin can only be pulled low by the circuit, so it never 'sees' more than its normal logic '1' voltage no matter what the supply voltage is.  With appropriate choice of MOSFETs you can use the same circuit for any supply voltage from 3.3V up to about 15V.  Above 15V you'll almost certainly need a modified circuit to limit M1's Vgs to keep it well within its abs. max limits, just due to the limitations of having to find a P-MOSFET rated for >20V Vgs.   

The key parameter for low voltage operation is the MOSFETs threshold voltage - M1's needs to be well under  Vbatt/2 so it can deliver enough current when the gate is grounded  (i.e. when Vgs=-Vbatt, see datasheet curves to check it wont be edging into saturation), and M2's needs to be under half the logic '1' voltage.
« Last Edit: October 28, 2021, 03:13:59 am by Ian.M »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5907
  • Country: es
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #33 on: October 28, 2021, 08:26:45 am »
Just replace the 2n7002 with a small signal bjt and a 10K resistor to its base. 2n2222, bc547, c945... will work down to ~1V
« Last Edit: October 28, 2021, 08:29:53 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #34 on: October 28, 2021, 10:55:32 am »
Just replace the 2n7002 with a small signal bjt and a 10K resistor to its base. 2n2222, bc547, c945... will work down to ~1V

While true for most of the general power circuits with seperae GPIO pins for power control and button sensing, a BJT will specifically *NOT* work in my single GPIO pin circuit.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5907
  • Country: es
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #35 on: October 28, 2021, 01:59:24 pm »
No idea what you're talking about...
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #36 on: October 28, 2021, 03:54:17 pm »
No idea what you're talking about...

From reply #6 above

Its not possible to replace M2 with an ordinary BJT as per your circuit, as its base current will be significantly higher than that available through the GPIO weak pullup when its set as an input, which will pull down the GPIO, so it will no longer be possible to use the same GPIO to sense the switch state.
Buffering the GPIO so it doesn't get pulled down by the BJT base current is possible, (e.g. add a super-Beta emitter follower to drive the base resistor), but adds more complexity vs simply choosing an appropriate MOSFET. 
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5907
  • Country: es
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #37 on: October 28, 2021, 07:21:41 pm »
Circuit complexity? That circuit is already over-complicated.
So your gpio sets the internal weak pullup,  M2 will be turned on all the time, which will also turn M1 on.
When S1 is shorted,  M1 will keep turned on as long as the button is pressed, without any way to turn it off until it's released, which is a bit scary depending on what M1 is controlling.
After that, you read the gpio, if read low, you set the gpio as output, low level (or turn off the internal pullup), switching off M2, and opening M1 when S1 is released.
Now you'll never now when S1 is pushed again...?

Anyways, you can do the same thing much easier... Use a high gain npn bjt like BC547C, which is extremely common.
100K is the internal pullup, being the GPIO directly connected to the base.
There's a small difference: The switch instantly turns off the output.
If you want to keep M2 on while the switch is pressed, then add the diodes like in your circuit.
« Last Edit: October 28, 2021, 07:28:53 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #38 on: October 28, 2021, 07:51:23 pm »
DavidAlfa, I don't think you were around for the original posts.  The idea was to have the pushbutton turn on the power, after which the processor would maintain it, and the button could then be used for general purpose input, but with a long press the processor would shut down the power.  And all of this would be done with a single GPIO pin.  I aways assumed the processor would wait until the button was released before doing anything so it could tell whether the press was long or short.  Anyway, I tried to develop a circuit using an NPN instead of an N-channel mosfet, but wasn't able to do it.  If you have such a circuit, I'd like to see it.
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5907
  • Country: es
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #39 on: October 28, 2021, 08:45:32 pm »
I see problems in your circuit, but maybe it's me.
The only input voltage source is its own pullup, so you need to have it enabled all the time... thus the mosfet will be always on.

Yeah I seethe bjt problem....
You would need a second transistor, making an AND gate, so the pullup only turns on the output when there's power on it.
To turn off the output, turn off the pullup or set the pin as output, low level, for a short time.
« Last Edit: October 28, 2021, 10:15:47 pm by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #40 on: October 28, 2021, 10:19:37 pm »
Looking back at Ian's circuit, if the GPIO is configured as INPUT_PULLUP, that will be enough to turn on the N-channel and keep the power on. Then when you short the switch, that pulls the GPIO low via D1 which turns off the N-channel.  However, via D2 it also directly grounds the P-channel gate, which keeps the power on even though the N-channel is off.  C1 prevents any glitching as the P-channel gate is pulled low via the two different paths.  So it actually works quite well, and I don't see another way to have the same functionality with fewer parts.

While the internal pullup would probably be enough to turn on an NPN, the voltage at the base would be 0.6V or so, and I was not able to come up with a way to preserve the input function of the switch.  I think Ian's circuit is the best solution I've seen for this, but you can watch the OP's video covering it and four other alternatives and see what you think. 
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #41 on: October 28, 2021, 10:24:18 pm »
Yep, you don't read the input when M1 is off, as the MCU's supply is from downstream of M1!   :-// 

@Peabody: that's as good an explanation as any of my circuit. 

@all,
If you are more visually oriented, see 11:22-14:43 in doublec4 (Chris)'s video for an explanation of its function.

Chris's video, queued to my circuit: https://youtu.be/7D9L9oS4AJM?t=682

I can *think* of a few ways of doing something similar with BJTs, but they are all horribly complex.  :horse:
« Last Edit: October 28, 2021, 10:27:45 pm by Ian.M »
 

Offline DavidAlfa

  • Super Contributor
  • ***
  • Posts: 5907
  • Country: es
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #42 on: October 28, 2021, 10:36:33 pm »
Even more simple: Use self-latching. The MCU can turn off the mosfet at any moment by setting the gpio low.
No fancy electronics, very readily available and cheap parts.
Q2 will we switched on by the switch. The output will turn on Q1 and lock it up.

Together, D3+Q1 b-e junction have a drop of 1.2-1.4V, thus not affecting the gpio input.
When the gpio is turned low, there's only D1 in series with R4, so there'll be 0.7V, turning Q1 off and disabling Q2.

There's only a drawback: You'll have to ensure the output discharges BELOW 1.2v or it will latch again,
You could use an adittional fet to automatically discharge the output quickly(attached).

Edit: Oh I see it's a power-on circuit for the mcu itself, not for switching loads.
Then, likely you won't he discharging circuit. Just set the ouput low until it dies.
You might replace D3 with a 2.4V zener to increase the turn off voltage.
« Last Edit: October 29, 2021, 12:04:53 am by DavidAlfa »
Hantek DSO2x1x            Drive        FAQ          DON'T BUY HANTEK! (Aka HALF-MADE)
Stm32 Soldering FW      Forum      Github      Donate
 

Offline z555

  • Newbie
  • Posts: 1
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #43 on: November 11, 2021, 09:14:55 pm »
There are some power management ICs out there which provide soft switch functionality at greatly reduced circuit complexity and footprint at the expense of well expense...

Checkout:
$1.80 per 100 Maxim Integrated's MAX16150
Quote
The MAX16150 is an extremely low-power, pushbutton, on/off controller with a switch debouncer and built-in latch. This device accepts a noisy input from a mechanical switch and produces a clean, latched output, as well as a one-shot interrupt output, in response to a switch closure exceeding the debounce period at PB_IN. A switch clo- sure longer than shutdown period at PB_IN results in a longer one-shot interrupt output. The MAX16150 family has two set of devices, one in which a longer switch closure greater than the shutdown period deasserts the latched output, and another in which the latched output stays asserted.



$4.39 per 100 Analog Devices' LTC2955
Quote
The LTC2955 is a micropower, pushbutton on/off controller that manages system power by generating a clean enable output from the supply monitor input and the debounced pushbutton input. It features an interrupt output that notifies the system of a pushbutton or low supply event. When the system is ready, it may use the power kill input to shut off power. If the pushbutton remains pressed for more than the configurable turn-off duration, the system power is forced off.
« Last Edit: November 11, 2021, 09:20:56 pm by z555 »
 

Offline CBF

  • Newbie
  • Posts: 6
  • Country: au
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #44 on: November 19, 2021, 10:16:06 am »
I cannot get this circuit to work. It turns on correctly but when the arduino sets the output low to turn off the input floats to high. I cannot think of a solution and believe the problem is because the arduino is tri-state or my mosfet? Datasheet and my schematic:
https://www.farnell.com/datasheets/2303831.pdf
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #45 on: November 19, 2021, 12:03:43 pm »
The Arduino output may not hold its state during loss of Vcc.  If it glitches high it will re-trigger. If you've got a decent scope, look for glitches on the out pin.

If you find a glitch, try splitting the 4K7 resistor into two 2K2 ones with a cap to ground in between to make a low pass filter, with a time constant an couple of orders of magnitude longer than the glitch so it has negligible effect.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #46 on: November 19, 2021, 07:03:58 pm »
I cannot get this circuit to work. It turns on correctly but when the arduino sets the output low to turn off the input floats to high. I cannot think of a solution and believe the problem is because the arduino is tri-state or my mosfet?

If you mean the GPIO pin labeled INPUT in your schematic, that should always be high unless you are pushing the button.  There's nothing pulling INPUT down.  But if you mean the power doesn't shut down, then that shouldn't be happening.  Are you keeping the output pin low for a while?  Remember that you have to recharge the gate capacitor through that 1M resistor before the mosfet will turn off.  After bringing the output low, try adding a 10 second Delay afterwards.  If that still doesn't work, instead of taking the output low, try changing it to INPUT mode, still with the Delay.



« Last Edit: November 20, 2021, 04:09:21 am by Peabody »
 

Offline T3sl4co1l

  • Super Contributor
  • ***
  • Posts: 21686
  • Country: us
  • Expert, Analog Electronics, PCB Layout, EMC
    • Seven Transistor Labs
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #47 on: November 19, 2021, 07:29:54 pm »
Just to belatedly add my own to this old thread --

I did this, with the additional constraint that it run from 24V, with low leakage.



The 24VEN goes to an LDO enable, which powers the MCU's converter (24-3.3V buck) and other hardware (12V for SMPS controllers).  This circuit draws essentially MOS leakage current until enabled, and the load's minimum current draw is still many times the bias drawn by this when on, so it's no matter at all.  It also monitors RS-232, so that serial commands can wake up the MCU directly.  Filtering not shown; ESD protection is shown.

Oh, the serial wake-up part is a bit ambiguous, isn't it... the input NMOS is wired-OR with the latching NMOS I believe?  So the right half of that is duplicating the respective part of the right hand side.  Yeah I don't have this thing in front of me right this instant to confirm, tsk tsk.

Tim
Seven Transistor Labs, LLC
Electronic design, from concept to prototype.
Bringing a project to life?  Send me a message!
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #48 on: November 20, 2021, 04:18:50 am »
Just looked at the schematic again, and I think the 2.2uF gate capacitor shown in red is way too big.  Its only purpose is to prevent the circuit from powering up when power is first connected.  But for that I think .01uF or even smaller would be enough.  Try removing that cap, and then see if the circuit powers down properly.  And the 1M resistor may be too high if there's any leakage through the NPN.  Try 220K or even 100K and see if that makes a difference.  I think the circuit is sound, and should work, but you need to experiment a bit with different values.
 

Offline CBF

  • Newbie
  • Posts: 6
  • Country: au
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #49 on: November 21, 2021, 05:14:13 am »
I tried adjusting the gate cap values and the resistor with no luck. I successfully with a different circuit. I think a low pass filter on the base of the transistor may have worked as the output did spike to negative momentarily, as Ian P suggested. Thanks anyway.
 

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #50 on: November 21, 2021, 09:31:50 am »
@CBF: For the record, what circuit did you end up with that was successful?
 

Offline CBF

  • Newbie
  • Posts: 6
  • Country: au
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #51 on: November 22, 2021, 05:09:57 am »
@CBF: For the record, what circuit did you end up with that was successful?

Yes for the record! I took out the delay element and went with a circuit I found similiar to this with the mosfets I had handy and ditched the timing component for a hold down to turn on. My arduino boots up almost instantly. I added a pull-down resistor on the sense:
 
The following users thanked this post: Ian.M

Offline Ian.M

  • Super Contributor
  • ***
  • Posts: 12860
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #52 on: November 22, 2021, 07:41:57 am »
Yes, with a 6K8 pulldown on the SENSE input to keep the max. signal just under 5V, that looks reasonable.   The only flies in the ointment are that the switched power isn't debounced so is likely to glitch during power up, and the switch has to handle the entire load current till the MCU turns the MOSFET on.  An Arduino has enough onboard decoupling to ride through the power glitches, and if it doesn't have other significant loads on Vin or +5V is unlikely to draw enough current to be problematic for most small button switches, but it may not work so well for other applications.
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #53 on: November 22, 2021, 03:55:55 pm »
I'd still like to understand why the first circuit in the video doesn't work for CBF.  Below is a bit cleaner schematic but essentially the same except the capacitor is missing.  The circuit worked in Chris' video and in the video the circuit came from, so I wonder what the problem is with CBF's circuit.  Did Chris wait until the button was released before taking the output pin low?  It doesn't look like that in the video.  Anyway, is there any way to get to the bottom of this?

 

Offline CBF

  • Newbie
  • Posts: 6
  • Country: au
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #54 on: November 22, 2021, 11:54:40 pm »
I'd still like to understand why the first circuit in the video doesn't work for CBF.  Below is a bit cleaner schematic but essentially the same except the capacitor is missing.  The circuit worked in Chris' video and in the video the circuit came from, so I wonder what the problem is with CBF's circuit.  Did Chris wait until the button was released before taking the output pin low?  It doesn't look like that in the video.  Anyway, is there any way to get to the bottom of this?

Yes I would too. When I get some time I will play around with it a bit more, but first I have to finish this project.
« Last Edit: November 23, 2021, 12:08:22 am by CBF »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #55 on: November 23, 2021, 04:02:34 pm »
Could it be switch bounce?  I wouldn't think there would be much bounce when releasing the button.  Well if I have time over the weekend, I'll set up the circuit with a Nano and see what happens.

It seems the safest thing might be to wait until the button is released before turning off the NPN. It really shouldn't make any difference as long as you bring the output pin low and keep it low forever.  Then everything should shut down when the button is released.  But waiting for button release, if it still misbehaves, that would indentify the Nano as the problem - output pin glitching high as it powers down.
 

Offline CBF

  • Newbie
  • Posts: 6
  • Country: au
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #56 on: November 26, 2021, 06:18:59 pm »
Yes, with a 6K8 pulldown on the SENSE input to keep the max. signal just under 5V, that looks reasonable.   The only flies in the ointment are that the switched power isn't debounced so is likely to glitch during power up, and the switch has to handle the entire load current till the MCU turns the MOSFET on.  An Arduino has enough onboard decoupling to ride through the power glitches, and if it doesn't have other significant loads on Vin or +5V is unlikely to draw enough current to be problematic for most small button switches, but it may not work so well for other applications.

I can't believe I am still having problems with such a simple circuit. I have the arduino connected to a MOSFET controlled motor driver than can spike up to 1.5A. The circuit is unable to deliver this. Could this be the Rds of the MOSFET? The voltage seems to drop and the motors stall. When I remove the above circuit and power directly from the powerbank there are no problems.

I need a solution quickly for this project and I'm struggling to get anywhere. I'm sure there is lots wrong thats why I'm here:
« Last Edit: November 26, 2021, 09:30:24 pm by CBF »
 

Offline Peabody

  • Super Contributor
  • ***
  • Posts: 2007
  • Country: us
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #57 on: November 27, 2021, 12:11:40 am »
I couldn't find an IRZ44N.  If it's really IRFZ44N, then it's not a logic level mosfet, and if the source is at 5V, then the gate threshold voltage is way too high to turn on the mosfet fully when the GPIO controlling it goes to ground.

 
The following users thanked this post: Ian.M

Offline CBF

  • Newbie
  • Posts: 6
  • Country: au
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #58 on: November 27, 2021, 04:04:36 am »
I couldn't find an IRZ44N.  If it's really IRFZ44N, then it's not a logic level mosfet, and if the source is at 5V, then the gate threshold voltage is way too high to turn on the mosfet fully when the GPIO controlling it goes to ground.

Thanks so much, I had it lying around and remembered it being logic level, doh! I should have checked the datasheet - this explains my probblems with my first circuit. Will update  :)
 

Offline zbyhu

  • Newbie
  • Posts: 1
  • Country: pl
Re: Push button power circuit for Arduino... trying to modify it for 12V input
« Reply #59 on: December 14, 2021, 03:25:46 pm »
Hi All,
I have a question to Ian.M's circuiit.

I used DMG1013UW as M1 and BSS214 as M2.
Vbatt is around 3.8V.
What I observe is that M2 is turned on right after power is connected.
D1 and D2 are SKM14 from DIOTEC.

Double checked the MOSFETs pinout and it is correct.

Why circuit behaves like this?


 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf