Idea for a USB "sleep switch"

Here’s something that I think would be really cool and fairly easy for an experienced electronics guru here to work out:

a USB hub that is hooked into a wall switch such that when this switch is turned off, the computer that is connected to the hub goes to sleep, and can’t wake up till the wall switch is turned back on.

Right now I have a home theater setup with the amplifier, DVD player, computer monitor, internet, wireless hub, and projector screen on separate, switched outlets. The computer (and it’s external drive) is plugged into an always on outlet. Right now, I can turn any component on and off simply by hitting a switch on the wall. The only thing I can’t do that to is the computer (and it’s external drives). Naturally I don’t want to actually power off the machine, but it’d be nice to be able to get it to sleep simply by hitting another wall switch. That’s why I thought a USB hub would be the way to go. It would be plugged into the always on power as well, and when an external switch is thrown it sends a command to the computer connected to it to go to sleep, and then “disconnects” all the other inputs on the device so that simply wiggling a mouse or hitting a key on a keyboard will not wake it up. Once the hub is told to “wake up”, all USB connections would be reestablished, and the computer itself prodded to wake back up.

Whaddaya all think?

Ben

My idea for how to do this:

Keyboards sometimes have power buttons on them - pushing this button (in Windows, not sure about other OSes) can turn the computer off, hibernate it or whatever. You can also set up your BIOS so that your computer turns back on if it gets a keystroke.

So, using a microcontroller with USB, possibly even an ATTiny part running AVR-USB, make yourself a USB “keyboard”. Power it off the USB port, and give it a means of sensing AC. If AC appears, make the microcontroller act as if someone hit the space bar. If it disappears, make the microcontroller act as if someone hit the aforementioned power button.

If you’re not using the PS2 keyboard port on your computer, you could use that instead of USB.

There are lots of ways of sensing AC. I’d recommend using a cheap wall wart and clamping its output (series R, shunt zener) to a suitable voltage to drive it into a microcontroller pin.

that’s how I would do it. The USB PICs (e.g. PIC18F2550) can do this and Microchip has HID source code including keyboard free for the download. You could probably adapt the $25 UBW http://www.sparkfun.com/commerce/produc … cts_id=762 to do it.

On sensing AC - with a cheap wall wart, you can directly input to a pin on the UBW HW. I’d use a zener or a couple of diodes to limit the voltage. I’d also use a timeout - watch for the power being gone for, say, 20 seconds so power glitches don’t shut you down. Then send the shutdown command. You could do it by mimicking the keyboard hibernate or sleep command.

Sounds like a job for a slightly modified [CapsLocker.](Stealth USB CapsLocker | macetech.com)

Heheh, you could always buy a UPS with shutdown capability and plug it into an outlet that is controlled by a switch. Then set up the pc to boot when power is restored.

The capslocker seems the closest.

I don’t think rebooting is an option as it takes too long. I really want to wake up and sleep the machine many times a day.

Just implementing a simulated power press on a keyboard also lacks the functionality of keeping any other devices from waking the machine up (any other USB devices that is).

I really think this thing needs to be integrated into a USB hub so that it does dual duty: send the sleep command similar to the keyboard power switch idea that was suggested above AND shut down any USB connections from any external devices other than itself.

Anyway, just an idea. Way beyond my abilities/time/interest to actually implement.

cheers

Ben

Why not do this in software?

Just use the UBW as an IO input to detect if the switch is in the “sleep” position. If so, then have software put the machine to sleep. If it wakes up, check the switch, if it should be asleep, send it back to sleep. Just have the UBW send a wakeup event of some kind [either keyboard emulation, or something more generic, I don’t know that bit of the USB spec] when the switch is flipped to wakeup.

Cheers,

–David Carne

That actually sounds like a decent idea. Much easier to implement… which is irritating because what seemed totally out of my reach a moment ago now seems tantalizingly close - and I have absolutely no free time to be engaging in yet another project!

Sigh.

An easier way, that would require hardly any work would be to find a wall switch that is momentary (you can get them to start bathroom fans that are on a timer) and wire it in parallel with your computer power button.

Set your computer up to sleep/hibernate on a short press of the power button or shut down on a long press.

The next step is to get a master/slave power board that enables the slave outputs when the masters load goes over a certain level.

That way you could have only one switch on the wall and the rest hidden away.