Shop Learn
RS232 9600 8N1 & Opto-Isolator — Parallax Forums

RS232 9600 8N1 & Opto-Isolator

Hello All,

I'm learn how to use the Optocoupler with RS232 Data. I have a working unit Scanner, but want to Isolate it from the I/O pin once the Data has been received. I've Googled and YouTubed what I could to figure it out. But has anyone ever done this before and got it working?

I'm using my DG4062 (SQ Wave) & Scope for my test signal for now and a BOE.

I've used this (on hand) part before as a switch (, will it couple Data?. Inverter Amp. arrives tomorrow.

Find attached the 2 designs I think may work. One is from the website.

:::Just want to Isolate the I/O pin once the Data is received.
Thanks for any help.
496 x 346 - 24K


  • Short answer: NO

    Why? That part is great as a solid-state "relay" but due to the way the MOSFET is activated it is slow to response. It might be ok at 300 baud, but not 9600. The rurn-on time can be 0.25ms or more.

    Anyway, if you are really using optos then why bother with an inverter output although there are many devices with integrated logic outputs (HCPL-22xx etc). You could use the opto output in emitter follower so that a high input in the anode of the LED produced a high output. Or you could have your ground emitter circuit and drive the cathode of the LED instead etc.
  • Thanks Peter,

    Up date.

    Bottom schematic, with resistor(s) removed, GND on pin 2 and signal (Sq. Wave) in on pin 1.

    See attached Wave form Screen Shot.

    Do you know of a part that would work at 9600 Baud?

    800 x 480 - 87K
  • Up-date,

    read over your part number bad, getting late.

    Just ordered parts...Thru hole was out, so I ordered FairChild/ON (

    NOTE:Had googled your part and looked it up at, just was not sure if that was over kill or not.


    will update.
  • I'm might be taking a big guess here trying to figure out what you mean and what "signal" source you are using and where you are measuring etc. Only one waveform? Clamped to around 2V for some reason as if you weren't using a series resistor (the LED is a current device) etc.

    The RS232 signal would feed the LED through a resistor although that resistor can be anywhere in series, the important thing is to convert the voltage to a limited current. There is no "pull-up" voltage on the transmitter side from the RS-232 but I'm guessing that this circuit is not a real circuit, just another one of those "interweb" circuits. Quickly typing in RS232 OPTO I picked a circuit that seems to be able to actually work although I don't know what they mean by "available via licence", as if it were something clever and patented whereas it is a basic circuit. This one at least uses the negative voltage from the RS232 itself although it does require an RTS for the positive voltage. Always always, there are caveats.

    BTW, there are thousands of parts that would be suitable and you could get by even with something basic but it all depends upon where you source your parts.
  • Up-date,

    read over your part number bad, getting late.

    Just ordered parts...Thru hole was out, so I ordered FairChild (

    NOTE:Had googled that part and looked it up at, just was not sure if that was over kill or not.


  • jmgjmg Posts: 14,676
    A cheap and widely available Logic output Opto, is the H11L1. 1MHz and 1.6mA, so 9600 baud is no problems.
    Plenty of sources, and package choices.
  • Hello All,
    Want some help. Need someone to look over this circuit and let me know if it will work as planed (few tweaks).
    This may be over kill, but will it work and how can it be reduced.

    I want to separate two different RS232 units that will transmit their DATA into one I/O pin. Each unit will transmit data at separate times, but I thought about one unit being damage from the other units signal because the Traces will be connected. I will be setting up a test unit on the BOE unit.

    Schematic attached
  • Sounds to me like you should be looking more at RS422/485.
  • couldn't you use diodes to block the units sending from each other, or am I way off?


  • kwinnkwinn Posts: 8,692
    At it's simplest a 330 ohm resistor on each unit should work, although data will be garbled if two units send or have active outputs at the same time.
  • hmlittle59hmlittle59 Posts: 404
    edited 2019-02-16 02:19
    Hello All,

    Thanks for all the help. OEM PCB's/Stencil should be here next week from China($1.00) apiece. Hope to have it built to specs and see it will pass the Data.

    will update

    PCB's came in and.....AHHHHH....Don't order PCB's 2:30 am after making lots of Modifications. Wait a day and RE-INSPECT. A few traces missing. :swear: :swear: :swear: Anyway...
    Lots of Bench testing on the (BOE) trying to understand how RS232 (ASCII) will work with a Opto-Isolator (Non-Inverting) using my DG4062 Sig. Gen. (9600 Sq. Wave). Never really got that to working correctly(not the best Sq. Wave). Didn't help with the Thru Hole IC's wanting to keep popping out of the BOE(very frustrating).
    Went back to the bad PCB and added only the parts needed to turn on the Opto Isolator and WAH-LA. Lot more stable, easier to work with and Scope. Could have saved a week. Also, the Data Sheet had Test Points plus component values off the IC so I had already added them to the PCB. Will try and add them from now on for new IC's if possible. Makes testing and hook up a breeze. I was also able to solder in the Mag. Swipe Reader and the testing was stable.

    Thanks Peter for pointing out a part for me to check out. I'm currently using the Mouser:630-HCPL-2201-300E. Basically Plug and Play. I do have a 470 ohm resistor on the input. The (ASCII) Signal Voltage out is 2.6. I had already designed in a Op Amp circuit but the part I ordered is a Inverter and the Non-Inverter should be here tomorrow.

    Side Note:I have one of the original Rigol DS2102 scopes and because of a flaw with the Self Cal. wipes out the Trial Bundle (Trigger/Decode/Memory) options if pressed and I forgot and pressed it. But I was able to get a second Trial (30 hrs or so) from Rigol. Always only used the Scope when needed to preserve that time. The time finally ran out during this design and so I purchased the Bundle 3 weeks ago for $250.00. No problem for (6+) years and now, Channel 1 and Decode 1 cut in and out, Run/Stop and SINGLE lock ON together. Simply turning it OFF and ON will not fix it either. Have to press Self Cal. to get things back to normal for a random amount of time. Will call Rigol tomorrow.

    Will order new PCB's after fine tuning the Op Circuit.

    WOW, what a pass 2 weeks.

    Til next update

  • Why are you using an opamp?

    If you want to invert the signal through the opto all you do is you feed the other side of the opto's LED instead. So either put it into the anode and ground the cathode or else feed the cathode and ground the anode (negative volts activate). The series resistor should be more like 3k3 since the opto only needs about 1ma or so to drive and most modern RS232 drivers are usually more like +/-6V drive and nowhere near the +/-15V of the original spec. The fact is RS232 is a joke but everybody still plays the game even though the rules were changed.
    I had already designed it into the PCB that I received, not know how strong the signal would be coming from an Opto-Isolator. See: screen shot (Yellow from Module & Blue out of Isolator). Way better then what I was expecting.

    Will connect second Module and start the second level of electrical testing. Next spin of PCB will be a full operational test. To much patch work to get this board to that point.

    Will update.

    Thanks again
    4032 x 3024 - 4M
    3024 x 4032 - 5M
    800 x 480 - 178K
  • Hello All,

    What is the (Minimum) level of RS232 Data/ASCII can the BS2xxx family properly detect? I know 5v is idea.
    The Oscope is showing Data as low as 1v.

    ex.: 1v, 1.5v, 3v 4.5v.

    Thanks for any help
  • I do not familiar with BasicStamps,
    but according to SX Family User's Manual, almost all input ports are configurable as TTL or CMOS fashion.
    If so, generally speaking, for logic high, at least 2.0V at TTL input, a half of Vdd at CMOS input.
  • Thanks Yisiguro

    Anymore inputs would be welcome.

    Thanks again
  • Cluso99Cluso99 Posts: 17,762
    Just read your thread. Don't have time to properly comment as off to work.
    From a quick scan of the opto docs, the input has a breakdown voltage of 5V max. RS232 can exceed this so you will need some protection here.

    I think you need to explain your circuit a bit more. What are you sending RS232 from - both devices? What voltage swing do they have? How do you turn off the second port - is that via a switch to open the serial line? Are both devices true RS232 and by that I mean normally the TTL levels are inverted. RS232 transceivers invert the data.
  • Quick Update before work:

    Almost working per concept.
    One (1) RS232 unit is turned off (NPN) during normal operation. The other unit is electrically (ON) but (ISOLATED) thru the Optoisolator from the MC (BS2p 48). The Isolator is (weighting) down the (1) I/O line that I am using. When (electrically) disconnected my OEM PCB (ALL) seems to be well. My short program detects the DATA from either unit.

    Will try a (blocking) diode tonight. If that does not work, then redesign with electrical toggle ON/OFF concept.

    Thanks again
  • Cluso99Cluso99 Posts: 17,762
    edited 2019-03-30 14:56
    Because you are combining two devices together, an opto with a transistor as the output would be better and you could also drive a transistor from the second port, combining the two as open collector. But there are other ways to achieve this by modifying your circuit.

    Put a 10K pullup on BS P0.
    Change R3 from 330R to 1K in series with a diode 1N4148 or 1N914 with anode to P0.
    Replace R4 & D1 with 1K in series with a diode with anode to P0. This should work fine.

    Personally i dont like the R1, R2, C1 circuit but i havent looked at the datasheet. I understand what they are doing, just dont see that its necessary.

    Note resistor values i suggested are examples. Anything near that should be fine. Even 3K3 is ok.
  • Phil Pilgrim (PhiPi)Phil Pilgrim (PhiPi) Posts: 22,999
    edited 2019-03-31 06:57
    One thing I would definitely add is a reverse diode across the inputs of the opto. Most optoisolator IREDs can't stand much of a reverse voltage, and when the input swings negative it will see that entire voltage. Then you can just get rid of R2 and C1.

  • Cluso99Cluso99 Posts: 17,762
    I expect C1 is there to improve switching speed and hence R1 is there to limit the current. Since this circuit is supposed to come from an appnote i expect the manufacturer has covered a negative voltage, but i have had time to check the datasheet.
  • Cluso99 wrote:
    I expect C1 is there to improve switching speed ...
    You're probably right. I hadn't looked to see how small C1 was and was thinking it was being used to set an average bias level.

    I checked the datasheet. Reverse input voltage must be limited to 5V. So I stand by my recommendation for an external reverse diode in RS232 applications, where negative voltages can reach -15V.

  • Cluso99Cluso99 Posts: 17,762
    edited 2019-03-31 06:00
    Yes Phil, definately going to want a reverse diode across the led pins.
  • The 120pf cap network is only required to improve the 500ns propagation delay which never an issue when running this at 9600 baud. Now, I have had a look at your schematic that you posted back mid February and I noticed that you have another RS232 input going directly to the same I/O pin through a simple paralleled resistor + diode circuit. I have to say, if you hooked it up this way you would be coupling the positive RS232 voltage of at least 6V directly into the Prop. This is bad. You always need to limit the fault current that can flow into a 3.3V CMOS input when you have a higher external voltage but your diode says "bypass the current limit". What you actually was a separate I/O pin since it is easy to handle in software and have a good 10k or more of current limit on this direct input along with a small pull-down. Then there is no need for that on/off switch either.

    +1 regarding a diode across the opto's LED and also too there was never any need for the extra RC on the opto so that R1 = 2k2 or more and the cathode could have been grounded. As for R3 that value is way too low for effective current limit (if the output of the opto is actually 5V) so just use 1k or more instead.
  • yisiguroyisiguro Posts: 52
    edited 2019-03-31 09:04
    I think it is better using dual channel opto isolator instead of single channel one for each RS232 channel.
    These are same 8PDIP size, and could simplify the circuit.
  • hmlittle59hmlittle59 Posts: 404
    edited 2019-04-01 03:12
    As I stated before, I had also designed in a Op Amp circuit not know what the Isolator output would be(to low). That part was not needed so I just added a jumper wire to by pass it. I had tried Diodes before on the I/O lines but with bad results on the BOE. Also during my research for this project, I found a cable that used the (D1/R4) layout. That's were that came from. R2 and C1 are from the Data Sheet and as I understand it, it's for the TEST POINT only (No Load).

    I did try a Diode were the Op Amp jumper wire was installed and it did not work so I removed it.........Now I think it was a bad solder connection...1:00am soldering. After Phil mentioned about negative blocking Diode, I tried it again and it worked...A good night sleep helps with (0805) soldering. Thanks Phil.

    WORKING: So now I have 2 RS232 devices using the same I/O line on my BS2p40 OEM. The Mag. Reader can stay ON (with blocking Diode Mouser:621-SBR2A30P1-7) and the other unit will work. For now the other RS232 unit is just coded (HIGH/LOW) for testing.

    I will look into the Dual Isolator also. At $1.00 per PCB from (
    ), I maybe able to afford 1 or 2 more spins to get it working.

    Will start back on more testing and re-layout Tue.

    will update


  • hmlittle59, I reckoned that what you want to do with opto-isolator is protection from electrical shocks and rejection of ground loops.
    But, the schematic you attached shows that the ground line is shared with devices, i.e. external device is NOT isolated.
    And, silk print of your prototype board includes both "RX" and "TX": I didn't think your board needs BIDIRECTIONAL communication with external RS232 device. I think I misunderstood very much. I'm so sorry.
Sign In or Register to comment.