xpress_embedo
Active Member
Offline
Posts: 173
Thank You
-Given: 122
-Receive: 254
|
|
« on: April 11, 2014, 07:47:53 07: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
Offline
Posts: 4667
Thank You
-Given: 834
-Receive: 4323
There is no evidence that I muted SoNsIvRi
|
|
« Reply #1 on: April 11, 2014, 08:38:14 08: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: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
Sideshow Bob
Cracking Team
Hero Member
Offline
Posts: 1001
Thank You
-Given: 231
-Receive: 983
|
|
« Reply #2 on: April 11, 2014, 10:12:16 10: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 have come here to chew bubblegum and kick ass... and I'm all out of bubblegum
|
|
|
xpress_embedo
Active Member
Offline
Posts: 173
Thank You
-Given: 122
-Receive: 254
|
|
« Reply #3 on: April 11, 2014, 04:54:52 16:54 » |
|
@Sideshow Bob 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 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
Posts: 165
Thank You
-Given: 350
-Receive: 556
|
|
« Reply #4 on: April 11, 2014, 05:55:37 17: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
Posts: 173
Thank You
-Given: 122
-Receive: 254
|
|
« Reply #5 on: April 11, 2014, 06:06:17 18: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
Posts: 409
Thank You
-Given: 242
-Receive: 780
|
|
« Reply #6 on: April 11, 2014, 08:16:12 20: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, 08:21:38 20:21 by zuisti »
|
Logged
|
|
|
|
pickit2
Moderator
Hero Member
Offline
Posts: 4667
Thank You
-Given: 834
-Receive: 4323
There is no evidence that I muted SoNsIvRi
|
|
« Reply #7 on: April 11, 2014, 08:21:09 20: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: I stoped Muteing bad members OK I now put thier account in sleep mode
|
|
|
ReefGuru
Inactive
Offline
Posts: 5
Thank You
-Given: 1
-Receive: 3
|
|
« Reply #8 on: April 26, 2014, 07:54:28 19: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
Posts: 173
Thank You
-Given: 122
-Receive: 254
|
|
« Reply #9 on: April 27, 2014, 02:42:43 02: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
Senior Member
Offline
Posts: 482
Thank You
-Given: 169
-Receive: 232
|
|
« Reply #10 on: April 27, 2014, 03:05:48 03: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
Posts: 173
Thank You
-Given: 122
-Receive: 254
|
|
« Reply #11 on: April 27, 2014, 06:45:54 06: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
Offline
Posts: 5
Thank You
-Given: 1
-Receive: 3
|
|
« Reply #12 on: May 15, 2014, 05:23:28 17:23 » |
|
Any update on your solution?
|
|
|
Logged
|
|
|
|
DreamCat
Senior Member
Offline
Posts: 283
Thank You
-Given: 223
-Receive: 116
|
|
« Reply #13 on: May 19, 2014, 05:46:39 05: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.
|
|
|
|