Control Electrical Devices using Your Computer

Techhub | 9:51 AM | 2 comments

how to control electrical devices using your computer

This tutorial is about  how to  control Electronic devices via your computer. This DIY was found in Instructables. It doesnt need much programming and it could be a very effective way to automate your home. As you can see in above picture we will be computer controlling two 60 Walt bulbs using USBmicro - U451 device to program. You can find this module simply in electronic stores, if not you can purchase online http://www.usbmicro.com. This project was originally designed by  indestructable, very simple but a very effective method. Mechanics behind USB Relay device and the bulbs is fairly easy to understand. Programming that we'll be involving is not that advance to perform huge tasks, but it could be the first step of something better.But using this method you can light up pretty much anything hooking to a wall. Lets get started and please don't hesitate to ask about anything using comments section.

Lets start with a guidance for your safety 


First off - Any time that you work with 120V voltages, safety is paramount. If you are not comfortable working with mains power, please seek the assistance of someone who is.

Do not attempt to do this if you are not experienced and confident in wiring high voltages. 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.


Required Parts


The major components used for this example instructable are:
  • USB relay interface USBmicro U451
  • two light bulbs
  • lamp sockets
  • 110V AC cord
The example project will control two independent 110V AC lights with the two relays on the U451. The U451 and lights will be mounted on a wooden plank.


Mounting board


The lamp sockets are placed on either side of the wooden plank used for this project. The location of the lamps are copied to the plank and traced with a pen. A center line is drawn through the circle to aid in mounting the lamps.


mount the two lamp sockets using some screws placed in washers

Mounting the U451



The U451 is mounted next to the lamps with small standoffs and #4 screws. Pictured are the two 3-screw headers - one for each relay.

Wiring parts


Because of the high voltage and current involved with this example, you must use a wire of sufficient diameter. In this case 16 gauge will suffice.

Hot wire connection to the U451



The pair of wires from the two-wire plug consists of "hot" and "neutral" represented by black and white respectively.

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.


The neutral/white connection is split into two wire pigtails that connect to the lamp socket (silvered connection).

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


Mount the lamp sockets, tighten the screws. Install the light bulbs. These test bulbs were incandescent. Other more energy sensible light bulbs could be used.

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.


 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


When the program runs you are presented with two boxes that you can click on or off. If everything works the bulbs follow suit!

Let there be light!






You now have control of two lights in this example.

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.



This is a simple system to show you that you can perform advance tasks using PC programming. Also great tutorial by in indestructable, his hard working should be counted for a credit. 
You can mount the wires into a socket so you will be able to plug in AC devices and control them using your computer








 Good luck in building your device. 

Category: ,

About Ranusha De Silva:
Ranusha is a blogger/enthusiastic person. Apart from blogging, passionate in Technology, Aviation,Robotics, Traveling and the Joy of living. IOS Lover, Windows 7,8 , Snow Leopard and Redhat user, Dreamer with an unfinished novel since 6 years old yet still ambitious. Please contact me via my email or grab my Feedburner to stay updated.

2 comments:

  1. Nice post! Well explained. Thankyou

    ReplyDelete
  2. I agree, nicely described and illustrated. Trouble is, I can't get the U451 to be recognised by the BAS file under any version of Windows.

    ReplyDelete

Back to Top