# correct connection of an opto-coupler

Hi, all - I thought I posted something about this last week, but a search doesn’t turn it up, so here goes again.

I’m working through Molloy’s book, and trying to build the opto-coupler circuit in chapter 6. I’m not a hardware guy, so I’m feeling my way along here. The diagram doesn’t show specifically how to wire up the four connectors. I looked at the data sheet for the device, which was helpful, but still doesn’t get me home.

I could trial and error, but I’ve already fried one component, and they’re not easy to come by in my area. Can anyone help clarify this configuration?

This is the specific device: opto-coupler

Thanks…

You cannot use that optocoupler and directly drive it with the beaglebone.
the LED in that part needs 60ma to function correctly.

you would need to add a LED driver like what gerald has used to drive
the LEDs on the beaglebone.
you also need to calculate the correct current limiting resistor for
60ma @ 1.35v

doesn't turn it up, so here goes again.

I'm working through Molloy's book, and trying to build the opto-coupler
circuit in chapter 6. I'm not a hardware guy, so I'm feeling my way along
here. The diagram doesn't show specifically how to wire up the four
connectors. I looked at the data sheet for the device, which was helpful,
but still doesn't get me home.

OK, so what did you try? Which four connectors are you talking
As a device, opto is normally being driven by your computer (pins A
and C on your datasheet, connected to the LED) and the output
phototransistor serves as a control switch for your working circuit.
They both need current limiting, normally in the form of a series
resistor. For instance, the LED in your opto is limited to 60mA, and
probably should be driven at 10mA, so if you're driving it from 3.3V
output of your Beaglebone, you need a resistor of
R=U/I=(3.3-1.3)/.01=200 ohm. The output phototransistor is limited to
50mA, so it also should have a similar current limiting resistor
connected to it.
Of course the opto could also be used as an input circuit---the LED
driven by a voltage from the outside, and the phototransistor
connected to the input of your Beaglebone. Similar current-limiting
considerations apply.

Thanks for the replies. I should have included this picture of the diagram:

It’s the opto-coupler (labelled LDR) that I’m having trouble understanding how to connect.

Przemek: I haven’t tried anything. I don’t want to make a connection that could damage anything.

Thank you for any help.

I apologize for the confusion…after reading the instructions for the nth time, I have come to realize that I’m trying to use the wrong component for this exercise.

Thanks to everyone who tried to help me on this.

Right, Derek calls for an LDR aka Light-Dependent Resistor, aka
photoresistor, that looks like this:

https://www.amazon.com/PODOY-Photoresistor-GL5537-Resistors-Light-Dependent/dp/B016D737Y4

I agree with my fellow posters that using an optoisolator here is not the solution.

The solution is to use an isolated (preferably optoisolated) logic gate. In this case an OR gate. The critical thing to mention here is that the BBB uses 3.3V stuff which isn’t TTL (which is 5V+ for on and 0V for off). Which makes it interesting because most of the stuff you’ll connect is still TTL.

Here is a link to A chip (not the right one but has a lot of the characteristics we are looking for…and the price is right). http://www.mouser.com/ProductDetail/Texas-Instruments/CD4075BE/?qs=sGAEpiMZZMtYFXwiBRPs05FGKgXIMzep

What you do is you connect up the power (GND and VCC) and tie one input of an OR gate to ground and then the other input to your BBB. Then you take the output of the gate as your isolated output. Most of these logic chips have such amazing isolation that you can do this, I think. And if you blow it you buy a cheapo plastic DIP socket and replace the logic chip like a fuse.

This is such a great question at its core, I think I’m going to shop for an inexpensive DIP chip that performs isolation AND the converstion from 3,3v to 5v necessary for any civilized conversation about BBB connectivity.

Thoughts?

http://www.mouser.com/ProductDetail/Lite-On/LTV-817/?qs=sGAEpiMZZMteimceiIVCB4BEdbJlF99qoohwWIG77es%3D

An idea. Kind of reconsidering here. I’ll look for a good way of connecting something like this up. Nice for passing thru a single UART signal thru. I wouldn’t glue entire subsystems together this way, but if you had to pass a UART_TX to a slave TTL MCU this might be the way to do it. Inexpensive too.

OK, I haven’t breadboarded this myself, but here’s A circuit that looks like it will do the 3 to 5 V conversion (and back interestingly enough…just check if the driving volt level has enough juice to drive the LED).

Its unidirectional, remember this so two can implement a UART TX and RX, however there are some hardware protocols that require line bidirectionality that I can’t easily figure out how to do.

