I'm trying to input 12v into Ardunio Digital inputs. But since Arduino digital input max voltage is 5v, I would like to use an optocoupler as a switch for 12v input into 5v from Arduino itself.
So I have got P621 Opto, But I' little concerned about the opto handle 12V??
Also for optos both in and out can withstand same voltage??
I'm only a beginner since not much able to grasp the tech jargons from the datasheets..
-
\$\begingroup\$ Do you need the isolation the optocoupler provides? If not, you can just use a voltage divider. \$\endgroup\$awjlogan– awjlogan2020年02月10日 10:58:23 +00:00Commented Feb 10, 2020 at 10:58
-
\$\begingroup\$ @awjlogan Honestly not. I tried with a voltage divider which is working fine. But thought about a different approach with Opto.. \$\endgroup\$Sandeep Thomas– Sandeep Thomas2020年02月10日 12:53:03 +00:00Commented Feb 10, 2020 at 12:53
-
\$\begingroup\$ @SandeepThomas Optos are slow, expensive, and large - if you don't need the full galvanic isolation (ie, no shared ground), but want to protect the Arduino inputs, use a buffer IC and/or put in some protection diodes. \$\endgroup\$awjlogan– awjlogan2020年02月10日 13:45:34 +00:00Commented Feb 10, 2020 at 13:45
2 Answers 2
Think in terms of current. You want your input voltage to cause about 10 mA to flow in the LED. The LED will drop 1-2 volts, so (12-2)/0.01 = 1k.
The output transistor will produce a current that you need to convert to a voltage with a resistor. For low speed signals, 10k is a good choice.
Note that this circuit will invert the signal, 12V in will cause a logic zero. This is easily handled in software. Or, you can reverse R2 and Q1 to get a non-inverted signal.
schematic
simulate this circuit – Schematic created using CircuitLab
-
\$\begingroup\$ Thanks a lot friend.. But I have a little question... Is that 10k is pulldown resistor?? \$\endgroup\$Sandeep Thomas– Sandeep Thomas2020年02月10日 12:55:51 +00:00Commented Feb 10, 2020 at 12:55
-
2\$\begingroup\$ Look at the schematic: It's clearly a pull-up resistor. \$\endgroup\$the busybee– the busybee2020年02月10日 13:24:56 +00:00Commented Feb 10, 2020 at 13:24
-
\$\begingroup\$ can't we use arduino's built-in INPUT_PULLUP to eliminate the 10K Resistor? \$\endgroup\$Ohbhatt– Ohbhatt2020年07月07日 19:34:46 +00:00Commented Jul 7, 2020 at 19:34
But I' little concerned about the opto handle 12V??
enter image description here.
The electrical specifications states that it can accept upto 24V. So, 12 V is with in the valid operating range.
Also for optos both in and out can withstand same voltage??
The LED can be surely driven by the 12 V too. Important thing is to size the series resistor properly so that the recommended Foreward current of the opto LED is not violated.
Also, you can think of placing a diode in reverse direction across opto LED for reverse voltage protection
-
\$\begingroup\$ Thanks friend.. A question... You have mentioned to size the series resistor properly.... But why the resistor required since it handle 24v? \$\endgroup\$Sandeep Thomas– Sandeep Thomas2020年02月10日 13:08:30 +00:00Commented Feb 10, 2020 at 13:08
-
\$\begingroup\$ the LED current should be limited to some value, else the LED will get hot and burns out. Please refer to the datasheet to know the maximum LED current alowed \$\endgroup\$User323693– User3236932020年02月10日 13:24:53 +00:00Commented Feb 10, 2020 at 13:24
-
\$\begingroup\$ Which is 16mA as per the line below. \$\endgroup\$Nebula– Nebula2024年04月06日 17:44:41 +00:00Commented Apr 6, 2024 at 17:44