Sonsivri
 
*
Welcome, Guest. Please login or register.
Did you miss your activation email?
December 10, 2016, 05:30:24 17:30


Login with username, password and session length


Pages: [1]
Print
Author Topic: How to detect whether RS232 cable is connected to PC or not?  (Read 1362 times)
0 Members and 1 Guest are viewing this topic.
xpress_embedo
Active Member
***
Offline Offline

Posts: 154

Thank You
-Given: 103
-Receive: 188


WWW
« on: April 11, 2014, 08:47:53 08:47 »

Hello Everyone.
how can i detect whether a RS232 cable is connected to PC.
Actually i had to send data to pc and receive data from pc with the help of micro-controller.
But when no cable is connected with PC then i have to glow an led indicating the link is not okay.
Please suggest me a way to implement this.
Logged
pickit2
Moderator
Hero Member
*****
Online Online

Posts: 3817

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #1 on: April 11, 2014, 09:38:14 09:38 »

If you look at RS232 specs, you will see DTR and other Named Signal Paths, you just have to monitor one that suits.
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
Sideshow Bob
Senior Member
****
Offline Offline

Posts: 457

Thank You
-Given: 160
-Receive: 495



« Reply #2 on: April 11, 2014, 11:12:16 11:12 »

And if it is a true RS232 port. The signal level will be either in range minus 9 to 12 volt or plus 9 to 12 volt. That can be used to your advantage. Will this setup send data in a continuous stream or more sporadic. Which pins in the RS232 conector will be used besides GND, TXD and  RXD
Logged

I really am ruggedly handsome, aren't I?
xpress_embedo
Active Member
***
Offline Offline

Posts: 154

Thank You
-Given: 103
-Receive: 188


WWW
« Reply #3 on: April 11, 2014, 05:54:52 17:54 »

@Sideshow Bob
Quote
And if it is a true RS232 port. The signal level will be either in range minus 9 to 12 volt or plus 9 to 12 volt. That can be used to your advantage. Will this setup send data in a continuous stream or more sporadic. Which pins in the RS232 connector will be used besides GND, TXD and  RXD

I am planning just to use RXD, TXD and GND, but for detection purpose i need to use DTR i think, as i am getting around 9V on this pin (PIN 4 of DB-9 Connector), hope it will remain same always.


@pickit2
Quote
If you look at RS232 specs, you will see DTR and other Named Signal Paths, you just have to monitor one that suits.
Thanks pickit2, i will use DTR, is it okay to use this pin for sensing, i just want to confirm as i had seen some of the post on some forum, by which people uses RS232 to power there devices and they used DTR pin.
Logged
mario2000
Active Member
***
Offline Offline

Posts: 146

Thank You
-Given: 292
-Receive: 413


« Reply #4 on: April 11, 2014, 06:55:37 18:55 »

It is easy, you have to connect TXD with RXD, then sends a data vera and this is reflected in the reception of data as echo.

Pins: 2-3



Logged
xpress_embedo
Active Member
***
Offline Offline

Posts: 154

Thank You
-Given: 103
-Receive: 188


WWW
« Reply #5 on: April 11, 2014, 07:06:17 19:06 »

Let me clear exactly what i want to do.
My device is having two serial ports, both are connected to two different PC, only one pc will communicate with my device at a time, when the link betweeen the Firsr RS232 gets broke, i haveto use the second port.

And if i shrt my trans and receive line, then all gets echoed back to me whichis not my requirement.
Logged
zuisti
Senior Member
****
Offline Offline

Posts: 371

Thank You
-Given: 219
-Receive: 567


« Reply #6 on: April 11, 2014, 09:16:12 21:16 »

If the PC is connected, the PC-side TX  signal level will be in range minus 9 to 12 volt, ie definitely a non-positive voltage (else it will be floating, ie undetermined). Using a big pullup resistor (to VCC) for example, it can be sensed at uC side using an additional input pin, or - maybe - it will be the classic "break" condition which is also can be detected via SW.

