Computer Control of AC Devices
by indestructable in Circuits > USB
180494 Views, 320 Favorites, 0 Comments
Computer Control of AC Devices
Safety First!
This instructable is intended only for someone experienced and confident in wiring high voltages. Do not attempt to do this if you are not. Household current can kill or badly injure you if you who do not understand the danger.
Only the U451 relay contacts should be used for control/connection to 110V AC. The relay screw terminals are isolated from the other circuit connections. DO NOT touch the U451 when there is 110V AC present.
Major Parts
- USB relay interface USBmicro U451
- two light bulbs
- lamp sockets
- 110V AC cord
Project Mounting Board
Board Parts
The lamp sockets in this example setup will rest on some washers to provide some space for the wires that lead out from the under side of the socket and to the U451.
Mounting Lamps
Mounting the U451
Wiring Parts
Hot Wire Connection to the U451
Hot connects to each of the two common "c" terminals on the U451. This example project uses a wire nut to make the connection from the single source hot/black wire to the two pigtail wires that lead to the U451.
Connections to Lamp.
One black wire connects from the N.O. (normally open) screw terminal connection on relay 1 to this lamp socket (brass screw on socket) while the other lamp socket connects in a similar way to the N.O. connection for relay 2.
Lamps and Bulbs.
Check your wiring. Once you are sure about the 110V AC connections, attach the USB cable to the U451 and your PC. Plug the AC plug into an outlet.
Very Simple PC Programming
This project is brought to you by the magic of RobotBASIC. RobotBASIC (RB) is a free programming language and IDE (integrated development environment). It has support for controlling the USBmicro U451.
RB is free. FREE! You can write a program in the RB IDE and then save it as an .exe - a stand-alone executable that doesn't need the IDE to run. The USBm.dll is needed to go along with that file, but that is free, too.
I'm not going to get into the details of the program in this instructable. The entire program is the 35 lines in the image below. The program is easy to copy into the IDE and simply run. Here is the program as text: (note the spacing gets screwed up.)
// U451 relay control program
// If the DLL is found...
if usbm_DllSpecs() != ""
// And the device is found...
if usbm_FindDevices()
// Initialize the U451, outputs
n = usbm_DirectionB(0, 0xFF, 0xFF)
// Create title and two checkboxes for the relays
xyText 10,10,"Relay 1 Relay 2","",20,fs_Bold
for i = 0 to 1
addcheckbox "" + i, 10 + 120*(1-i), 60, " "
next
while true
for i = 0 to 1
if getcheckbox("" + i)
n = usbm_SetBit(0, i+8)
else
n = usbm_ResetBit(0, i+8)
endif
next
delay 100
wend
else
print "There are no Devices"
endif
else
print "The USBmicro DLL is not installed"
endif
Running the Program
Let There Be Light!
This setup could easily be modified to control the power to almost anything that plugs in. And RobotBASIC (www.robotbasic.org) can be used to make much more complex programs that, for instance, turn on electric devices based on a complex PC schedule.
Let there be light bulbs. :-)
Updated: Instead of Wiring the Lamps Directly...
Please see the specifications for the U451 for limits to the current for the devices you control.