Sharing Serial connection


Closed Thread
Results 1 to 7 of 7
  1. #1
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default Sharing Serial connection

    I have a situation where a PC and a PIC need to be able to send data to a serial (RS232) device.

    When the PC is being used I want to disable the PIC from sending data. I have a switch right now that is a PC/PIC selector. (Might looking into sensing DTR latter) Basically it disables TX on the PIC when the PC is being used.

    What is the best way to protect the TX pins on the PC and the PIC? I was thinking of just using some diodes on both TX pins to keep it simple. (RX should be a none issue) Is that OK or should I go with a mechanical disconnect like a relay?

    Thoughts?

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563

    Default I don't understand your problem much

    Hi,

    When you are using a PC to PIC comm. you are necessarily using a software at the PC side. In its simple form there could be two situations :

    1. Your PC side program is running.

    2. Your PC side program is not running.

    Situation1 : Your com port is open and cannot be used by any other prog. So no issues on the TX part.

    Situation2 : Your PC app for the PIC is not running and you want to use another prog with another connection.So a TX from the other devices cause a conflict with your TX output.

    Using the DTR is not a recommended option as there can usage of it by the other device.

    At this moment what I can think of is a thru connection via your PIC module.

    Use a Relay or CMOS switch to select one of the TX (either the PIC or the shared device). Depending on the priority you want you can sense activity on the other TX and switch from the PIC to it. Otherway round is to poll for a particular string on the RX line to enable the PIC TX or it is a thru of the other device.

    Please ellaborate your PC-PIC and other device connections. Whether you are using a level translator or a simple resistor. Also which PIC you are using and the type of other device (PIC type or true RS232)

    Regards

    Sougata

  3. #3
    Join Date
    Oct 2004
    Location
    Italy
    Posts
    695

    Default

    Hi,

    Use the PIC to repeat the data. (Link through the PIC).
    You will need a PIC with hardware UART + interrupt routine.



    Best regards,

    Luciano

  4. #4
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563

    Thumbs up Can we have some more details on the PIC

    Hi,

    Luciano's solution can be best and economical. But it is hard to comment without a little more detail. So ben give us some more info.

    Regards

    Sougata

  5. #5
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default

    That was one of my thoughts and I'm all for it. Here is where it gets sticky.

    The software on the PC side is locked to com1 but I'm trying to interface with 2 serial devices with it. The original idea was to use a serial switch box and control each individually with the software.

    The devices can be turned on/off remotely via serial. The request was to be able to turn both devices on/off on a day to day bases w/o the PC but they still want the ability to use the more advance PC software on occasion.

    I'm trying to combine the functionality of the switch box with the automated control of the pic.

    Keep in mind the protocol is a send and reply protocol which means the PC can't just send commands blindly to both devices.

    Make sense?

  6. #6
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563

    Default A simple method

    Hi,

    You can share the RXin (TXout of PC) from the PC to the PICs so that both of them listen to what the software is asking to do. So the objective is to prevent clash of TXout (Rxin of PC) line. If you are using two MAX232 on both the device then things get complicated. You already thought of the DTR line. So lets do it in this way.

    1. Do not use individual MAX232

    2. OR both the PICs TX output by a couple of 1N4148 diodes.

    3. Use the ORed output to the TXin of the MAX Chip

    4. Use the same ORed output to form some sort of bus activity signal to both the PICs.

    5. Now in your software just before you transmit check for activity (at least one frame according to your baud rate)

    6. If the line is active go idle for a few secs (or so according to your traffic and protocol).

    So when one PIC is sending the other would just wait for the bus to become free (sort of inverse DTR)

    Regards

    Sougata

  7. #7
    Join Date
    Jun 2005
    Location
    Wisconsin
    Posts
    382

    Default

    Doing it this way is more work than its with. I'm going to take another route and eliminate the switcher and PC portion of the design. If they want to you the PC they will have to replug as needed.

Similar Threads

  1. Replies: 33
    Last Post: - 19th March 2010, 03:02
  2. Laptop Serial connection how to
    By Sumobob in forum Serial
    Replies: 2
    Last Post: - 9th October 2008, 04:09
  3. Automatic VB6 to pic serial connection
    By arniepj in forum Code Examples
    Replies: 13
    Last Post: - 10th January 2008, 07:57
  4. Failure Serial Connection with Hyperterminal
    By guanerrr in forum Serial
    Replies: 2
    Last Post: - 5th August 2007, 07:49
  5. serial connection n vb interface
    By gidah in forum Serial
    Replies: 1
    Last Post: - 18th September 2006, 13:54

Members who have read this thread : 1

You do not have permission to view the list of names.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts