A Slug-Controlled Power Switch

19,741

Circuit Image

This page outlines the hardware and software design of a printer power switch that is controlled via USB from a Linksys NSLU2, also referred to as Slug. Although primarily designed for printer control, the unit can manage any device and can be operated from any Linux system. The NSLU2 functions mainly as a file and print server. To minimize energy consumption, particularly the 4W used by the printer while idle, the switch allows the printer to remain off when not in use. The printer's location, being upstairs, necessitated a remote solution to avoid unnecessary trips for switching it on and retrieving printed documents. While there are commercial power switches available, most are costly and designed for server environments, utilizing RS232 or Ethernet interfaces. A cheaper USB switch option exists but is limited to continental European sockets, prompting the decision to create a custom solution. The design incorporates an FT245BM USB-to-Parallel chip to enable USB control, utilizing one of its eight output bits to manage mains power through a triac. Initial testing was conducted with a breadboard prototype, requiring a foundational understanding of triacs. The ON Semiconductor documentation provided extensive information on triacs, including sensitivity variations in optocouplers. The K3020P optocoupler from Maplin is the least sensitive, requiring 30mA, while a more sensitive K3023P from Futurlec operates with only 5mA, allowing direct driving from the USB chip. Resistor R6 must be selected based on the optocoupler's peak surge current. Additional protection is achieved through a series RC filter across the triac, involving resistors R7 and capacitor C1. High-voltage capacitors in the range of 0.047 to 0.1 µF are recommended, though sourcing them can be challenging. The USB module includes a small EEPROM to store USB vendor and product IDs, which must be programmed using the same method as for SlugTerm. The selected vendor ID is EE17 and the product ID is 0002. The accompanying software includes the necessary code and schematic diagrams, as well as EEPROM configuration files. The main program, written in C++, facilitates power management through command-line arguments. It allows the user to turn the power on or off or to flash the power state. The slugmake.sh script compiles the Slug executable using a cross-compiler, which can be set up on a Debian PC. Finally, the integration with CUPS (Common Unix Printing System) is intended to automate power control upon job submission.

The electronic schematic for the printer power switch features the FT245BM USB-to-Parallel interface chip, which serves as the central control unit for the device. The chip connects to the USB port of the NSLU2, allowing it to receive commands from the Linux operating system. The output from the FT245BM is routed to a triac, which is responsible for switching the mains power to the printer. The triac is chosen for its ability to handle AC loads, making it suitable for controlling devices like printers.

To ensure reliable operation, an optocoupler is used to isolate the control signal from the high-voltage side of the circuit. This isolation is crucial for safety, preventing any high-voltage spikes from affecting the low-voltage control circuitry. The selected optocoupler's specifications dictate the necessary current through its input, which in turn influences the design of the surrounding components, such as resistors and capacitors. The RC filter across the triac, consisting of resistor R7 and capacitor C1, smooths out any transients and helps to stabilize the operation during switching events.

The EEPROM integrated within the USB module is essential for defining the device's identity on the USB bus. It stores the vendor and product IDs, which must be programmed correctly to ensure proper communication with the host system. The corresponding software includes routines for reading and writing to the EEPROM, facilitating the configuration process.

In summary, this printer power switch design exemplifies an efficient solution for remotely controlling power to a printer while minimizing energy consumption. The careful selection of components, adherence to electrical safety standards, and integration with existing software frameworks like CUPS enhance the functionality and usability of the device.This page describes the hardware and software design of a printer power switch controlled over USB from my Linksys NSLU2, aka Slug. The unit can, however, be controlled from any Linux box, and can switch anything, not just printers. My NSLU2 acts mostly as a file and print server. I can go for weeks without printing anything, so I want to keep th e printer switched off when I`m not using it (it takes about 4W while idle, which must be more than 99% of its total energy consumption). But it`s upstairs, and I don`t want to have to go up and down stairs once to switch it on and again to collect my printing.

So I decided to get a power switch. There are plenty of power switches out there. Mostly these are expensive things intended for server rooms (see this example ) with RS232 or Ethernet interfaces; USB would be more appropriate for the Slug. One cheap USB switch is this one which has been interfaced to a Slug, but it only seems to be available with continental European sockets.

So I decided to build my own. For USB control I decided to use the same USB module that I chose for SlugTerm, using the FT245BM USB-to-Parallel chip. I use just one of its 8 output bits to switch the mains power using a triac. Here`s a photo of my breadboard prototype: I needed to learn a bit about triacs before building the mains side of the circuit.

There is more than you could ever need to know in this document from ON Semi. Here is what I learnt: Triac optocouplers come with various different sensitivities; the K3020P that Maplin sells is the least sensitive and takes 30mA. Futurlec sell more sensitive versions (the K3023P needs only 5mA) which could be driven directly from the USB chip.

Choose R6 based on the optocoupler`s peak surge current: there will be a short time when it has turned on but the main triac hasn`t during which all of the load current will try to flow through it. The last two points are addressed by putting a series RC filter accross the triac (R7 and C1). See the ON Semi document linked above, in particular tables 6. 1 and 6. 3, for the theory and suggested component values. The capacitor needs to be a high voltage type of the order of 0. 047 to 0. 1 uF, and I have found these difficult to obtain: Maplin don`t sell them at all any more, and Futurlec only go up to 0.

01 uF. The 4. 7 nF and 1. 8k that I`ve used seem to work (the circuit is noticeably unreliable without them) but are not ideal. Possible sources include ESR and Rapid Electronics. The USB module contains a small EEPROM which stores USB vendor and product IDs, and this needs to be programmed.

The procedure is identical as for SlugTerm, so I refer you to that documentation rather than repeating it all here. I have chosen vendor EE17 and product 0002. A suitable file for the ftdi_eeprom program is included in the software, see below. You can get the code that I`ve used, as well as the schematics and the EEPROM configuration, using subversion from.

// Slugpower main program // Phil Endecott, July 2006. #include "Ftdi. hh" #include #include #include using namespace std; void usage(void) { cerr << "Usage: slugpower [0|1|on|off|flash] "; exit (1); } int main(int argc, char* argv[]) { if (argc!=2) { usage(); } string arg = argv[1]; try { Ftdi ftdi(0xEE17, 0x0002, 192000, 0xFF); if (arg="on" | arg="1") { ftdi. write(1); ftdi. write(1); } else if (arg="off" | arg="0") { ftdi. write(0); ftdi. write(0); } else if (arg="flash") { while(1) { ftdi. write(1); sleep(1); ftdi. write(0); sleep(1); } } else { usage(); } } catch (const char* c) { cerr << "Error: " << c << " "; exit(1); } } The slugmake. sh script will build a Slug executable, using a cross compiler. See for how to set up a cross compiler for the Slug on a Debian PC. The next step is to get CUPS to turn the power on when a job is submitted. Google found me this page where a setup using an X10 power switch and a parallel printer port is described; 🔗 External reference