Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How to detect whether RS232 cable is connected to PC or not?

Status
Not open for further replies.

xpress_embedo

Advanced Member level 4
Advanced Member level 4
Joined
Jul 5, 2011
Messages
1,154
Helped
161
Reputation
396
Reaction score
189
Trophy points
1,353
Location
India
Activity points
10,591
Hello 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.
 

Probably the simplest way is to use a two-color LED (the type with two pins) and a series resistor to limit the current to say 2mA. Connect it between any of the lines carrying signals TO the PC and to the ground pin. With the cable plugged in the LED will light and indicate the polarity of the voltage, if the cable is unplugged it will not light at all.

Brian.
 

This is a visual indication, how the controller will detect it, in my application i have to switch to other port as soon as link gets disconnected.

And as per this post
https://www.edaboard.com/threads/298016/

I can use DTR to sense whether cable is connecter or not, is it true.
If this is so, then it will be easier to implement and solves my problem completely .
 

You can use also use a CRO by connecting its one of terminal to data pins and other to the ground on the 232 connector, to check whether pulse is present or not...
 

If DTR is sent along the cable, yes you can simply monitor for it's presence. If your RS232 link only uses TX, RX and ground the signal will not be available.
Another way which will work even if DTR isn't wired is to use a monostable wired so it triggers on data and times out if the data stops.

I had to do something similar on a TV station where it had to switch to a backup data channel if the main was unplugged. That one only used TX/RX/GND so I linked one of the other pins in the connector to ground and provided a pull-up resistor in the monitoring system. 0V meant everything was OK, a high voltage meant the short was missing so the plug must be out.

Brian.
 
xpress_embedo said:
I can use DTR to sense whether cable is connecter or not
I don't know the application scenario, but if you happen to be the communication master (this means that you get an answer only if you ask a question), then it can be done easilly with software. Throw some bytes on the line. If you get answer, PC is still there. If not, then you try a couple more times and if no answer comes, you scan next port. If you are the slave on the other hand and wait for periodic data, then you can have a communication timeout error (that is PC stayed quiet for a long time). In most cases (not all) you are able to detect this from the software.
 
The DSR line is fed to the PC serial port from the Data Set when it is Ready. This can be asserted either by the Modem being powered up or a null modem cable to another Terminal or PC which becomes the DTR signal at the other end.

So DSR is detected by the PC which asserts DTR when the serial port is active.
 

@Brain
I had to do something similar on a TV station where it had to switch to a backup data channel if the main was unplugged. That one only used TX/RX/GND so I linked one of the other pins in the connector to ground and provided a pull-up resistor in the monitoring system. 0V meant everything was OK, a high voltage meant the short was missing so the plug must be out.

This method is good, thanks, but it will not work for me.

Question.png

Cable Disconnection is not only the fault condition, other thing which disturbs the channel are also considered as fault.

- - - Updated - - -

@alexxx
I don't know the application scenario, but if you happen to be the communication master (this means that you get an answer only if you ask a question), then it can be done easilly with software. Throw some bytes on the line. If you get answer, PC is still there. If not, then you try a couple more times and if no answer comes, you scan next port. If you are the slave on the other hand and wait for periodic data, then you can have a communication timeout error (that is PC stayed quiet for a long time). In most cases (not all) you are able to detect this from the software.

Thanks Sir,
If did not get any other solution then i will implement it at last.
;-)
Its my Backup.

- - - Updated - - -

@SunnySkyguy
The DSR line is fed to the PC serial port from the Data Set when it is Ready. This can be asserted either by the Modem being powered up or a null modem cable to another Terminal or PC which becomes the DTR signal at the other end.

So DSR is detected by the PC which asserts DTR when the serial port is active.

I dont get what you want to say, so sorry i am unable to get your words properly.

- - - Updated - - -

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.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top