Designing a TTL Serial Opto isolator - cellularmitosis/Electronics GitHub Wiki
Optoisolator Characterisation
Circuit A: The Basic Optoisolator Circuit:
LTSpice schematic for Circuit A
Square Wave Source:
An Arduino skietch running on an ATtiny85 is used to generate the square waves, with each pin of the ATtiny generating a different frequency. The firmware toggles a pin twice, waits 1 millisecond, then moves on to the next pin, toggles it twice, etc in a round-robin fashion.
104 μs (~9600 baud):
4N25
4N35
MCT2
LTV-814H
52 μs (~19200 baud):
4N25
4N35
MCT2
LTV-814H
26 μs (~38400 baud):
4N25
4N35
MCT2
LTV-814H
17 μs (~57600 baud):
4N25
4N35
MCT2
LTV-814H
8 μs (~115200 baud):
4N25
4N35
MCT2
LTV-814H
Circuit B: Idle Power Optimization
Take a look at this waveform graph from Sparkfun's excellent RS-232 vs. TTL Serial Communication tutorial:
Note when the line is idle, it is at logic '1' (5V). This means the LED inside of the optoisolator will be burning power when we aren't communicating (which will likely be the majority of the time).
This power consumption can optimize this by inverting the just the optical portion of our signal path. By doing so, the LED will be dark when the line is idle. If you aren't constantly communicating, this will save a bit of power.
This is accomplished this by adding a PNP transistor in between the microcontroller and the optoisolator.
The signal will need to be inverted a second time on the output side of the optoisolator. This is accomplished by using a pull-up resistor rather than a pull-down resistor.
Here is Circuit B:
LTSpice schematic for Circuit B
104 μs (~9600 baud):
4N25
52 μs (~19200 baud):
4N25
26 μs (~38400 baud):
4N25
17 μs (~57600 baud):
4N25
8 μs (~115200 baud):
4N25
High(er) Speed: 6N137
The 6N137 is significantly faster than any of the above parts. It should work well at 115,200 baud. Here it is in circuit B:
8 μs (~115200 baud):
6N137