The U401 and U421 USB Interface from USBmicro are an easy way to interface a number of real-world devices to the PC (or Mac/Linux). In many cases control of something as simple and straight forward as a relay from a PC would require more than just a minimum amount of effort. The U401 (U421) make this very straight forward. This control project can be done using two components available from CircuitGizmos (GCU401 or CGU421 and CGRELAY1).
The U401 and the U421 have different shapes. The U421 is a “DIP” (Dual In-line Package) while the U401 is a SIP (Single In-line Package). This just means that one device has two rows of 12 pins spaced over a half inch apart, while the other has 30 pins all in a single row. The U401 sold here also has a thin, removable USB cable. The firmware on the devices are the same.
Here is a U421 pictured:
And here is the U401:
When you plug a U401 or U421 (generically called a U4x1) into a Windows PC (or Mac/Linux), it is recognized by the operating system and the OS connects the U4x1 to a driver. This is the HID (Human Interface Device) driver that is part of the operating system. No extra drivers need to be installed.
For this Gizmo project I will simply control one single output of a U4x1 to turn on (and off!) a single relay. I’ll use the schematic on the USBmicro site as a guide, and use one the the CircuitGizmo relays powered by 12 volts. I’ll also make use of the free application software to control the relay.
This is the CircuitGizmos relay:
The picture shows two relays in order to see all sides of the relay. A relay is a coil of wire that when magnetized closes a switch. The connections to the coil are shown below by the light blue arrows, while the contact/switch connections are shown in green:
Applying 12 volts across the coil will close the contact of the relay. The contact, of course, can switch a higher voltage. This relay could be used to switch on a 120VAC light, for instance. The U4x1 by itself can’t switch on a light, but can control this relay to do the job.
Actually the U4x1 doesn’t even directly turn on this relay. The output that the U4x1 has can’t drive the coil directly, so the job needs to be done with an additional device. Take a look at the example schematic from USBmicro:
This schematic shows the relay contact/switch off to the right. That can be the switch that switches on the 120VAC light. The relay is shown in the middle (and in that case has a series resistor – not needed in this case) the connection to the U4x1 on the left. The coil driver in that small schematic is a 74LS07. A single NPN transistor could be used, as could a FET. For this project I choose to drive the relay coil with a ULN2803:
The ULN2803 is a device that comes in a DIP package with 18 pins. The ULN2803 would support driving 8 relays. For this project a single port line of the U4x1 USB Interface connects to pin 1 of the ULN2803. The ULN2803 is connected to ground at pin 9. If the U4x1 is connected to pin 1, then the output associated with pin 1 is pin 18. That is connected to one of the relay coil connections. The other relay coil connection is connected to a 12 volt supply. When the U4x1 turns on the driver, the coil is energized and closes the contact. Whatever you have connected to the relay would be turned on.
The output test application can control the U4x1 and is available from USBmicro. There is a screen shot here:
This Gizmo project showed quickly how a relay can be controlled by a PC with two of the products that you can get here at CircuitGizmos. Using a driver like the ULN2803, you can see how easy it would be to expand on the device and have a project that could control up to 16 relays per single U4x1. The example application gives you a boost to be able to check out your USB project’s hardware. Control of the U4x1 can be done through quite a few different languages.