Two hosts power switch ###################### General principle ================= This project detects up to two host power state through the their usb port and switch on their associated devices' mains outlets (screen, sound amplifier, printer, etc). Devices might be shared (the same printer is used by both computers), in this case, the device is switched on by whatever computer is detected on. Flowchart ========= When detecting a host state change, the following happen:: .------------------. .-------------------. | Host state | | Skip filter input | | change detection | | (usb control) | '------------------' '-------------------' .--------------. | .-------------. | .------>| Switch relay | '-->| Skip filter |<--' | '--------------' '-------------' | | .---------------------. v | Start on/off timers | .---------------. '---------------------' | Update target | ^ | table |-------------' '---------------' Feature list ============ * Detect when one of the host is up (not in standby), switching on its associated devices (mains outlet). * Each computer has its own set of associated outlets to switch on. * An outlet may be shared between computers, if at least one of the computers is on the outlet is on (logical OR). * Each outlet have an optional delay before it switch on or off. Delay for on and off may be different. * Configuration for outlet associations and for the switch delay is saved in non-volatile memory. * Computer standby detection is isolated and done by a mini-usb plug (calibrated for standard 5 volts supply, but you might change the input tension according to the optical coupler and input resistor, see schematic for more details). Molex to usb cable might be done if all usb ports of the computer are always on and its standby is never detected. * There is one button for each computer to toggle its state (thus overriding its current state). The override is reset at the next computer state change. If the override reset is the same as the current state, you will see no change: if an override set the state to on, and the computer is switched on, the state change will not be seen until computer is in standby or off again or if another override is done. * There is one button for each outlet so it can be toggled off or on. This toggle bypass the configured delay. The outlet can be toggled again normally according to the associated computer(s) state change. * If at least one of the computers is on, global led is on. An individual led indicate the state of each outlet. * Very low power then no outlet nor computer is on: the MCU will sleep and consume near nothing and all led will be off. * Instead of pressing button, the dedicated control usb connection can be used to toggle state of things and to set a detection skip for the next off to on detection of a computer. * A low consumption power converter (near 0 watt in full standby) is used to power the MCU. Advantages compared to being powered by control port include being autonomous, not using control port to switch relay (might induce little current spikes), and keeping current state when unplugging controlling computer. Rationale ========= The power switch could have triggered computer wakeup instead of doing computer standby detection, but it is more complicated and it prevents using the keyboard or another source of wakeup to switch on its associated devices. The disadvantage is to need a way to skip the switch-on of the associated devices when it is not needed (for example when doing wakeonlan to read data in another location, one does not need the associated devices to be on). In my case, the wake-on-lan was an exception to the normal usage of my computer, so I made the skip choice to be in the workflow.