3

I would like to check sensor signal on MCU. Sensor signal is 24V. Therefore, i want to use optocoupler as an interface between MCU and sensor. NC1 is going to MCU pin. My question is if i can connect 24V direct like this. There are total 4 inputs exactly same.(24V to 5V)

I have simulated this on tinkercad and it shows 11mA current flows over diode and it works without any problem. However, i don't think it is reliable to connect it like this so i want to ask how should i connect this for proper and reliable operation?

enter image description here

alfonso
  • 457
  • 4
  • 13
  • Why's everyone so obsessed with optocouplers? They are expensive and unreliable. Just use a voltage divider. – Lundin Mar 29 '21 at 06:59
  • 9
    @Lundin, you can't get electrical isolation from a voltage divider. – Abdalrahman Seliem Mar 29 '21 at 07:33
  • @Abd-AlRahmanMuhammad And why exactly do you need isolation in this case? There's very few cases where you need that, and those are when you _expect_ the other end to have unreliable grounds. Boats, certain forms of heavy machinery etc. – Lundin Mar 29 '21 at 07:37
  • 4
    @Abd-AlRahmanMuhammad The schematic in question does not actually make use of electrical isolation at all - notice the shared grounds. (Is that intentional?) So Lundin does have a point here. – Richard the Spacecat Mar 29 '21 at 07:37
  • And indeed, if you connect the grounds anyway, using an optocoupler is nonsense. It's just a cumbersome transistor of sorts in that case. – Lundin Mar 29 '21 at 07:39
  • 2
    @RichardtheSpacecat, Yes I did notice that there is *no* electrical isolation indeed, but I blame the author for that mistake, I was talking with Lundin in general about what I can take from an optocoupler, not what I can take from it in *this case*. – Abdalrahman Seliem Mar 29 '21 at 07:42
  • 3
    @Lundin, I am sorry I did not notice your first comment. As mentioned in my reply to Richard, I am not talking about *this* particular case, but I was talking in general. You were say why is *everyone* obsessed with optocouplers, so you were generally speaking too, that's why I was replying in general. I hope I made my point clear this time. Thank you – Abdalrahman Seliem Mar 29 '21 at 07:47
  • There are some *special* optocoupler (they call them "voltage detector") that can be connected mostly like that. Some of these have also an integrated rectifier to work in AC. They aren't cheap however and usually you need some kindo of resistor anyway – Lorenzo Marcantonio Mar 29 '21 at 09:16
  • @lundin They also work great to remove DC bias from an AC signal without introducing capacitance (i.e. no effect on frequency like a coupling cap would) – Kyle B Mar 29 '21 at 15:50
  • @KyleB I know what they are good for. My comment is regarding why people on this site seem to use them whenever they encounter something that isn't 5V. Most of the time it seems to be because they don't know how to form a voltage divider with resistors as taught in physics class at high school. There is not likely any AC in this application... – Lundin Mar 30 '21 at 06:15
  • @Lundin Are optocouplers really unreliable? I know they're used for feedback in most power supplies for example, and those aren't unreliable – user253751 Mar 30 '21 at 09:55
  • @user253751 They are known to start behaving strangely as they age. From Silabs AN 789 "Optocouplers have several weaknesses, including parametric instability with temperature and device aging, significant internal parasitic couplings, long propagation delay times, narrow operating temperature ranges, and relatively low reliability". There's a broad product category "digital isolators" introduced some 10 years back and based on MEMS transformers, that are meant to replace the whole optocoupler technology. – Lundin Mar 30 '21 at 10:19

4 Answers4

17

No. As indicated by the symbol, the opto-transmitter is an infrared LED with a typical forward voltage, Vf, of 1.4 V. Like any LED in a similar situation a series resistor is required to limit the current. In your case you probably want 10 mA through the LED so \$ R = \frac V I = \frac {22.6} {10m} = 2k2 \$.

A few tips:

  • Draw your schematics so that higher voltages are at the top of the page and current flows from top to bottom. i.e. Invert your opto-isolator.
  • Generally signal flow should be from left to right. i.e. LED (the input) on the left, output transistor on the right.
  • GND symbols should point down to ground.

If you are interested, Rules and guidelines for drawing good schematics is well worth a read.

Transistor
  • 168,990
  • 12
  • 186
  • 385
7

No, direct connection to 24V is not OK. You need a resistor for current limiting.

Justme
  • 127,425
  • 3
  • 97
  • 261
4

Well, as an answer for your question's title, yes you can. But after seeing the schematic, the answer has changed to no you can not.

The optocoupler's input is an LED, any LED is a diode, which has a forward voltage (Vf) and has a maximum current (Imax), but generally speaking, these small LEDs you use with microcontrollers generally have a maximum current of 20mA, it is better anyway to check the datasheet of your LED or your optocoupler in this case.

Now the problem is you are appying (+24V) which everyone can guarantee is greater than the (Vf) of the LED, which will result in very high current that would lead to the destruction of the LED, hence the optocoupler would be useless.

A cheap, yet suitable solution is to add a current limit resistor which needs to dissipate the rest of the voltage and limit the current to 20mA or less, as mentioned, the datasheet will give you the range you can work in, but I will just go with 10mA, and a forward voltage of 2V, just to simplify the calculations in this case. R = V / I = (24 - 2) / (10mA) = 2.2Kohm, that is a 2.2Kohm resistor in series with the LED, needless to say, it wont actually matter if you put it before or after the LED, in other words it does not make a difference whether the current passes through the LED first or the resistor first.

Now afer we solved the first problem, let's talk about a second/side problem, do you know what is the advantage of using an optocoupler? The main advantage is having electrical isolation between the two sides (input and output), you clearly are not taking this advantage, so you paying extra money, if you do not care about electrical isolation (which I will not go into details about it), I suggest you use a normal transistor.

Thank you and good luck.

1

Add one of the following resistors between your VDC and the anode of the diode of the optocoupler:

1.2 kOhm in case you have +5 VDC
4.7 kOhm in case you have +12V VDC
6.8 kOhm in case you have +24V VDC

as an additional protection you can connect 2 Diodes in series between Pin1 & Pin2 of the Opto with the Anode towards Pin 1. This would ensure only 1.4V max between Pin1 & 2.

Voltage Spike
  • 75,799
  • 36
  • 80
  • 208
Fahim Baig
  • 11
  • 2