Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Arduino push button, Arduino turns itself off

Status
Not open for further replies.
Hi robertbu,
I do not know if adding a capacitor to D6 would solve the problem as I do not yet know the cause of the problem which is why I wanted to know the voltage on D6 and the gate of the mosfet when D6 was set high to switch the circuit off.

Les.
 
I am looking at your last circuit Robert
The way it sit, I read the following logic:
1- D6=Low, SW open
Q3=off, Q2=on, Q1=off
2- SW (momentary switch) is pressed now
Arduino is turned on, D6 is set high,
Q3=on, Q2=off, Q1=on, Q1 is latched, SW released, start timer
3- Time is up, SW is not pressed again, D6 is set Low
Everything is reset, Arduino is turned off.
4- Monitoring for SW press again

P.S.: I think I found the problem. When Q1 is latched on step 2, SW becomes redundant. How is the Arduino know if the SW is pressed and how is that effect the Arduino?
You need to find a way that even though Q1 is turned on and conducting, SW is able to trigger the Arduino!
 
Last edited:
Here is a simple idea. The switch turns Arduino on thru an isolation diode. Once Arduino is on, it immediately turns OUT Low, turning the Pmos ON, Latching the feed to Arduino. This also triggers a timer of certain time (example 1 minute).
Arduino checks for SW press (if IN=High) every 1 seconds. If IN=high, then Arduino resets the 1 minute timer and looks at IN again.
After 1 minute time has passed and no activity on SW, then OUT will go High, Pmos is turned off, and Arduino is turned off.
Next SW press will restart the event.
EG
 

Attachments

  • Tilt_SW_Retrigger.jpg
    Tilt_SW_Retrigger.jpg
    47.9 KB · Views: 295
  • Tilt_SW_Retrigger V2.jpg
    Tilt_SW_Retrigger V2.jpg
    50.4 KB · Views: 308
Last edited:
Les: In the original circuit, the voltage at D6 goes to 5.01v when the pin is pulled up. When I follow voltage over time, it goes to 5.01v the reboot light on the Arduino blinks, and the voltage drops again before complete shutdown. D6 is not being held high long enough for a complete shutdown when R2 is included. Without R2, shutdown works, but D6 floats until the first line of my program so the circuit does not latch unless I press the push button for 1s. The standard bootloader of an Arduino takes around 1s before my code is executed. The idea I was asking about (which I will try out) was to add a capacitor to D6 to hold the line high a bit after the Arduino reboots. It is one thing to have an idea about how to fix a problem; it is another thing to understand if it is a good idea even if it works.
 
MikeMI: Your suggestion as a good one, and something I've already spent some time exploring. From my reading, to get the kinds of numbers you suggest I would need to pull the power LED and the voltage regulator. And the results I've read about with this conversion are around 4ua sleep and 14ma awake for the 5v mini pro. That still leaves me with the task of either providing a regulated 5v from some external source (and paying whatever current penalty is needed for that source), or designing the project to run off varying battery voltage. And I'd also have to wire circuits to turn on and off peripherals which don't have a sleep mode of their own.

Getting this circuit working is like a sword to a Gordian knot for me...it solves the power use issues in several projects with different power sources, different power requirements, and different peripherals.
 
EvilGenius: Thanks for the feedback, ideas, and circuit work. For my current project, I don't care that S1 is useless after the power is on since I will use a second tilt/ball switch tied to a pin with a more aggressive orientation to detect when to turn the Arduino off. There another project for this circuit where I do care, but your approach will not solve the problem for a stock Arduino board. There is a 1s delay due to the bootloader between power on and the first line of my code being executed...so the switch would need to be held for 1s before the Arduino would stay on. I want an immediate latch on.
 
EvilGenius: Thanks for the feedback, ideas, and circuit work. For my current project, I don't care that S1 is useless after the power is on since I will use a second tilt/ball switch tied to a pin with a more aggressive orientation to detect when to turn the Arduino off. There another project for this circuit where I do care, but your approach will not solve the problem for a stock Arduino board. There is a 1s delay due to the bootloader between power on and the first line of my code being executed...so the switch would need to be held for 1s before the Arduino would stay on. I want an immediate latch on.
The Sw trigger is not for turning off but rather to keep the Arduino on constantly until there is no activity on Sw.
Your 1s start up time is understood. I will think about a solution.
 
Hi robertbu,
Re post #24. I suspected something like that may be happening. I don't think a capacitor on D6 will solve the problem as the coltage will rise on the capacitor and a soon as it gets high enough to start turning the transistor and mosfet off it will not be charged to a full 5 volts. I suggest adding a capacitor between ground and Vin on the Aruino so that it remains powered from this capacitor for a few mS after the mosfet has fully switched off. This is so the high signal on D6 does not go low before the mosfet is fully off. I think a few hundred uF would be about right. I'm not sure that this will work as it depends on how the Arduino behaves as the capacitor discharges.

Les.
 
Hi Lee, I used 1 uF cap and a 220 ohm resistor to pull up pin 6, and worked just fine (though I like your answer of powering the whole Arduino better). I ended up using the second circuit I posted with three transistors. The ball/tilt switch only handles 15 ma, so I had to approach the turn on in a different way. Thank you (and everyone else) for your time and feedback. Posting here was a learning experience.
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top