Austech



iTrader Today's Posts Donate My Posts Classifieds Site Rules FAQ's
Go Back   Austech > Technology > Electronics
Register Members List Upgrade Account Search Today's Posts Mark Forums Read

Electronics It covers a wide range of stuff , so grab your soldering iron and come on in.

Reply
 
LinkBack (1) Thread Tools Search this Thread Display Modes
Old 30-10-08, 11:56 PM   1 links from elsewhere to this Post. Click to view. #1 (permalink)
Junior Member
 

iTrader: (0)
Join Date: Oct 2008
Posts: 3
Spent time on board: 1:41:24
doktor is on a distinguished road
Default RS232 acting as a switch sensor

I have a small device that controls a relay which is normally open.

Using the serial port on my computer I would like to be able to detect when the relay closes.

I thought the easiest way would be to connect the Tx wire of the serial port to the relay and then via the relay back to the Rx wire.

The idea was to keep writing to the port and immediately trying to read back from it.
Until the relay closes the program would not be able to read what it sends thus realising the relay is still open.

This kind of works but is not very efficient due to the constant looping and opening/closing of the port.
Furthermore it is not possible to monitor 2 relays this way.

I did check out some of the Velleman kits but they mostly operate using the parallel port which I would like to avoid if at all possible.

Is there some better simple way? Perhaps even utilising the USB port?
doktor is offline   Reply With Quote
Old 31-10-08, 08:10 AM   #2 (permalink)
Premium Member
 
GavinSV's Avatar
 

iTrader: (0)
Join Date: Jan 2008
Location: Adelaide
Posts: 79
Spent time on board: 2 Days and 19:17:06
GavinSV is on a distinguished road
Default

Hi doktor. Rather than use the TX/RX pins of the serial port, try using the DSR and CTS lines of the serial port on pins 6 and 8 respectively (6 and 5 on a D25 connector). These two lines are input pins on the serial port. If you've done any windows programming, it would be very easy to write a bit of code to monitor these two pins.
GavinSV is offline   Reply With Quote
Old 31-10-08, 01:21 PM   #3 (permalink)
Senior Member
 
trash's Avatar
 

iTrader: (0)
Join Date: Jan 2008
Posts: 394
Spent time on board: 3 Days and 11:36:42
trash is on a distinguished road
Default

Couple of choices available to you depending on how much function you want to have. If you're just looking for something to be momentarly on, then pumping the serial line and having an RS232 carrier detect on the line is very simple. All you're looking for is a 6 to 24Vpp AC signal. A bypass capacitor, diode detector and low pass filter (4 components will do the job).

Gav has the right idea though, there is no need to send data, just use the control lines. CTS RTS and DSR DTR. That's enough for two relays with tellbacks.

If however you actually want to do it with RS232 serial then it can be done with .... (everybody knew I was going to say this) a PIC chip !!

