Argh, soft switches

So what’s a soft power switch anyway? Let’s start with the converse: a regular light switch, say, of the tumbler type. You switch it in the ‘on’ position and voila, light. There’s a power cut and off it goes. But the switch maintains ’state’, so when the mains come back on, so does your light!

This doesn’t happen with soft switches. Pushing a soft switch momentarily closes a contact, thereby generating a signal. Typically this signal is interpreted by some circuit, turning on your laptop. Or if your laptop is already on it might put it into standby. The effect of pushing this switch depends on context. The pushbutton has no state, it just generate an event when it’s being pushed. No persistent state here. And context might get lost — after a power failure, for instance.

Context bites.

In itself this is not a bad thing, but the devil is in the details. The implementation of the circuit part can make a geek’s life miserable. I had an external harddisk enclosure sporting one of those soft power switches. Connect power, push the button, it’s on. Power cut? Off it goes (of course). Power restored — it’s still off. But I wanted it to be on whenever there is power. Duct-taping the button in the ‘pushed’ position (hey, ’state’!) didn’t do much good as, in my limited understanding, this particular switch appeared to work by ‘pulling down’ a signal from the high state to the low state. The circuit will never be armed! With the button pushed down when power comes back on, the high state will never be reached as any potential will just leak away through the switch, dammit.
I spent some time trying to solder around this problem, trying to delay the bridging of the contact with all kinds of contraptions made of stuff I had lying around (positive feedback circuit from LEDs and an LDR, fun) to no other avail than eventually frying the controller circuit. I’m such a n00b with electronics, I can’t even build a proper delay circuit.

Laptop relay

But that didn’t stop me from soldering up a solution to the following problem. My old netbook is performing home server duties now, which is nice as it’s energy-efficient, quiet, and has builtin UPS. This is the plan: If the mains go down it can keep running. After a while it sets an RTC wakeup alarm and suspends itself. The RTC alarm will be set ~12 hrs into the future, it will power up and switch on the UPS which powers the ADSL modem, border router, and switch. That way it can collect some mail. And then it shuts down the UPS, sets another RTC wakeup alarm…. wash, rinse, repeat, until battery power runs out.

Problems

  • So what if battery power has run out, and mains power gets restored?

Then I’d have to physically push the button to power the thing back on. I don’t want that. But there’s no ‘restore power state after power loss” BIOS option on this laptop. Lucky for me, with this particular piece of equipment I can just permanently short the same pins that the power switch shorts ­— no timing trouble as with the harddisk enclosure here.

  • So what if mains power comes back on after the server has just decided to go to sleep for another XX hours?

Well that would be a silly situation. I need the laptop to resume from standby in that case.
This posed problems as the pin shorting trick mentioned before doesn’t help in this case. Potential just keeps on flowing through the ‘pressed’ switch, regardless of the state of the mains power. So restoring mains power doesn’t generate an event.

Solution

…was to use a relay. The coil is wired to the internal 20V leads coming from the power connector (right picture). klz helped soldering this rather tricky one. The relais switch leads are soldered onto the switch wires (left picture, you can see the little switch connector). In the middle (middle) you can see the relais. It’s huge and makes the bottom plate of the laptop bulge a bit.
But it works! It generates the equivalent of a button push whenever mains power comes on.


Tags: , , ,