I'm trying to interface a hall sensor with my Arduino MEGA to do a simple frequency counting.
The sensor in itself is a +12V (10-36) operation so I have to convert it to TTL...
As far as I understand I could directly use it on +5V since it's a NPN open collector output but I don't want to fry this one (already did with a couple of chinese cheapies but this one is $$$).
So I'm trying my hand on 4N35 optocouplers and drew the circuit attached.
So the D1 is just there for visualization, to know quickly wether the sensor is sensing something or not.
Now, do I need R1 & R2 (pull-up)? Obviously R1 is needed to lower down the voltage. I figured it'd be around 2,2Kohms but since it's here, could I ditch R1 and connect the + of the optocoupler LED and connect it between R1 and the L1?
Also... how do I calculte the resistor needed for the optocoupler diode? I can't seem to make sense of the datasheet on this one...
R2 could be 1K to provide approx 10mA through the IRLED of the 4N35.
The 4N35's transfer ratio is 100%, so it could sink up to 10mA on its output.
Therefore, if R3 is also at 1K but pulled up to 5V, this would provide a 5mA load on the output.
So I'm sure 2 resistors of equal value, anything from 1K to 10K would provide a good signal at the opto-isolator's output.
Can I size R2 to 100Ohms so that I have 100mA flowing through for example?
No because IF=60mA max.
Check out Fig.4, Current Transfer Ratio vs Forward Current.
For long life, I wouldn't put more than 20mA through the internal LED.
The output is only meant to provide an isolated signal, not meant to drive a heavy load.
Could easily use an additional transistor to get more current.
But doesn't the resistor needs to be sized for a certain voltage drop also? I mean, if the resistor is 10K : wouldn't the voltage drop be too low for a 1,2V LED?
Also, the internal pull-up of the Arduino being 20K, I can use that without problem, right? That'd make less than 1mA current so perfectly fine, or am I missing something?
The internal pull-ups on the Arduino are spec'd to be between 20k and 50k (that's
all you can assume, they are not actually resistors in fact, but FETs), so generally
too large to drive opto couplers which usually want 10 to 20mA or so.
But doesn't the resistor needs to be sized for a certain voltage drop also? I mean, if the resistor is 10K : wouldn't the voltage drop be too low for a 1,2V LED?
Nope. I've used 80µA (47K series resistor to 5V for LED), 100K pullup resistor to 5V at transistor output.
Would recommend 10K max for a stronger signal ... however, it depends on your application.