I'm working on a power supply design and I wanted to have the output on/off button just a momentary push button. The main reason for this was to make sure that the output was always off when the power came back on. You don't want to have the output get knocked on whilst moving the power supply and accidentally put too many volts into a prototype!
The basic requirements are:
- Must toggle a logic output on/off each time the button is pressed.
- Must be reliable and not glitch.
- Must always start up in the "off" state.
Initially I tried using a flip-flop to do the latching, I set it up to toggle on each clock pulse and then fed the clock from the switch. I found it very difficult to get the switch debounced reliably, the logic would toggle several times each time I pressed the button and it was never reliable which state you'd end up in. I tried various capacitor based debounce schemes but they didn't seem to work, the debounce reduces the rise-time of the switch and stops the flip-flop from clocking properly.
What I needed was a more analogue solution, the 555. The 555 uses an analogue comparator, so the rise-time of the switch is irrelevant. The monostable and multi-vibrator modes of the 555 are well known and often used, but it can also be used in a bi-stable circuit. I found this article and built up a circuit based around this. I've added a capacitor and resistor to the reset input of the 555 to ensure that it is held low at startup. This ensures that the ouput will always be "off" when the circuit is powered on.
I've built up a prototype on breadboard to test out the circuit. The circuit works well, but since I plan to drive a number of relays and LEDs from the final circuit, I wanted to provide some fan-out from the 555. I've added a 74HCT04 hex inverter chip to drive up to 5 outputs. One inverter is fed from the output on pin 3 of the 555. The output of that first inverter then runs each of the other inverters giving a logical buffer (no inversion anymore) and independent outputs that can drive separate loads.
This was a brilliant example of where decoupling is absolutely essential, when I added the 74HCT04 to the bread board it would constantly reset the 555 circuit (not helped by the fact that most of the gates were not in a defined state). Adding a 100nF ceramic capacitor across the power supply on the 74HCT04 fixes it and makes the circuit reliable again.