Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Control a Relay with a PC

Status
Not open for further replies.

neomoses

Mechanical
Dec 30, 2002
9
I need help. I'm trying to do some development on a project, and I would like to be able to energize a circuit with a PC or other device that would give me an adjustable and repeatable on/off signal. For example, I may want to turn the circuit on for 1 minute, then off for 5 minutes, or I may want to have the circuit on for 45 minutes then off for 30 minutes, depending on the circumstances.

The on/off will be controlled with a relay. That part I'm comfortable with. What I'm not comfortable with is how to control a PC port from windows to send the on/off signal. I don't care if I use a serial, parallel, or USB port.

Are there any readily available programs to send a signal like this? Or am I gonna have to find someone who is comfortable with C or C++ to help me with this? Any help would be much appreciated.

I'm not dead-set on using a PC to control this, so if there is another method of making a timer that has the needed flexibility, I am all ears.

Bryan
 
Replies continue below

Recommended for you

Bryan,

Don't know how you are with programming or 'C' language but the most flexible way to do what you want to do is fit a PC relay card in your PC that controls the relays from software.

Arcom make such a beast - available through RS components part ref 295-3748. Find it on their website - This offers 8 changeover relays fully controlable through I/O port address. You could control it directly using machine code running is a DOS shell depending on DOS version rather than use 'C' but the software supplied is pretty comprehensive.

Are less costly ways of doing it - depending on how good you are with a soldering iron and how much you value your PC! Also, there are a huge variety of programmable DIN rail timers available that can be set up to do almost any repeatable cycle but I guess from you note that you want to be able to change this easily and not open up a control case every time the timing needs to be altered.
 
Thanks gezcooke and OperaHouse, that's almost exactly what I was looking for. The MPJA kit looks nice (especially the price.) It even looks like they have a program available for windows NT/2000!

Melone, could you tell me more about programmable relays? I may be able to make them work. I'm thinking something like a 25%-50% duty cycle would work well.

Bryan
 
These are readily avaible devices. Do an internet search on them and let us know if they will work.
 
Quick note: if this is a project that is to be sold, and if you choose to use a PC to control the relay, you might consider using the USB port. The project will become a beast, but there a number of PC's out there being sold without "Legacy Ports", i.e. parallel ports and RS232 ports.

Also, if you decide the suggestions above are a little pricey, you could always use something as simple as a 555 timer or such. Using a simple timing IC, you can add various features, you can control the frequency and duty cycle, and you can make the whole design pretty small.
 
I think I'm gonna go with kit 108 from Kitsrus. It looks like it'l do exactly what I want, and is under $60. I had no luck finding a "programmable relay" with basic internet searching (google, yahoo, etc...) Everything I saw while searching for that was quite expensive, over $100.

I might get a couple of those kits from kitsrus and play around witha 555 timer circuit and dabble a bit on the electronics side.

Bryan
 
The 555 approach will not be practicle at a duration of 45 minutes. The software approach will work best for you, especially when your times are not fixed. Here's what I do for a lot of these projects that require 'development'. I start with an old IBM XT computor. You'll find lots of open I/O space. The motherboard even decodes out a couple of address blocks that you can jump straight onto. Point soldier your interface circuits using as much motherboard resources as possible, ie; power, clk, timer. If you know the BIOS you can even jump the switch settings which opens up a full 8 bit port off the pia onboard. Now you can write your own driver using any number of simple DOS based apps. Once every thing is working as required, you can begin to reduce the excess. Edit the BIOS to run alone or on command from a comm port. I have dozens of projects that incorporate these old motherboards that are only half populated with chips. Why, because there cheap, quick, and have a ton of resources onboard.
 
Hi Neo:
I would use a PC in DOS, program in BASIC, use parallel
port: it is trivial.

What are the data of the relay? AC,DC, Current , VTG ?





<nbucska@pcperipherals.com>
 
I have done this in two different ways.

1) a Win32 app (PowerBASIC) that talks to the serial port to a PIC 1684. Send O10 that is On 10 SECONDS, and send F1 that is oFf 1 minute. PowerBASIC was used, since I telnet into a port over the internet to flip the relay on and off.

2) Simple version, transistor to drive a relay on the parallel
port and a PowerBASIC (or BCET free) basic program. That controls it.

For that matter, you do not need a PC to do this. What are the specs? If you want to leave them on in the consulting area, I will take a look at it and tell you what I think would be best, I mean, if you only need quantity 1 and have a PC, options 2 is simple and fast.
 
I found these directions and diagram for how to control a relay from a serial port:
He includes software snipits for how to trigger the relay from DOS, Window, and Linux.

He drives the relay using a transistor, which is what I have seen suggested in several locations on the net.

Now, if I could just scratch my mechanical head enough to build this. Any hints and handholding is appreciated.

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor