Soft Latch with Hardware "Watchdog" - Page 1
Forum section: electronics / projects

author: Piedtyper
author_rank: Contributor
timestamp: December 15, 2016, 07:22:56 pm
content: Hello,I'm working on a project that would use a soft latch power switch. I would like the switch able to be refreshed with a pulse from the micro controller every 500uS or so. If that refresh pulse doesn't occur then the system turns itself off.I believe the circuit below will work except for the issue of Q3 conducting and turning the power back off before the micro can wake up and provide that pulse to charge the capacitor.What I need is a way to delay Q3 for ~2mS to make sure the micro is up and running. I thought of using a one-shot 555 circuit and I think that would work but it just seems too cludgy to me. Is there a better way to get a charge into C2 only once at power up?Thanks in advance!

author: rob77
author_rank: Super Contributor
timestamp: December 15, 2016, 08:54:42 pm
content: Quote from: Piedtyper on December 15, 2016, 07:22:56 pmcan you elaborate a bit more in detail on how the switch should work and also the how the Q3 pnp transistor should work ?

author: Piedtyper
author_rank: Contributor
timestamp: December 15, 2016, 09:52:11 pm
content: Quote from: rob77 on December 15, 2016, 08:54:42 pmHi. Thanks for the reply.The switch itself is based on a schematic I found.http://www.edn.com/design/power-management/4427218/Latching-power-switch-uses-momentary-pushbuttonThe additional components I added/inserted are R4, R5, R6, C2 and Q3. My reasoning was to turn the circuit off I either need to bring the gate of the mosfet (Q2) high or the base of Q1 low. Either of which should turn off the latch..I think/thought.Of the two I believe Q1 low would be the easiest. Since I wanted to have this watchdog I thought along the lines of a sample and hold. Charge a cap and use that to hold the voltage up for a short period of time. Since it was a charge that led me to a PNP since the natural discharge of the cap would then turn the circuit off when it dropped below the low threshold of Q3's base which would allow current through Q3 which would then un bias the base on Q1 which in turn would bring the gate of Q2 high and shut down the circuit. As long as the micro keeps C2 high enough Q3 shouldn't conduct.I'm probably not explaining this well but does any of that make sense? Any questions just let me know and I'll certainly try again.Thanks,

author: Zero999
author_rank: Super Contributor
timestamp: December 15, 2016, 10:17:18 pm
content: Quote from: Piedtyper on December 15, 2016, 07:22:56 pmThe schematic you posted won't work. The pulses don't go into the base or gate of any transistor. They just go to 0V via R1 and C1.You need a missing pulse detector, which could be implemented with a 555 timer, comparators, logic gates or discrete transistors.

author: Piedtyper
author_rank: Contributor
timestamp: December 15, 2016, 10:36:31 pm
content: Quote from: Hero999 on December 15, 2016, 10:17:18 pmThe "pulse" or input from the Micro goes through R6 to charge C2. Won't the voltage on C2 keep the gate of Q3 high so it doesn't conduct until C2 discharges through R5?

author: Zero999
author_rank: Super Contributor
timestamp: December 15, 2016, 10:55:35 pm
content: Quote from: Piedtyper on December 15, 2016, 10:36:31 pmOh, I see. I was looking at the push button switch, which won't do anything.It still won't work. Q3 is a PNP transistor and is wired backwards.

author: Piedtyper
author_rank: Contributor
timestamp: December 15, 2016, 11:03:36 pm
content: Quote from: Hero999 on December 15, 2016, 10:17:18 pmDoh! Sorry I'm an idjit.I've flipped Q3 and re-attached the section of interest in the schematic. Sorry about that. Assuming Q3 now would work and conduct when C2 is discharged, how would I go about an initial charge of that capacitor when power is first applied. I've looked at the missing pulse detector and I might be able to get that to work or go with a one-shot of a 555 but I was hoping for a better way.Again. Thanks.

author: onlooker
author_rank: Frequent Contributor
timestamp: December 16, 2016, 03:26:58 am
content: QuoteThe real problem with R1||C1 is that SW1 is doing nothing useful. I guess by pulses you really meant to say SW1.

author: Piedtyper
author_rank: Contributor
timestamp: December 16, 2016, 04:14:41 am
content: Whooops.No I do mean pulses from the micro but then that would assume I have the right freakin' schematic posted. The corrected/modified version is below. I had the switch leg going to Vcc instead of the gate.I've changed the pnp to an npn (Q3) and added an npn to allow the micro to send a signal to Q4 to discharge C2 periodically.If C2's voltage gets high enough to bias up Q3 then the circuit should shut off...I think.The path through R9 should charge the capacitor slowly enough it will stay low long enough for the micro to take over and switch Q4.Sorry for the mistakes in the earlier posts...and let's be honest..the probable mistakes in this post/schematic.Still looking for options and suggestions and I appreciate all the replies.

