Author Topic: Push button power circuit for Arduino... trying to modify it for 12V input  (Read 15571 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?

 

Online 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

Online 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: 19520
  • 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: 19520
  • 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: 19520
  • 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: 19520
  • 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


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf