Somewhere under that mess is a 555-timer |
I wanted to make a circuit that would be turned on by a push-button switch, supplying a load with a relatively high current, run for a fixed (but configurable) length of time, then turn itself and the load off automatically, using next to no power when in 'standby' mode, waiting for the next button press.
The reason I wanted to do this is that there's a sink on our sailing boat which gets emptied by an electric pump. At present, you have to stand there, holding a button to run the pump until the sink is empty. Wouldn't it be nicer to be able to press the button then walk away to carry on with life? Well yes, it would! Let's see if we can do something about it!
The pump can run dry without being damaged, so it doesn't matter if it overruns slightly once the sink is empty. What I basically need to do is set the delay a bit longer than the average length of time I stand there holding the button. It would be cool to have a sensor that would report when the sink was empty and stop the pump at exactly the right time, but that would introduce a lot more complexity into the project. One thing that I have learnt from my experience with electronics on boats is that simple is better. Once salt air starts getting into things, all hell breaks loose! I tend to get carried away and want to automate everything. Then it breaks and my wife gets grumpy. On a previous boat, I had all the lights rigged up to a central control system. When things headed South with the control system, it was like a disco in there!
A further consideration is that I would like to be able to run the sink in manual mode i.e. how it currently is - hold the button down to run the pump, let it go to stop the pump. I want to do this because the system runs on battery power. If the batteries are getting low, I don't want to waste juice by having the pump running for 30 seconds if there's just a splash of water to be emptied. Most importantly, if the timing circuit breaks, I don't want to be left with a sink full of dirty water while hearing "I told you so" coming from the direction of my wife!
I remembered using the 555 timer back in school. It's a useful little IC which can be used in a surprising variety of ways. After a bit of investigation and experimentation with different configurations, I decided to go with the standard monostable circuit but modified so that it triggers itself when the circuit is powered up.
Here is the circuit that I ended up with:
It would have been simpler to use an N-channel MOSFET as a low side switch because then the output of the 555 could be connected directly to the MOSFET's gate. However, I generally don't like low side switching "out in the wild". On a PCB as part of some logic system, I think it's fine, but I don't like devices having power continuously on their live rails. If some water caused a short between the pump's negative supply and ground, the pump would start running and not stop until the batteries were completely dead. I should mention that it's a 12V system, so the risk of electric shock isn't an issue.
This is why I went with a P-channel MOSFET, so that I could switch the positive rail, but I then had to invert the timer's output using an NPN transistor. Make sure the MOSFET can handle enough current to run your intended load. Although I haven't tried it myself, I think you can simply put multiple MOSFETS in parallel to increase the current limit, but you might want to investigate any caveats of this approach before trying it.
How the circuit works
There are already plenty of good resources on exactly how a 555 timer works, so if you want to know all the details, you can look them up, but in this case, all you need to know is:
- To start the timer running (and set the output high), the trigger pin needs to be pulled down to below 1/3 VCC
- To stop the timer running (and set the output low), the threshold pin needs to be pulled up to above 2/3 VCC
Because the trigger pin is connected to the discharged capacitor, C2, which is initially at 0V (i.e. below 1/3 VCC), the chip is triggered as soon as it powers up, starting a timing cycle.
Because C2 is connected to VCC via a resistance, it will slowly charge up and, after a certain amount of time, it will reach the magic threshold voltage of 2/3 VCC. Because a potentiometer is used, you can, obviously, speed up or slow down how quickly the capacitor charges, thereby extending or reducing the time delay of the circuit. With the values of resistance that I chose, the delay can be set to anywhere between about 5 and 30 seconds.
Once the threshold voltage has been reached, the timer sets the output low and also connects the discharge pin to ground, discharging the capacity ready for the next timing cycle. R3 stops the capacitor draining too quickly. Its value isn't too critical - it was just the first low-value resistor that I picked up. Without it, I found that the timing cycle would restart. I guess that the trigger pin was falling below 1/3 VCC before the residual charge in the circuit had been used up.
Once the timer puts its output low, it shoots itself in the foot and kills its own power supply. Q2's base is starved of current and stops conducting across its emitter/collector. This allows the base of Q1 to be pulled to VCC by R1, and BOOM it stops conducting across the drain/source and the power to the 555 is cut. Lights out, no talking, sleep well!
The only thing that can power the circuit back up so that the pump will start running again is to manually connect the Q1's gate to earth, which is done via the push button, S1.
C1, across the Q2, is there to prevent any induced currents, static charge etc. from firing the circuit up. I was finding that if I touched the live side of the circuit, it would start up and it would also run when it was first connected to the power. I tried a 100nF ceramic capacitor at first, but that wasn't beefy enough to absorb these errant currents.
The DPDT switch, S2, is used to completely bypass the timing circuit and directly connect the push button to the motor, to allow the "WCM" mode of operation (Wife-Compatible Manual mode!).
The LED lights up when the output is on. This lets you test the circuit/set the time without having a load connected and it will allow for easier fault finding if something stops working after the circuit has been installed under the sink. R5 is a fair bit larger than necessary, but I only needed the LED to light dimly seeing as it will be installed in a dark cupboard under the sink.
The flyback diode, D2, is present to protect the circuit because I'm using it to drive an inductive load. If your load isn't inductive, you can leave it out.
I decided to use a low-power CMOS version of the 555 timer. I don't see any reason why you couldn't drop an NE555 into this circuit, although I haven't tested it myself.
I'm using 12V, but this circuit can be used, unchanged, on a fairly wide range of voltages without affecting the timing. Just check the datasheets for the 555 timer, MOSFET and capacitors that you use to ensure they can all handle whichever voltage suits your needs. In my case, I could use anything from 2V - 15V (or even 18V if I fancied living on the edge and pushing the 555 to its absolute maximum rating!).
Finally, there is no 0V output from the circuit because I will connect the pump directly to the battery negative and only ground the timer circuit with a thin wire spurred off the main negative lead. There didn't seem any point making thick lines on the stripboard to carry the pump's high-current back to ground, as I had to do with the positive trace supplying the pump.
I'm using 12V, but this circuit can be used, unchanged, on a fairly wide range of voltages without affecting the timing. Just check the datasheets for the 555 timer, MOSFET and capacitors that you use to ensure they can all handle whichever voltage suits your needs. In my case, I could use anything from 2V - 15V (or even 18V if I fancied living on the edge and pushing the 555 to its absolute maximum rating!).
Finally, there is no 0V output from the circuit because I will connect the pump directly to the battery negative and only ground the timer circuit with a thin wire spurred off the main negative lead. There didn't seem any point making thick lines on the stripboard to carry the pump's high-current back to ground, as I had to do with the positive trace supplying the pump.
No comments:
Post a Comment