Shop OBEX P1 Docs P2 Docs Learn Events
Question about isolating serial connection — Parallax Forums

Question about isolating serial connection

AJ-9000AJ-9000 Posts: 52
edited 2010-09-07 17:47 in BASIC Stamp
Are there any inexpensive optocouplers like a phototransister TIL-111 or a photodarlington TIL-119 that would work in a situation like sending data one way from a Stamp to a PC ?


Update;
I think I know the answer and that is that all serial communication uses alternating current so it wouldn't work using a simple optoisolator.
633 x 338 - 7K
1.PNG 6.9K

Comments

  • stamptrolstamptrol Posts: 1,731
    edited 2010-09-06 05:22
    Serial communication doesn't use "alternating current" but it can use signals that swing from some negative voltage to some positive voltage.

    You can do what you show in the diagram with most PC's as they will interpret a signal close to 0v as a negative voltage and a signal in the 5v range as a positive signal. Use the TIL111 and drive the led side from the stamp(with appropriate resistor in series).

    On the transistor side, pull the collector up to 5 volts through a 220 ohm resistor. To achieve isolation, the transistor side 5 volts would have to come from the PC. The serial signal appears at the collector-resistor junction and goes to rx on the PC. Emitter of course goes to 0 volts.

    If you are running the stamp on batteries or an isolated power supply, the communication isolation is less important.
  • LeonLeon Posts: 7,620
    edited 2010-09-06 05:28
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-09-06 10:14
    If your transmission is one-way (Stamp -> PC), the following circuit should work for you:

    attachment.php?attachmentid=73037&stc=1&d=1283793042

    The output on pin 2 (PC's RxD) gets its negative supply voltage from the PC's TxD (pin 3) when the opto isn't conducting. When the BASIC Stamp output goes from high (mark) to low (space), the optotransistor will conduct. If there's a positive voltage on the PC's DTR (pin 4), pin 2 will go from negative to positive. For this to work, you have to make sure that DTR is asserted from the PC's side. In the BASIC Stamp's debug screen, for example, there's a checkbox for this. OTOH, if you're writing you own PC serial software, there will be an API call that you can use to make sure DTR is asserted.

    The 5.6K resistor value is only a guess. You may need to adjust it for optimum performance. Also, when sending with the Stamp, use positive (true) serial communicaiton, since the opto is wired, in this case, as an inverter.

    -Phil
    400 x 200 - 2K
  • AJ-9000AJ-9000 Posts: 52
    edited 2010-09-06 23:03
    Thanks everyone I appreciate the help.

    I have a question, when Tom Sisk(stamptrol) recommends using a TIL111 he says "the transistor side 5 volts would have to come from the PC" and the schematic of Phil Pilgrim's doesn't show that wiring, was that accidently omitted ?

    As you can see by the drawing below this project reqires a number of Stamps but at this time I only plan to use 8 initially. Assuming Phil's skematic is wrong and there should be a 5 volt wire going from the PC to the TIL111 that would create a problem because I would then have to power all of them at once. Is there another optocoupler available that doesn't require a 5 volt power supply that I could use in conjunction with one line conditioner near the PC to boost the voltage ?
    633 x 338 - 17K
    2.PNG 17.3K
  • stamptrolstamptrol Posts: 1,731
    edited 2010-09-07 03:38
    I think Phil's option will work as it takes the signal from the serial port itself. Its a more elegant solution as long as you can get DTR pin turned on.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 23,514
    edited 2010-09-07 08:33
    The TIL111 has a phototransistor output, so it doesn't "require a 5V power supply". It just requires a positive voltage on its collector, which I've taken from the PC's DTR output. Some, but not all, PCs provide power on pin 9 of the DB9 connector.

    Just about any phototransistor-output opto will work here. It doesn't have to be a TIL111. But you will have to experiment with the emitter resistor value to get the best performance. Also, with any phototransistor output device, your baud rate will be very limited, due to the transistor's slow switching speed.

    -Phil
  • AJ-9000AJ-9000 Posts: 52
    edited 2010-09-07 17:47
    That answers all my questions, thanks
Sign In or Register to comment.