In fact the pic chip is so good at doing this job that you can have multiple devices running off the pic chip and you can even have multiple pic chips all running on RS232 like a bus. (RS232 isn't designed for bus type comms RS485 is better for that, but we can make our own rules in this case)

Keep an eye on the PIC thread ... serial comms is about 2 or 3 tutorials away.
trash is offline   Reply With Quote
Sponsored Links
Old 31-10-08, 01:38 PM   #4 (permalink)
Premium Member
 
GavinSV's Avatar
 

iTrader: (0)
Join Date: Jan 2008
Location: Adelaide
Posts: 79
Spent time on board: 2 Days and 19:17:06
GavinSV is on a distinguished road
Default

Quote:
Originally Posted by doktor View Post
they mostly operate using the parallel port which I would like to avoid if at all possible.?
Nothing wrong with using the parallel port for IO. Although I've started to void them now for new projects since parallel ports are starting to disappear.


Quote:
Originally Posted by doktor View Post
Is there some better simple way? Perhaps even utilising the USB port?
There are a number of USB-IO adapters on available and they are not hard to interface to, but you will need to do a bit of programming.
I have used USBmicro adaptors on a number of projects and they seem to work quite well. Have a look at Dontronics USBmicro's U421 USB Interface - Dontronics
GavinSV is offline   Reply With Quote
Old 31-10-08, 06:48 PM   #5 (permalink)
Senior Member
 
trash's Avatar
 

iTrader: (0)
Join Date: Jan 2008
Posts: 394
Spent time on board: 3 Days and 11:36:42
trash is on a distinguished road
Default

There's also softmark.
Soft
trash is offline   Reply With Quote
Old 31-10-08, 08:37 PM   #6 (permalink)
Junior Member
 

iTrader: (0)
Join Date: Oct 2008
Posts: 3
Spent time on board: 1:41:24
doktor is on a distinguished road
Default

Thank you everyone!

Yes, the CTS/RTS and DSR/DTR lines seem like a much better option.
That way the program could just wait until they are activated without the need to loop forever.

I was actually thinking of perhaps using a PIC but that seemed much more involved and I just wanted something quick and simple. Basically a simple piece of hardware that I could program to send me an email when the relay momentarily closes.

Just a quick question though. I think I should have mentioned that the relay is driven by a different piece of hardware and does not require power. That being the case would it be enough to simply loop the CTS/RTS wires through the relay switch?

Thanks again,

doktor
doktor is offline   Reply With Quote
Sponsored Links
Old 31-10-08, 08:47 PM   #7 (permalink)
z80
Premium Member
 

iTrader: (94)
Join Date: Jan 2008
Location: Victoria
Posts: 4,945
z80 is on a distinguished road
Default

Quote:
Originally Posted by doktor View Post
I have a small device that controls a relay which is normally open.

Using the serial port on my computer I would like to be able to detect when the relay closes.

I thought the easiest way would be to connect the Tx wire of the serial port to the relay and then via the relay back to the Rx wire.

The idea was to keep writing to the port and immediately trying to read back from it.
Until the relay closes the program would not be able to read what it sends thus realising the relay is still open.

This kind of works but is not very efficient due to the constant looping and opening/closing of the port.
Furthermore it is not possible to monitor 2 relays this way.

I did check out some of the Velleman kits but they mostly operate using the parallel port which I would like to avoid if at all possible.

Is there some better simple way? Perhaps even utilising the USB port?


If you want to do it professionally and have $85 in your wallet, want to have it foolproof and accessible from anywhere in the world...get a BF450.

It has an rs232 to TCP/IP converter and four software controlled relays.
You can monitor the inputs and the outputs.

I have a custom application that a talented man wrote to control it that is absolutely sensational.
It also has inputs.

you can even get it to send you an email if one of the relays has been triggered.
__________________
On vacation....
z80 is offline   Reply With Quote
Old 31-10-08, 09:37 PM   #8 (permalink)
Premium Member
 
GavinSV's Avatar
 

iTrader: (0)
Join Date: Jan 2008
Location: Adelaide
Posts: 79
Spent time on board: 2 Days and 19:17:06
GavinSV is on a distinguished road
Default

Quote:
Originally Posted by doktor View Post
That being the case would it be enough to simply loop the CTS/RTS wires through the relay switch?
Yes, you can use either RTS or DTR as a signal source and loop it back through the relay contacts to CTS and DSR.
[IMG][/IMG]
GavinSV is offline   Reply With Quote
Old 31-10-08, 11:27 PM   #9 (permalink)
Junior Member
 

iTrader: (0)
Join Date: Oct 2008
Posts: 3
Spent time on board: 1:41:24
doktor is on a distinguished road
Default

Quote:
Originally Posted by GavinSV View Post
Yes, you can use either RTS or DTR as a signal source and loop it back through the relay contacts to CTS and DSR.

Cool, thank you very much!

I really appreciate everyone's help.
doktor is offline   Reply With Quote
Sponsored Links
Reply


LinkBacks (?)
LinkBack to this Thread: http://www.austech.info/electronics/12808-rs232-acting-switch-sensor.html
Posted By For Type Date
Austech - Powered by vBulletin This thread Refback 31-10-08 06:51 AM

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


server monitor
All times are GMT +10. The time now is 04:23 AM.


Powered by vBulletin Version 3.6.0
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.

Ad Management by RedTyger