Optocoupler 4N25 to isolate RS232 serial

Hello forum,

I am thinking about how to galvanic isolate a serial RS232 connection using 4N25 optocouplers.
The connection is 19k2 baud, so the 4N25 should be fast enough.

I know about the inverting problem if using them in the traditional way (output pulled LOW when input signal is HIGH), but here is some very interesting analysis about a non inverting circuit:

Has someone tried using this setup?
One could limit the current flow through R2 by increasing it (@5V it is around 15mA!), but that of course has side effects on the rise and fall flanks as well as the voltage levels.
LTspice shows that 1k2 ohm might just work if working with 3V3 on the receiving side.

Any reports? Ideas? Comments? :slight_smile:
Thanks!

The minimum and maximum voltages of a (true) RS232 signals are ±~12V.
TTL signals are traditionally 0V or 3,3V/5V.
➜ careful what your input signal is really going to be

You'd be surprized how slow photo-transistor opto couplers can be! Expect switch-off times to be 10us or so (much slower than switch on). Still 19200 baud ought to work. 330 ohm load and limiting resistors are going to give you the best speed as used in that page.

[ For serial the fact that these slow slew rates might cause multiple transitions won't matter, but for other logic protocols a ~10us slew time is a no-no, you'd use fast logic isolators for those, not opto-isolators. ]

You can arrange inverting or non-inverting easily with opto isolators by changing from low to high side switching (ie swap the positions of the 330 load resistor and photo-transistor).

Thanks, I know it is 5V level TTL according to the datasheet.

You are correct, the rise/fall rates are out of spec (5µs for 19k2) but I was hoping that would not matter and could even be stretched a little more while limiting current as well cough cough
I want to limit the current flow as much as possible while keeping the serial connection alive.

Hi,
Check the conditions of the rise fall times.
timing


100R ???

Google

opto couplers for rs232

Tom.... :smiley: :+1: :coffee: :australia:

Yeah its a little... well.. :slight_smile:

But googling lead me here:

https://www.tarthorst.net/victron-ve-direct/

fun fact, he used exactly the device I wanted to build this for using exactly the same 4N25 :smiley:
According to him, it works. At least on the receiving side and using the inverted schematic.
Guess I will have to try.

On the receiving end, the processor will detect the beginning of the start bit, then read the state of the Rx line at the middle of the data bits, beginning 1.5 bit periods after the start bit is detected. So if the transitions are slow. the start bit will be detected late, and the data bit reads will also be late. But I don't think that hurts anything so long as it doesn't read so late that Rx has started to transition into the next bit. So it seems like it ought to work at moderate speeds unless the fall time at the beginning of the start bit has a requirement that isn't being met.

But assuming your lines idle high, you're going to be drawing current all the time when it's idle. I wonder if an alternative might be to control polarity by changing the 4N25 input circuit. You would typically connect the LED anode to the Tx driver and the cathode to ground, but you could instead connect the anode to Vcc and the cathode to Tx. If the driver idles high, then the 4N25 would be off when idle.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.