Shop OBEX P1 Docs P2 Docs Learn Events
Can I sense when a cable is unplugged? — Parallax Forums

Can I sense when a cable is unplugged?

HomeSchoolDadHomeSchoolDad Posts: 32
edited 2005-12-15 13:07 in BASIC Stamp
Hi again!

I would like to be able to tell if a cable has become unplugged.

Background: The unit I am stuck talking to sends one-way serial data over a cable with a 3mm stereo plug on their end using a single conductor plus ground, with DTR and DSR tied together on a DB9 connector on the other (my end). When an event occurs it just dumps out the result on the serial connection with no handshake. I have included a serial buffer in the design to catch the data while I am looking for button presses.

I have no idea why they use a stereo plug since they clip the connector to the plug tip off and only use the ground and middle band of the plug.

I was thinking about making my own cable and changing the serial connector (way too big!!) to another 3mm stereo plug on my end - but I am concerned that the plugs can get dislodged and I would miss the serial data the unit sends out to me. I would like to display a "Cable Unplugged!" warning if that occurs.

I am making the assumption that the cable ground would tie to ground on my board and the serial in from the jack would tie to the buffer. Please enlighten me if I am wrong!

Questions: Is there a way to monitor the cable ground (or the serial in) and make sure the cable is plugged in and ready? Alternatively, is there a way to use a normally open/closed jack to see if it has a plug inserted - perhaps by using the unused plug tip in a normally open jack? -OR- Can anyone suggest some other kind of small (SMT preferably) plug-locking jack to prevent the loss of data on my end? What would be my best solution here?

Jeff Brower

Comments

  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2005-12-14 15:19
    Jeff,

    ·· Assuming TRUE TTL serial data, you could check for a HIGH on the pin you're using for serial input.· Just an idea.· If the other end is driving the line to 5V then great, and if the cable comes unplugged it should read low, although you may have to use a weak pull-down resistor.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
    csavage@parallax.com
  • Bruce BatesBruce Bates Posts: 3,045
    edited 2005-12-14 15:28
    Jeff -

    Based on what you say, you have an extant ground in that cable. Tie that ground to the Stamp ground(s). Use a complete 3mm stereo plug (with tip) and apply + 5 volts DC to it at the far end. Attach the 3mm stereo plug tip to a Stamp pin, through an appropriate protection resistor, and so long as it reads HIGH, the unit is plugged in. Simple as that.

    Regards,

    Bruce Bates
  • HomeSchoolDadHomeSchoolDad Posts: 32
    edited 2005-12-14 19:01
    Thanks for the reply guys.

    I like both ideas for different reasons, but:

    I put a meter on the cable and I only get voltages when the the serial data is dumped out - so I·guess Chris's suggestion is out.

    After some testing I figured·out that the reason the host system has a stereo plug is that it is intended to have a Y cable connected to it and the tip goes to a display device and the band goes to·a recording device (me).· They supply different cables for each device appropiately wired.

    I am concerned that if I put voltage on the tip and some dumb dumb uses their own 3.5mm cable they will fry the·host and the display, is that true?

    Am I out of options?

    ······ Jeff
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-12-14 19:44
    Hmm. You could tie the serial line (which also goes through an RS-232 reciever, then to the buffer device) through a 22 Kohm resistor to a BS2 pin. When 'idle', I believe this line sits at -10 volts. The BS2 PIC 'protection diodes', along with the 22 Kohm resistor, will 'clip' this value to zero volts.

    When 'active', this line pulses to +12 volts -- which the 'protection diodes' clip to 5 volts. Now, if this line were 'open', I don't know what it would do -- concievably you'd have an unterminated input, and it would pick up 60 Hz 'noise'. So that doesn't help much.
  • Philip GamblinPhilip Gamblin Posts: 202
    edited 2005-12-15 05:13
    Here's a mechanical solution. You should be able to find a 3mm jack with either a Normally open or Normally closed contact which would be really simpl to monitor if the cable was un plugged. Could you hardwire the cable?
  • HomeSchoolDadHomeSchoolDad Posts: 32
    edited 2005-12-15 12:36
    Hi Philip,

    Is your solution the same as Bruce's? I kind of think that we three are on the same track - but I am unsure how to wire it / code it to get what I want without destroying the other boxes if someone uses the wrong cable (since all of them look the same).

    Jeff
  • knightofoldcodeknightofoldcode Posts: 233
    edited 2005-12-15 13:07
    I'm having a hard time understanding what you're attempting to detect. If you are simply trying to detect on the BS2 end, wether the stereo plug is inserted into your device, there is an easy solution. If you're trying to detect wether it has a electrical contact, such as detecting if the cable was cut, then you'd need a different method.

    Assuming that the "cut cable" method is desired, then obtain a cable, with two wires and a shield. Take one of the wires and the shield and use these wires for the data connection, then use the other cable to connect the shield in the plug end of the cable, not the BS2 end. So you'd make a loop of a ground. Then the BS2 can detect if this ground is present, two resistors and your'e done. Of course this wouldn't be desired in a security application. I've seen this method used on telephone lines for burglar alarms, and this is a bad idea as it's really easy to determine which one is the alarm wires and which is the telephone wires, and easy to only cut the alarm wires and not telephone. So it's just for accidental cutting, not purposful from anyone whose knowledagble, but I don't think that's the issue here. [noparse]:)[/noparse]

    If your'e trying to detect wether the plug is inserted into the BS2 device, then this can be done the same way a stereo system knows if there is a headphone plugged into it..... It's a clip that when a plug is inserted, moves out of the way, no longer connecting two of the pins. On most stereo jacks there are actually 5 pins. One is for the shield, one is for the right and one for the left stereo... Two more are used to determine if a plug is inserted. When no plug is inserted these two pins are connected, as soon as a plug is inserted then it disconnects these two plugs. This could be wired up to a BS2 the same way you would wire up a push button.

    If someone uses a standard cable, or the original cable, no damage will be done. If the special cable was reversed, it may damage the device. I'd suggest the BS2 route use the smaller sized stereo jack/plugs, to make sure this can't happen. Then on one side it would be the 3.5mm stereo and the other side would be the 2.5mm. Unless someone uses two adaptors, which are uncommon, there shouldn't be an issue.


    Knight.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-
    This message transmitted with 100% recycled electrons.
    -=-=-=-=-=-
    Gravity doesn't exist. The Earth sucks.
    -=-=-=-=-=-
    Make a man a fire, and he will be warm for the night.
    Light the man on fire, and he will be warm for the rest of his life.
    -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-
Sign In or Register to comment.