Page 1 of 1

Using Optoisolators at 115200 baudrate

Posted: Mon Jun 29, 2020 7:52 pm
by Finn2708
Hi,

I would like to interface my 3D printer control board (5V) with my Pi 3 (3.3V) running octoprint.
For this I need a serial connection capable of 115200 baud while isolating the Pi from the board at the same time.

For this, optoisolators are the component to use, I think. I tried it with a couple of LTV-816 I had at hand. I used the first circuit from the following picture (source: https://next-hack.com/index.php/2017/09 ... -3v-input/).
For Rl I used 380 Ohms on 3V3 and 820 Ohms for 5V. Rpu is 10k Ohms on my circuit.

When probing with my multimeter the circuit gave the intended results, however when connected to my printer and the pi it does not seem to work. Sadly I don't own an oscilloscope, so I can't check waveform output.
Image

I was wondering, if anyone had a similar problem before and could give me advice on
(i) preferably a board I could purchase that is able to handle the speed or
(ii) better optoisolators to use (6N137 popped up for me, however they do need 5V supply voltage which seems awkward to use with the Pi) or
(iii) better circuit with LTV-816.

Re: Using Optoisolators at 115200 baudrate

Posted: Tue Jun 30, 2020 8:37 am
by jayben
It could just be the value of the pullup / pulldown resistor; 10K is much too large.

The reason is that the transistor has quite a lot of charge-storage, so it acts a bit like a capacitor that is discharged when the opto LED is on, and charged via the pullup resistor when the LED is off. The data sheet figure 10 (response time vs. load resistance) suggests that you may have a time-constant of 8 usec with a 10K pullup, which will be a problem if the serial bit-time is around 9 usec.

You can calculate the correct pullup value using the datasheet; the LED forward voltage is 1.2 so the current is (3.3 - 1.2) / R, then multiply by the transfer ratio (e.g. 0.5) then adjust the pullup value so that the transistor draws slightly less than that current when on... or you could just try 1K, and see if that works.

Re: Using Optoisolators at 115200 baudrate

Posted: Tue Jun 30, 2020 10:08 am
by PeterO
Another option might be to use an isolator designed for higher speed signals like the H11L1 https://www.rapidonline.com/isocom-h11l ... or-58-0858

I've used these at 115200 but with 5V on both sides. The data sheet says Vcc is OK down to 3V so should be OK on the Pi Rx side.

PeterO

Re: Using Optoisolators at 115200 baudrate

Posted: Sat Jul 04, 2020 10:55 am
by njh
Just some random extra suggestions for debugging
  • Just with a mutlimeter you should be able to measure high and low state voltages (with some bodge to make the output stick low).
  • If you can transmit repeated byte values like 0xF0 or 0x55 you should get a middling DC voltage and it should be about the same in both cases. You might also be able to measure their frequencies too (but multimeter AC measurements won't to be accurate at those frequencies).
  • Test the UART is set up correctly on the Pi by looping Tx to Rx. Then try opto-coupling the Pi to itself (both sides 3.3V)
  • Try using smaller values for Rl, like say 220R (3.3V) or 390R (5V). That should in turn allow smaller values for Rpu.
  • Your first configuration is the more common one, I think. It probably makes no difference with CMOS logic.

Re: Using Optoisolators at 115200 baudrate

Posted: Sat Jul 04, 2020 12:59 pm
by danjperron
A simple note from the PDF file of the LTV-816.

The cutoff frequency is 100KHz. it won't work for 115Kbaud!