Finn2708
Posts: 2
Joined: Mon Jun 29, 2020 7:12 pm

Using Optoisolators at 115200 baudrate

Mon Jun 29, 2020 7:52 pm

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.

jayben
Posts: 52
Joined: Mon Aug 19, 2019 9:56 pm

Re: Using Optoisolators at 115200 baudrate

Tue Jun 30, 2020 8:37 am

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.

User avatar
PeterO
Posts: 5887
Joined: Sun Jul 22, 2012 4:14 pm

Re: Using Optoisolators at 115200 baudrate

Tue Jun 30, 2020 10:08 am

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
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

njh
Posts: 78
Joined: Wed Aug 09, 2017 2:07 pm

Re: Using Optoisolators at 115200 baudrate

Sat Jul 04, 2020 10:55 am

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.

danjperron
Posts: 3503
Joined: Thu Dec 27, 2012 4:05 am
Location: Québec, Canada

Re: Using Optoisolators at 115200 baudrate

Sat Jul 04, 2020 12:59 pm

A simple note from the PDF file of the LTV-816.

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

Return to “Interfacing (DSI, CSI, I2C, etc.)”