Only an idea ...
« Last Edit: April 11, 2014, 09:21:38 21:21 by zuisti » Logged
pickit2
Moderator
Hero Member
*****
Online Online

Posts: 3817

Thank You
-Given: 567
-Receive: 2049


There is no evidence that I muted SoNsIvRi


« Reply #7 on: April 11, 2014, 09:21:09 21:21 »

did you read the rs232 specs, in there is a part about handshaking...
FFS RTFM not what others tell you to do, by not reading specs you don't learn for the next time.
Logged

Note: If you have no posts other than, I want or reporting a dead link Then you can't complain If I remove your post So Stop Leeching
ReefGuru
Inactive

 Muted
Offline Offline

Posts: 3

Thank You
-Given: 1
-Receive: 3


« Reply #8 on: April 26, 2014, 08:54:28 20:54 »

Why not just use a simple keep-alive where you PC side client sends a heartbeat, or responds to a ping. If the heartbeat pong is not seen by the micro the port is down. This way you can still use 3 wire serial and not have to worry about sensing line voltages, etc.
Logged
xpress_embedo
Active Member
***
Offline Offline

Posts: 154

Thank You
-Given: 103
-Receive: 188


WWW
« Reply #9 on: April 27, 2014, 03:42:43 03:42 »

In My Application, there is a Software on PC, which Sends and Receives Data from the device, in any case of communication failure, i have to switch.
What i am thinking is that, in PC Software i will set DTR or RTS to a known state, this will help detection in the device easy, as these two pins can be set to any level either high or low using PC Serial Port Programming.
And on Device side i will detect this signal, if signal is there then Connection is okay otherwise not.

I think this will solve my problem.
Hardware base methods are good as my Specification Given to me suggests not to use any Software based method to detect link failure as that will only slow down the speed of the whole setup.
Logged
CocaCola
V.I.P
Senior Member
*****
Offline Offline

Posts: 398

Thank You
-Given: 108
-Receive: 182


« Reply #10 on: April 27, 2014, 04:05:48 04:05 »

I personally like the the ping/pong stay alive...  Depending on how fast it has to be able to detect the disconnect ping/pong works well and can be done with low overhead...  If either/or side misses a ping/pong responses within the given time period then the connection can be assumed dead or a second try made to confirm it wasn't simply a glitch before flagging the connection dead...
Logged
xpress_embedo
Active Member
***
Offline Offline

Posts: 154

Thank You
-Given: 103
-Receive: 188


WWW
« Reply #11 on: April 27, 2014, 07:45:54 07:45 »

Thanks for your help.

I will implement the ping pong method and the hardware detection method by sensing dtr pin, if it doesnt cause delay in my whole setup.
Logged
ReefGuru
Inactive

 Muted
Offline Offline

Posts: 3

Thank You
-Given: 1
-Receive: 3


« Reply #12 on: May 15, 2014, 06:23:28 18:23 »

Any update on your solution?
Logged
DreamCat
Active Member
***
Offline Offline

Posts: 235

Thank You
-Given: 130
-Receive: 77



« Reply #13 on: May 19, 2014, 06:46:39 06:46 »

Good idea from ReeGuru.
if you learned some of TCP/IP, it is too easy about communication.
I often need write these kind of program for MCU, so I done various packe format for various application, include the CRC, auto answer, etc.
Logged

May be I expressed the wrong meaning, sorry for my bad english. Please correct it for me if you can.
Pages: [1]
Print
Jump to:  


DISCLAIMER
WE DONT HOST ANY ILLEGAL FILES ON THE SERVER
USE CONTACT US TO REPORT ILLEGAL FILES
ADMINISTRATORS CANNOT BE HELD RESPONSIBLE FOR USERS POSTS AND LINKS

... Copyright 2003-2999 Sonsivri.to ...
Powered by SMF 1.1.18 | SMF © 2006-2009, Simple Machines LLC | HarzeM Dilber MC