Offline
Newbie
Karma: 1
Posts: 37
|
 |
« on: August 11, 2011, 05:44:18 am » |
I'm trying to make an Arduino circuit that comes on when you press a momentary button, but then stays on until the Arduino decides it's time to switch off. Fairly common situation, I'd imagine, but I've never done it before. Is my [attached] schematic workable? Looks sensible to me, but I've discovered that that means remarkably little  Basically, I'm imagining that the circuit won't do anything when power is first applied, as there's no current through the base/emitter of the TIP102. Press the power button on the right, and the TIP102 will turn on, allowing power through the voltage regulator and therefore powering up the arduino. The first line of code in the arduino will set the 'power control' pin high, so it'll keep the TIP102 powered even after the user has taken the finger off the button. Then when I want the arduino to power down, all I have to do is set the 'power control' pin low. The two diodes are just acting as an 'OR' gate, and to stop current from finding a route straight from the power button to the arduino. ... Or am I making a basic mistake? Thought it was worth asking here before buying the bits.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 37
|
 |
« Reply #1 on: August 11, 2011, 05:48:43 am » |
Oops - just to add, I'm slightly concerned that the decoupling caps across the input and output of the voltage regulator may cause problems. Should they perhaps be connected to ground *before* the TIP102 (the 'switched ground', if you will)?
I'm not worried about the circuit inadvertently powering on when I first connect the 9v battery, as long as it'll behave from then on.
h
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #2 on: August 11, 2011, 07:33:30 am » |
I'm slightly concerned that the decoupling caps No they are fine. That looks like it might work. The only problem might be when the arduino want's to turn off and it will not be able to hold the output high long enough to be off. But I think it would work. If you have problems then you might like to look at looking at the on button with the arduino and only turn on the holding output when the on button is being pressed. But try this first. Conventionally this is done with two transistors connected as a multivibrator or flip flop. It is kicked on and then kicked off so it doesn't require any logic level to hold.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 37
|
 |
« Reply #3 on: August 11, 2011, 09:26:08 am » |
Thanks for the response! That looks like it might work. The only problem might be when the arduino want's to turn off and it will not be able to hold the output high long enough to be off. The Arduino's holding the power on by keeping a pin high, so do you mean it may not be able to hold the output low for long enough?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #4 on: August 11, 2011, 09:33:46 am » |
No the on bit should work. It is the off bit that might be problematical. Arduino sends pin high, power starts dropping, then you enter a sort of twilight zone where you might get resting going on and restarting the program and re asserting the pin low. Electronics do funny things when operating a voltages on the verge of operation. But as I said it will probably work.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 37
|
 |
« Reply #5 on: August 11, 2011, 09:38:48 am » |
Sorry to harp on, but I'm a bit confused now - the TIP102 conducts when there's power applied to it's base, doesn't it? So I'm triggering the power on by giving it some volts, and the Arduino takes over and keeps supplying enough volts to keep the TIP conducting.
When it's time to switch off, the Arduino output goes LOW, causing the TIP to stop conducting.
Or have I got things arse-about-face?
|
|
|
|
|
Logged
|
|
|
|
|
Manchester (England England)
Offline
Brattain Member
Karma: 269
Posts: 25417
Solder is electric glue
|
 |
« Reply #6 on: August 11, 2011, 11:16:37 am » |
Yes you have it right.
My worry is the potential thrashing about of the arduino pin as the power dies, it might just trigger it on again.
|
|
|
|
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15310
Measurement changes behavior
|
 |
« Reply #7 on: August 11, 2011, 11:21:55 am » |
When I've wanted project with manual on/automatic power control I've used a small single coil latching relay circuit. Draws zero current once latched on. Software turns output pin high in setup function, set output pin low when program wishes to power off. http://img25.imageshack.us/img25/563/08miq7.jpgLefty
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 37
|
 |
« Reply #8 on: August 11, 2011, 11:29:09 am » |
@Grumpy_Mike - thanks for checking for me! I'll buy the bits and have a play.
@retrolefty - Yup, a relay was my first thought, but I've only got one 5v/latching one knocking about and I want to save it for bigger badder things. Thought it would be a useful exercise to try and keep the whole thing solid-state now I'm getting a little more experienced with all the analogue 'glue' needed to have my AVRs talk to the outside world.
[edit:] Just looked at your schematic; never come across single coil latching relays before, I've only got double-coil ones. Interesting. A bit confused about C1, though; why is it there? Doesn't it stop the current flowing before the relay's even had a chance to think about moving?
|
|
|
|
« Last Edit: August 11, 2011, 11:32:13 am by howiem »
|
Logged
|
|
|
|
|
Left Coast, CA (USA)
Offline
Brattain Member
Karma: 279
Posts: 15310
Measurement changes behavior
|
 |
