Intro: Latching Momentary Switch for ATX PSU Conversion
A what? I hear you say! A momentary switch which is latching? such a thing is not possible, surely!
But it is. I found the design on the net and tweaked it a bit so that if connected to an ATX psu it will toggle to the correct setting if the PSU shuts itself down, which is the behaviour you get with a PC's power switch.
This project came into existence because I got annoyed having to press the power button twice after accidentally shorting out the supply, which caused it to shut down.
- ATX PSU conversions are great, but you need to have a latching switch to turn it on. You probably already know that the switch on a PC is momentary, so this fact in and of itself is slightly annoying. So we bung in a latching switch and live with it.
- Fancy switches, such as the "angel eye" one shown here cost a lot more in a latching version than they do in a momentary version, because they're more complicated. So a way to use the momentary version is desirable for this reason.
- Another reason it's desirable is that latching switches have a different profile in the open or closed position. Momentary switches always go back to the same shape when you press them.
- The final reason a momentary switch is desirable is this. When you accidentally short the terminals of your ATX PSU it shuts itself down. So now with a latching switch you have to turn it off, even though it's turned itself off, before you can turn it on again. With a momentary switch, you should be able to just press the switch one time, and off you go again.
I based this project on the schematic found here: http://www.smallbulb.net/2014/435-single-button-p... and here: http://sound.whsites.net/project166.htm There are many variants of the design all over the web.
The circuit is simple, and very cheap to build. The video is just to show it turning the PSU on and off, and resetting itself when the PSU cuts out. What I forgot to show is turning it on again after a cut-out!
Step 1: How It Works
The circuit relies on a 555 timer.
The description below refers to the timer as if it is a bipolar device, however a CMOS one is essentially the same, you just have to read "collector" as "drain". Please refer to the 555 internal diagram when reading this description.
Notice that the threshold and trigger pins are connected together. They are held at a little under half the supply voltage by R1 and R2. The exact voltage isn't important, but it needs to be between 1/3 and 1/2 Vcc. The usual version of this circuit has it at 1/2 Vcc but that may not work for the method used here to start the circuit with the output high.
C1 ensures the circuit is powered on with the output in a high state by pulling the control voltage pin high when it receives power from the standby wire. This is needed because the ATX PSU requires the switch wire to be pulled low in order to turn it on. It works because it raises the internal reference voltage at the "trigger" comparator to 1/2 vcc, slightly above the point set by R1 and R2. This makes the comparator pull the internal flip-flop's "set" input high. It has no effect on the "threshold" comparator because the reference is already higher than the threshold pin anyway.
The ATX switch input (green) is connected to the discharge pin on the timer rather than the output, as it requires a pull-down to activate, rather than a high or low input. The current is minuscule so it won't harm the discharge transistor.
So to start with, the pwr_ok input is at 0v, and the circuit is powered from the standby voltage, which is 5v. This voltage is on all the time regardless of whether the PSU is switched on or off. The output is at 5v and the discharge transistor is turned off, so the ATX switch input is also sitting at 5v. The pwr ok signal goes high when the supply is ready to use, and goes low very quickly if the output falls out of specification.
When you press the button, in this state, the timer's threshold and trigger pins are pulled up to 5v. This has no effect on the trigger pin, which is already above the trigger voltage. But it does affect the threshold pin, which is being held below the threshold voltage. The internal flip-flop's reset input is activated, and this is what makes the output of the 555 go low and the discharge transistor's collector becomes a path to ground.
The 4.7uF capacitor, C2, gets slowly charged at initial power on via the 220k resistor, R3. It is this capacitor that provides the energy to pull the threshold and discharge pins high, or provides a short duration path to ground to pull them low. This capacitor helps eliminate false triggering of the circuit since it takes about a second to charge or discharge, so you can't turn the supply on and off very quickly.
So now the output is low and the ATX PSU is turned on.
Next, you've finished experimenting and you press the button again. This time C2 is in a discharged state, so 0v is connected to the threshold and trigger pins. This has no effect on the threshold pin, which is already being held below the threshold voltage. But it does affect the trigger pin, which is being held above the trigger voltage. The internal flip-flop's set input is activated, and the so the 555's output goes high and the discharge transistor's collector becomes an open circuit, turning off the PSU.
Suppose whilst you are experimenting, Something Goes Horribly Wrong and you short circuit the output of the PSU, which then shuts itself down to prevent damage.
In it's original form, this circuit would still be in the "on" state, much like a latching switch, as it's power supply from the standby output is constant. It has to have an extra signal to make it turn off.
In order to accomplish this, an extra capacitor couples the PWR_OK output of the PSU to the threshold and trigger pins. This way, when the PSU shuts itself down, it pulls these two pins low briefly, and sets the output high.
As far as I can see, this is the only way to cause the PSU shutting itself down to also toggle this switch. If it's not working for you, try increasing the value of C3. If it's still not working, you should consider connecting a monostable circuit between C3 and the combined trigger and threshold pins.
Finally, an indicator shows that the PSU is turned on. Because momentary switches are so much cheaper, it's easy to have a nice illuminated switch like this one, even on a tight budget! The LED cathode goes to 0v. The LED in this switch has a built in current limiting resistor, so the anode can go straight to 5v. For a standard LED though, you should include a current limiting resistor. 390 ohms is a good starting value, you may want to try going higher or lower till you get a brightness you like.
Step 2: Component List
- An illuminated momentary switch. The one I got has a built in current limiting resistor for it's LED. This type is listed as "angel eye" on eBay. It doesn't have to be an illuminated switch, it just looks nice.
- 555 timer. I used a SMD version so I could make a board to fit through the switch mounting hole.
- 33k resistor
- 27k resistor
- 220k resistor (can change to adjust delay time)
- 1uF capacitor
- 100nF capacitor (may need to change for a larger value)
- 4.7uF capacitor (can change to adjust delay time)
- PCB making materials, or prototype board.
I got the switch on eBay. I already had a stock of the 555 timers, and the other components were free.
Step 3: Construction
I built the prototype of the circuit on a piece of perforated board. The 555 timer is an SMD chip. I just sat it on top of a piece of "Koptan" tape (much cheaper than Kapton tape!) and connected a couple of the resistors directly to it to hold it in place. The other components I connected with fine magnet wire. If you adopt this style of construction it's easier to use DIL devices, not SMD, though!
I wanted the PCB to be able to be attached permanently to the switch and to pass through the switch mounting hole. For this reason I made a board 11mm wide by 25mm long. It's provided with terminals for the switch contacts and the built in LED. I fitted wire "tails" and soldered a pin header to them for ease of connection to the PSU. I applied heatshrink tubing to hold the wires together and cover their connections to the header.
If you are using a different type of switch you may find it won't fit in this way.
I actually made a massive mistake when I made the board, I created a mirror image version! Luckily because the circuit is so simple I only needed to fit the 555 timer upside down to remedy the problem. I hope you won't make my mistake, and get the board the proper way up. The PDFs are for top copper.
There are lots of guides to making PCBs, I even wrote one myself! So I won't go into how to make the board, here.
Solder the chip in place first. making sure you get the correct orientation. Pin 1 goes away from the line of resistors down one edge. Solder the other surface mount components next.
I used an electrolytic cap for C2 because I didn't have a 4.7uF ceramic one.
You have several options for C2:
- Low profile capacitor, no more than about 7mm tall
- Fit the capacitor with long leads so you can lay it flat against the board
- SMD capacitor of some kind
- Tantalum capacitor, which is very small anyway. Note the style of polarity marking is different to aluminium types
It just depends on what you have.
Ensure that the board will fit through the switches mounting nut. If you use an electrolytic cap for C2, check it will fit with this attached. I chamfered the edges of the board to get a bit of extra space.
Next, connect the board to the switch using the 2 large pads at the end. You could cut slots in the pads and bury the switch terminals in them, if you really need to get the board close to the centreline of the switch, but I wouldn't recommend it. Another option is to drill holes in the pads and fit pins which you can solder the switch to on the plain side of the board. Use short lengths of solid wire to connect the LED terminals. Only solder them, don't wrap the terminal as you may find you need to disconnect it. If your illuminated switch doesn't have a built in resistor, replace one of these pieces of wire with one.
Finally, if using pin headers or another type of connector such as JST, solder these in place now. If not, fit the switch in it's mounting hole and solder the wires directly to the board if you didn't already fit wires.
Step 4: Finally
The best way to test the switch is by connecting to an ATX PSU. If you don't have one ready, you can still test it, see below.
- black wire of the ATX PSU to gnd
- green PS_ON wire to "power on"
- purple +5VSB wire to "5v standby" (wire may not be purple)
- grey PWR_ON wire to "pwr_ok" (wire may not be grey)
The grey and purple wires are actually reversed on my ATX PSU - something to watch out for!
If you are considering using any indicator other than a small LED as your "on" indicator, you should connect it to one of the PSU's main outputs, not the PWR_ON signal.
If you find the LED is pulling down the PWR_ON voltage too much, use the +5v instead.
When you initially power it on, you have to wait a second before the switch will work. This is deliberate and in addition to de-bouncing the switch, is intended to stop naughty fingers from rapidly power-cycling whatever the switch happens to be connected to. Once the switch is on, you have to wait another second before you are able to turn it off again.
You can change this delay by changing the value of C2 or R3. Halving the value of either component will halve the delay, but I wouldn't set it to less than about 200mS.
Connect the PSU to the mains. It should stay off. If it turns on immediately, you need to increase the value of C1. Interestingly, I found the circuit worked correctly in the prototype, but I needed to change the capacitor for the "real" version, so it's now actually 1uF.
Power the supply on, power it off again. Hopefully it's working so far! Power it on again, and now short circuit the +12v output of the PSU to 0v. It should turn itself off, and the switch should change to the off setting too. If you need to press the button twice to turn the PSU back on, it hasn't worked and you will need to track down the problem.
Don't try short circuiting the +5v rail, you may find it melts your wire instead of cutting out.
If you need to test the switch without an ATX PSU, you need a 5v supply to do so.
To test it this way, connect:
- 0v of the supply to gnd
- +5 of the supply to 5v standby
- an LED with current limiting resistor between +5 and "power on"
- a 10k resistor from pwr_ok to +5v
- a test lead to "pwr_ok"
The LED will come on when the timer's output is low, which is comparable to turning on an ATX PSU.
Short the test lead to 0v. The switch should turn off. Turn it on again by pressing the button a second later.
And that's it, testing complete!