Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

need a circuit for control a relay on/off from a PC RS232

Status
Not open for further replies.

kingsz1

New Member
I want to connect a relay to a PC RS232 (serial) port, than use programming control this on or off. I test the serial port pin 3 voltage allway in high level when I set it low in program. I found some information from internet that the serail port need a interface for its external devices.

Please if you know how is this interface circuit, show me the circuit. simple is the best. for control a LED or a relay.

Thank you all.
 
I would do it with a PIC, but there are many different ways. You could use an old UART, I seem to remember the 6402 was one?, or you could use the handshake lines to feed a relay via a simple driver.

Personally I would advise a PIC solution, where you could easily (and more reliably) control the switching on and off of the relay - either by simple characters, or even text strings.

My RS232 PIC tutorials show how to do this with LED's, you would just need to replace the LED's with transistor drivers feeding relays.
 
Nigel Goodwin said:
My RS232 PIC tutorials show how to do this with LED's, you would just need to replace the LED's with transistor drivers feeding relays.

Thank you Nigel. Are you means this link:


or other link? can you post it, please.

I really want to know seperate a bit state, e.g. bit0 is on or off, from the serial bits(start bit, bit0-bit7, stop bits, etc.)
 
kingsz1 said:
Thank you Nigel. Are you means this link:

Yes, you would need that circuit, plus a processor board, then a relay driver board (I haven't done one yet, but it's very trivial) - obviously for a complete project you would build it on a single board.

I really want to know seperate a bit state, e.g. bit0 is on or off, from the serial bits(start bit, bit0-bit7, stop bits, etc.)

One of the tutorials does just that, using the LED board - it lights 8 LED's, one for each bit of the byte received. All you need to do is replace the LED with a driver transistor and relay.
 
Thank you. Nigel.
I found a link http://www.rentron.com/pc-relay.htm "Building a Basic Stamp I & PC Relay Controller". But I cannot find a Basic Stamp I from local shop. I has the 2051, 16F84 on hand. how can I use these microcontroller to control the relay? also how is the programming code for the microcontroller?

I need your help. Have a nice day.
 
kingsz1 said:
I has the 2051, 16F84 on hand. how can I use these microcontroller to control the relay? also how is the programming code for the microcontroller?

The 16F84 is the older version of the 16F628, and (to some extent) is compatible - the 16F628 code in my tutorials can be used with only very slight modifications.
 
nigel code on your tut how can i get it to turn led on form pc would like to send serial data to pic and have it turn led on /led off . have pc program that can send data to port how do i get pic to take data (eg . somthing like b30 have it turn led off or b31 turn led on
 
eugene2021 said:
nigel code on your tut how can i get it to turn led on form pc would like to send serial data to pic and have it turn led on /led off . have pc program that can send data to port how do i get pic to take data (eg . somthing like b30 have it turn led off or b31 turn led on

Tutorial 7.5 will do pretty well what you need, just select two ASCII characters which have the required bit as a '1' and a '0', the first character will turn the LED ON, and the second will turn it OFF.

If you want to use multicharacter strings (as in your example) you would need to buffer the strings and then check what they were.

If you want to do something like that you might try looking at Dontronics PICEX software, which although very old now is free and very versatile, have a look at https://www.dontronics.com/picex.html.
 
If you only need 1 or 2 relays you can use the handshaking lines of the rs232 port. You can simply set them or clear them in software, no pic needed, just a transistor and a diode to drive the relay.
 
If you want 8 channels from the serial port then you'll have to receive a byte from the uart. Simplest way is with a pic, if you don't have any pic expierience and don't want to get involved in it then i suggest you use the parallel port.
 
A Solid State Relay may also also be adviseable as you can trigger them easly with low voltage and low amperage with theres no click noises every time like standard relays.
 
anyone use avrs i found some code that does what i need but only will turn on first relay.need help adding code for more.can post code for single relay. this is for at90s2313
 
Status
Not open for further replies.

Latest threads

New Articles From Microcontroller Tips

Back
Top