« Reply #9 on: August 11, 2011, 12:15:50 pm » |
Just looked at your schematic; never come across single coil latching relays before, I've only got double-coil ones. Interesting. A bit confused about C1, though; why is it there? Doesn't it stop the current flowing before the relay's even had a chance to think about moving? No, upon intital digital output high, enough charging current flows through cap to latch relay on, once cap charges to full +5vdc, current flow stops, but the charged cap then contains enough charge to reverse current flow when output pin goes low, resetting the relay. It's a cleaver little circuit that is more then meets the eye at first. The resistor shown is optional as if you try and turn the circuit back on too soon before the cap has fully discharged it won't relatch, the resistor ensures the cap fully discharges when off. If one doesn't mind the continous 13ma current flow draw of the relay coil, then the cap and resistor can be done away with and relay just wires from ground to the output pin. By the way Pololu seels nice sold-state power switches: http://www.pololu.com/catalog/product/750Lefty
|
|
|
|
« Last Edit: August 11, 2011, 12:21:59 pm by retrolefty »
|
Logged
|
|
|
|
|
United Kingdom
Online
Faraday Member
Karma: 130
Posts: 4644
|
 |
« Reply #10 on: August 11, 2011, 01:02:45 pm » |
I've just posted a schematic to solve this very problem in thread "Switch Arduino ON, it does tasks, then Switches self OFF" which is also in this section of the forum.
|
|
|
|
|
Logged
|
Formal verification of safety-critical software, software development, and electronic design and prototyping. http://www.eschertech.com
|
|
|
|
Calgary, AB
Offline
Newbie
Karma: 2
Posts: 46
Arduino Newbie
|
 |
« Reply #11 on: August 11, 2011, 04:29:16 pm » |
Hi Howiem
I was a litle concerned with your design with having the transistor in the base of the 7805. This will create an offset that will increase the output of the 7805 to about 5.7Vdc and could also cause some instability if the voltage across the TIP102 varied. Since there is no voltage on the GND pin of the 7805 and very little current, I doubt it would work without adding a resistor from +9V to the collector, and I am not sure that would turn off the 7805.
REMOVED solution, thank you Magician for pointing out the err in my version.
Regards Bill
|
|
|
|
« Last Edit: August 12, 2011, 09:21:15 am by Bill_Kerr »
|
Logged
|
Don't you just hate ONE D 10 T problems?
|
|
|
|
Montreal
Offline
Edison Member
Karma: 16
Posts: 2207
Per aspera ad astra.
|
 |
« Reply #12 on: August 11, 2011, 05:11:14 pm » |
IMHO, it's wrong way to switch output by disconnecting a ground of 78XX. It would send higher output voltage to load, up to unregulated Vin ( 9V ), creating serious threat to load.
|
|
|
|
« Last Edit: August 11, 2011, 05:21:45 pm by Magician »
|
Logged
|
|
|
|
|
Montreal
Offline
Edison Member
Karma: 16
Posts: 2207
Per aspera ad astra.
|
 |
« Reply #13 on: August 11, 2011, 06:07:45 pm » |
@Bill_Kerr: nice try, but it's not gonna to work eather. (At least no smoke hazard  In order to keep it "on" Atmega has to output on control pin whatever voltage it getting as VCC plus 2 x p-n junction (1.4 V) what, obviously, it couldn't do. I'd suggest to have a look on RuggedCircuit "high side drive" http://ruggedcircuits.com/html/circuit__19.htmlonly instead of solenoid and diode, collector should be connected to 7805 input terminal. In "off" state wouldn't be any current, which is important with battery power source.
|
|
|
|
|
Logged
|
|
|
|
|
Offline
Newbie
Karma: 1
Posts: 37
|
 |
« Reply #14 on: August 15, 2011, 04:42:20 am » |
Yup - as many suspected, my circuit doesn't work properly - it latches "on" beautifully, but when the Arduino's finished it's task and sets the power-latch-pin LOW, the power never goes all the way off. It's obvious in hind-sight what's going on - because I'm effectively disconnecting the ground from the Arduino, the whole Arduino/load part of the circuit ends up floating at VDD, including the power-latch-pin, meaning current flows through the B-E part of the TIP102, keeping it all switched on. Glad I tried doing this way, though, if only because I've learnt a few important lessons, and my arduino has survived  When I get some time I'll have a look at Magician's high-side drive approach, or the two-transistor bi-stable or flip flop approaches (thanks, Grumpy-Mike and dc42). If all else fails I can always drop in my last precious latching relay to do things the old-fashioned way. @Bill_Kerr - good point, hadn't thought about the offset effect of having silicon on the base of the 7805... oops Flippin 'eck, the digital side of electronics is sooooooo much easier [logical, ho ho] than analogue. Getting there, though 
|
|
|
|
|
Logged
|
|
|
|
|
|