Using Optocoupler with Arduino

Hi,

For my project I need to read 24V inputs with my Arduino Nano.
The real voltage is from 18V to 36V.

So in the first place the bottom one has a threshold at 12V instead of 20V, for some personal reason (my 24V system is a 12V*2 battery powered, so i want to be able to read this input if a battery die).
I've placed a parallel resistance to raise the input diode threshold to remove some input noise and a Zener diode at 28V Vz to protect against over voltage.

I just want to have confirmation about the values and choice of equipements I choosed, to be sure and not burn anything :slight_smile: I've some doubt about Zener diode current value

Thank you for your time :wink:

Zener diodes, just like LEDs will become a short ciircuit when the voltage exceeds the zener voltage. Is this what you want?

Er, no, it doesn't. The voltage across it remains at the zener voltage and the current is set by the difference between that and the input voltage divided by the series resistance.

The voltage dividers, like R1/R2, reduces the incoming voltage to 0.06 of the input voltage. In order to provide at least 2 volt for the opto an input of 33 volt is required. 12 volt might no be detected and 24 volt... on the edge I think.

To add a little bit of context, this system is to use on an old truck, that's why i say 24V but in fact it's more 26/27Volts.

@Paul_KD7HB i want to use the Zener diode as it should, a voltage portection. I don't wan't to exceed 28V because I've already had an alternator failure and I've got 36V onboard !! That's why I want 28V max.

@jhaine So, for you, have i made the good choices for resistors values and Zener diode ? Because, as I understood, when the zener diode is conducting above zener voltage, a small current flow thrue it. But my 1.3kOms resistor, it's just to have 20mA in the optocoupler LED. So i need to "remove" the current in the conducting Zener diode to 20mA to know if the 1.3k is enought, right ?

@Railroader The typical forward voltage of this opto is 1.15V (with 1.0 low and 1.3 high), so yes 12V will not be detected (only for the last one with the 150 Ohm resistor) and just starting at 18V (1.06V @ 18V and 1.3 @ 22V). I don't need less because when engine running, the onboard voltage is at 26/26.5V and it's to use the arduino with other stuff when engine running (exept warning light input).

No, I was just pointing out zener characteristics.

The resistor choice is unsuitable. LEDs in the opto need to be current driven. R2/R3 etc are doing nothing helpful. If you have 24v say on input 1 then R1 and R2 divide this down to ~1.4v which is barely enough to slightly forward bias the LED especially at higher temperature. The correct way to drive the LED is through a series resistance to the voltage being sensed. So for a 24v level and if you wanted say 2mA LED current you would need 24v/2mA = 12K. If you take R2 out of circuit and increase R1 that should do what you want. If you want to include the zener for over-voltage it either needs to be right at the input with a current-limiting resistor, or better say a 12v zener and split the 12k series resistor into two 5.6k ones with the zener from the junction to ground.

It's strange, that's what I've found in a Toshiba documentation about optocoupler setup.

I think what you explain me is not really what i want (but my english is not perfect and i can missunderstood...)

First i need 20mA, for the LED, that's why I've choosed 1.3k @ 26V (the voltage I normally have when engine is running).

Second, like Toshiba explaine in their documentation, to virtually increase the threshold of the LED, I need to add a parallel resistor to the LED (and make a voltage divider. I found some topics about that on stackexchange but no one with the zener diode too). That's why I've R1&R2 and a ratio of 0.06. Like that, until the voltage is approx 18V, the LED will not light. (in regard of the minimum LED spec of the opto).
I can increase slightly the R2 value to have 1.2/1.3V @ 18V if you think it's too low. What you say to me is, R1 in this case doesn't affect current for the LED, right ?

I don't understand the thing about the zener diode ? Why using a 12V one ?

You need to switch the optos on hard when there is a voltage at an input. I have never seen a circuit with a shunt resistor connected like that, it makes no sense whatever Tosh say. If you want 20 mA to drive the LED then make the resistor lower than 12k, like 1k3, but take the 82R away it isn't helping you at all. Why would you want to increase the LED threshold? (But 20mA seems a lot, I use opto-interrupters quite a lot and they only use 10mA).

So if you then want to protect against an overvoltage above 28v, don't use a 28v zener just across the input because it will have no overcurrent protection. If you split the input resistor in two equal parts and connect the zener to the mid point then the input voltage at which the zener starts to conduct will increase so you need a lower voltage zener. Roughly, a 14 or 15v zener would do the job. If the voltage at the input then goes above ~28v then the zener limits the voltage rise applied to the LEDs (not that it would matter much).

Another user explained me a mistake i've make with the using of Zener diode in parallel of the series resistors. So i'll remove it and only use series resistors to divide the voltage and safelly handle an potential faillure of the alternator and also create a threshold for LED voltage. The threshold is to not light the LED when voltage is lower than 20V +/-2V (or 12V for warnings). Yes i think 20mA is to much. Like i saied to the other user, i didn't remember why i choosed 20mA, but yes i think i'll go down to 10mA.

I know that i need an overcurrent protection resistor for the zener and that's why I've choosed to place it after the R1. But as i understand what you explain it's not the good solution. I'll keep that in mind if i need to use one in next project.

For the threshold voltage for turning on the optocoupler, couldn't you put a zener in series with the LED, so there is no significant current flow until the zener voltage + LED voltage drop is exceeded?

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.