Is this setup for 8 optocouplers good?

Hey. I'm trying to let my Arduino control another device and so I need to use optocouplers. This is the data sheet for the ones I'm using. The resistor pictures is 220 ohm, it's the smallest one I have for now but I'll going out to buy thing later and hopefully I'll find a smaller one. So will this setup work or do I have to change the resistor/layout? Thanks, and sorry if this seems trivial, I'm new.

You need a resistor per LED. 8 optos, 8 resistors. Otherwise the current thru the optos will vary with the number of optos that are active.
What are you intending on the output side? It will be easier to see what is going on by using a schematic.
For example:

CrossRoads:
You need a resistor per LED. 8 optos, 8 resistors. Otherwise the current thru the optos will vary with the number of optos that are active.
What are you intending on the output side? It will be easier to see what is going on by using a schematic.
For example:

Thank you for replying! The output side goes to a game (it looks just like these except with a different cover). The game has 8 buttons and each one connects two of the 5 wires together. I figured out which ones each one connected and then I made this. Also I should be using one 190 ohm resistor per optocoupler if I want to run them at 1.2 volts and 20 mA right? I only have 220s and above though, I assume it'll be fine.

Use 1k resistors for the opto LEDs.
The opto transistors are not switching significant current, so ~4mA LED current is already more than you need.
Leo..

Wawa:
Use 1k resistors for the opto LEDs.
The opto transistors are not switching significant current, so ~4mA LED current is already more than you need.
Leo..

They only need 1.2mA to activate? Testing that right now.

Wawa:
Use 1k resistors for the opto LEDs.
The opto transistors are not switching significant current, so ~4mA LED current is already more than you need.
Leo..

No that won't work. It's so much. For some reason with 1K i can only connect the wires 1 way for it to work and with 220 it works both ways. I guess I'll just one 220 for every optocoupler. I'm sure I can do it with less but it doesn't matter too much.

Your current resistor(s) of 220 ohm, should work just fine there.

So I made it in Yenka here. Why does the current to the LEDs drop each time you power a new one? They're all different power sources.

You have connected it wrong. That's why a 1k resistor did not work.

Two possible ways to connect.

All anodes go to +5volt, and all cathodes have their own 1k resistor.
The other end of the resistors connect to 8 pins.
Logic LOW turns the optos on.

All cathodes go to ground, and all anodes have their own 1k resistor.
The other end of the resistors connect to 8 pins.
Logic HIGH turns the optos on.

Post your diagram again.
Leo..

Will you only have one optocoupler turned on at any time? If so, then you have it wired correct.

Will you have more than one optocoupler turn on at any time? If so, you need a resistor on each.

Wawa:
You have connected it wrong. That's why a 1k resistor did not work.

Two possible ways to connect.

All anodes go to +5volt, and all cathodes have their own 1k resistor.
The other end of the resistors connect to 8 pins.
Logic LOW turns the optos on.

All cathodes go to ground, and all anodes have their own 1k resistor.
The other end of the resistors connect to 8 pins.
Logic HIGH turns the optos on.

Post your diagram again.
Leo..

I was only using 1 opto for my test. Not too many ways to wire it:

The two outputs on the bottom were used to turn on and off the game I'm using by connecting them to 2 of the 5 controller inputs it had, connecting them and sending the message and turning it on/off. With a 1K resistor like shown, the two outputs weren't interchangeable and each one had to be put on one specific input of the two. However, for some reason, when I used a 220 resistor they were and either one could be put on either of the two pins. That'll make my design easier since I don't have to worry about which opto output goes to which input.

They're buttons for a game so they can all be on at the same time, but usually mostly 1, sometimes 2, or less frequently 3 will be on at the same time. However it's important that it won't break with all 8 on since that's always a possibility if someone tries to press all 8 buttons at once.

Here's a picture of the controller I'm talking about. For example I can turn it on by connect the leftmost and rightmost of the 5 connectors in the middle.

"Also I should be using one 190 ohm resistor per optocoupler if I want to run them at 1.2 volts and 20 mA right?"

What is this about 1.2 volts? Aren't you sending 5 volts to the optocoupler(s)?
Is that in the specs. for the optocoupler? Can you give us the link to their datasheet specs.?

Whoops. I mis-wrote that. I meant that the opto takes 1.2 volts. I posted the data sheet in my original post.
Here it is again: PC817 Datasheet. It's the first one btw.

"Also I should be using one 190 ohm resistor per optocoupler if I want to run them at 1.2 volts and 20 mA right?"

Yes, 190 ohms is what I calculate. Thats on each optocoupler.

(5v-1.2v) = 3.8v
3.8v/20ma
3.8/.02 = 190 ohm

Something fishy going on.
20mA LED current should not be needed.
The game buttons might be switching microamps with those rubber buttons.
Did you connect the opto transistor with the right polarity?
Leo..

Hi,
The data shows Vcesat of 0.2V is with If = 20mA.

I have used these, and worked on industrial control gear with them, and they really hammer that LED.
The spec also shows CTR from 50% to 600%.

Tom.... :slight_smile:

Wawa:
Something fishy going on.
20mA LED current should not be needed.
The game buttons might be switching microamps with those rubber buttons.
Did you connect the opto transistor with the right polarity?
Leo..

The only reason I said 20 mA is because the data says 1.2 forward voltage at 20mA. I don't really know too much about this though.

TomGeorge:
Hi,
The data shows Vcesat of 0.2V is with If = 20mA.

I have used these, and worked on industrial control gear with them, and they really hammer that LED.
The spec also shows CTR from 50% to 600%.

Tom.... :slight_smile:

Sorry but I'm not sure what Vcesat and CTR mean.

The two outputs on the bottom were used to turn on and off the game I'm using by connecting them to 2 of the 5 controller inputs it had, connecting them and sending the message and turning it on/off. With a 1K resistor like shown, the two outputs weren't interchangeable and each one had to be put on one specific input of the two. However, for some reason, when I used a 220 resistor they were and either one could be put on either of the two pins. That'll make my design easier since I don't have to worry about which opto output goes to which input.

An optocoupler is not a "just a switch" - Actually, as you can see on the schematic, the "output" is a transistor. And as in every BJT, there is a collector and an emitter . Then no, what you call "the 2 outputs "are not interchangeable . A common way to connect this is :

  • emitter to GND
  • collector to Load
  • the other side of the Load to "+"

You might need to add a resistor on the collector side, if the load resistance is too low (you didn't say much about the output side : voltage etc....)

and... I suspect another XY problem here, am I the only one ?

Well, given that the game is not connected to anything else, you do not really need optocouplers.

You could just as easily use 74HC4066 quad bilateral switches with the Arduino and game negatives (or indeed, positives, as long as the game power voltage is less than the Arduino) connected together. The only limitation being that you would need to physically turn off the game power when the Arduino side was turned off, or else power the 74HC4066 via two Schottky diodes from both supply voltages (it draws essentially no current anyway).

Because these are bilateral switches, you do not have to get the connections "the right way round".