author: Zero999
author_rank: Super Contributor
timestamp: December 16, 2016, 09:03:51 am
content: Now SW1 will turn it on but not off, which may be acceptable, if you want to connect the switch to an MCU I/O pin and do the shut down in software.There's still a potential bug though. What happens if the MCU freezes with its output in the high state? The circuit will remain on, which is probably not what you want to happen.

author: Piedtyper
author_rank: Contributor
timestamp: December 16, 2016, 04:25:12 pm
content: Quote from: Hero999 on December 16, 2016, 09:03:51 amProbably a lack of understanding on my part but...When the circuit is conducting and SW1 is pressed won't C1 discharge/raise the voltage to the gate of Q1 and turn it off since C1 is being kept at Vcc via R1?You're 100% correct. If the micro losses its marbles stuck high then it won't shut down. The plan would be to have the micro with a Watchdog and pull the pin low on reset/power on. It sure seems like this whole thing's devil is in the details.Assuming SW1 will turn things off I guess I'm going to have to fight with LTSpice first and then build the dang thing to test.

author: rob77
author_rank: Super Contributor
timestamp: December 16, 2016, 06:53:28 pm
content: Quote from: Piedtyper on December 16, 2016, 04:25:12 pmok. once again and slowly please...facts:- C1 is being discharged by R1 all the time - that's clear because R1 is parallel to C1- when the circuit is in on state the collector of Q1 is at 0V - therefore pushing the button does literally nothing.

author: BloodyCactus
author_rank: Frequent Contributor
timestamp: December 16, 2016, 09:09:25 pm
content: you should look at the '1232' family of chips.here is one example datasheethttp://www.mouser.com/ds/2/268/MIC1232-779050.pdfds/micrel/microchip etc. they can watch voltage, and/or also take a heartbeat, if they dont get the heartbeat they trigger reset. very handy chips.

author: Zero999
author_rank: Super Contributor
timestamp: December 16, 2016, 11:39:29 pm
content: Quote from: rob77 on December 16, 2016, 06:53:28 pmYes, I think he drew a line in the wrong place. It should look like this.

author: MattHollands
author_rank: Frequent Contributor
timestamp: December 17, 2016, 12:21:14 am
content: Quote from: BloodyCactus on December 16, 2016, 09:09:25 pmThese chips don't have soft-switching functionality though, they're just a watchdog.A while ago I reverse engineered the soft-switching circuit from the LCR45 meter.projects.matthollands.com/2016/09/09/soft-switching-reverse-engineering-lcr45/.You will see that the OFF_L net needs to be held high to keep T1 conducting. Obviously this doesn't perform the watchdog function that you wanted, but if you just added a high pass filter, it would probably work. As shown in my screen shot, by filtering a 500kHz square wave, you can get a steady DC voltage output which could drive OFF_L. As soon as you stop driving the square wave (ie it gets stuck at 5V or 0V), the output drops to 0V and T1 turns off, which turns off T2 and the whole system turns off.(the values used here are pretty bad, but if you use 1M for the resistors and 1u for the caps and a shottky diode you can probably get 1V constant output which is enough to drive something like the Si2302CDS FET which could replace T1 in the schematic. Also get rid of R4 and R10).(Vn001 is the voltage from the votlage source, Vn002 is the voltage on the left of the diode, vn003 is the voltage on the other side of the diode)

author: Zero999
author_rank: Super Contributor
timestamp: December 17, 2016, 02:26:38 pm
content: Well you could add a transistor to the original circuit, which turns it off, biased so it's normally on and turn it off using a negative voltage multiplier, using pulses from the MCU.

author: MattHollands
author_rank: Frequent Contributor
timestamp: December 17, 2016, 03:05:15 pm
content: Quote from: Hero999 on December 17, 2016, 02:26:38 pmNice idea. For my own interest/demonstration I simulated the pulse-to-dc circuit - credit to you for the idea. This is with a 1khz square wave.

author: Piedtyper
author_rank: Contributor
timestamp: December 17, 2016, 04:12:02 pm
content: Quote from: Hero999 on December 16, 2016, 11:39:29 pmYes. Absolutely correct. I noticed that when I actually processed what rob77 was saying. The line from the top of the cap should go to the collector of the BJT on the source leg of the mosfet. I've come close to beating LTSpice into submission and I'm starting to get realistic results. Thanks very much for the catch.

author: Piedtyper
author_rank: Contributor
timestamp: December 18, 2016, 05:11:36 pm
content: First let me thank those that responded. Your input is appreciated and was crucial.I believe we have a solution. The circuit works in LTSpice although I was hoping for it to work up to ~13.5V and it doesn't. I don't understand why. There is some nuance of the circuit that evades me.Attached are the LTSpice schematic and trace showing Vout stepping from 6.5-13.5V input. The signal from the micro is cut at 6s while the main switch continues. Clearly the addition of the negative voltage doubler and npn transistor work great!If anyone can help me understand why it behaves as it does at higher voltages for input I would appreciate it. I hate not understanding why something happens.Again. Thanks!