OK, electrically let’s talk about exactly what is going on here. Basically a phototransistor is like mounting a small solar cell to the gate of a transistor and running the transistor in a switching (rather than amplifying) mode. With the LED butted right up against the photosensitive gate it provides more than enough light energy to provide the switching effect we are seeking. Switching can be looked at as merely amplification past the limits of the transistor…the transistor merely becomes conductive, like a switch.

So you just hook up the input like you would any other LED (because it IS an LED) that part is easy, however what you do is you set up the output like in the schematic, by connecting the appropriate leg to VCC (in the case of TTL +5V) determined by which way the diode effect goes (you don’t want the voltage to go against it, or it just won’t switch…just logically figure it out, or breadboard it first). And then the other output leg becomes your isolated, voltage-converted output.

Sorry I’m overexplaining this, but for the newbies I think it good to explain it operation thoroughly and logically.

OK, now in this schematic, you’ll notice its got like a zener or something and its multistage. I don’t think you need this sophisticated a set up necessarily (assuming you are selecting one from mouser or somewhere). You can use just a regular phototransistor (1 stage) optoisolator. Why? Because the driving LED has more than enough juice to saturate the gate on the phototransistor single stage or not.

OK, here is another idea that performs a similar process, however it can only work from a higher voltage level down to a lower one (like a TTL 5V down to a BBB 3.3v level, NOT the other way around…you’ll have to use the optoisolator approach for that). How a voltage divider works is by the ratio of the two resistor values you select:

OK, how I always conceive of the schematic of a voltage divider is the schematic on the far left. Your Vin would be the 5V digital signal (NOT VCC, the signal itself) you were trying to divide down to 3.3v (remember it can’t do the up conversion, it’ll only go “downhill”) which appears on the Vout.

I even have the optimal resistor values for you that make sure the currents right, strong enough to drive the logic but weak enough that it doesn’t consume any power really.

For 5V to 3.3V signal conversion:

R1 = 1700 Ohms (or a 1.7K resistor)

R2 = 3300 Ohms (or a 3.3K resistor)

Breadboard it out first. Take two resistors of the previously stated values, manually apply a continuous +5VDC to the Vin, tap it between the two resistors (don’t forget the ground connection its how voltage division actually occurs) and verify with DMM that the output voltage is indeed 3.3v. Now you have a nice little way of doing that voltage conversion. Add it to you bag of tricks.

For the newbies, whatever you do DON’T dream of passing ALL your signals over big arrays of optoisolators and voltage dividers, just for elegance sake. What you do is you run multiple voltage “domains” on your board and then when you absolutely, positively have to do the conversion, do so. For example, don’t surround a TTL MCU with several optoisolators, run it off of a 5V bus (common ground though) and thread through the single signal (like a UART_TX from the BBB through the optoisolator). On the board level remember you don’t necessarily have to thread the UART_RX back a lot of time (like for status). A good example is my PIC based motor speed control…it only receives a TX. You don’t have to check at the board level, it always works…saving you a voltage divider back to the BBB.

Hi Woody -

Thank you for the detailed replies. I appreciate the effort you put in on these. I’m currently tied up with another project, but I will return to this before long.

Thanks again.

OK, I think you can do a bidirectional line this way with a \$1 SSR (solid state relay)…maybe

http://www.mouser.com/ProductDetail/Sharp-Microelectronics/PR26MF11NSZF/?qs=sGAEpiMZZMvD44QvxK4%2FifSkPJVuODho

I use these primarily for a MCU (like a BBB GPIO out) to driver stage in like ESC circuits, or to drive a beefier electromechanical relay. Right price, really versatile.

Talking about multistaging things, I have several discretes networks (my “bag of tricks”) that I kind of patch together when I need a given function.

One of my favorites is SSR-to-Relay. The link is to a microminiture PCB relay that what you do is you take a BBB GPIO out pin and then activate the SSR (which also gives optoisolation) and drive this relay. Its beefy enough for most applications, but you can further stage it to a big 120VAC power relay if you need to throw a really big switch.

http://www.mouser.com/ProductDetail/Omron-Electronics/G5LE-1-ASI-DC6/?qs=sGAEpiMZZMvi6wO7nhr1L1%2bISpNYs8NG

Oh this is gold, serious. I noticed that the datasheets for optoisolators don’t give you the resistor to limit the LED (which is necessary). This calculator in conjunction with the datasheet WILL give you the necessary limiting resistor value.

http://led.linear1.org/1led.wiz