# Hooking up an optocoupler in a 24V Machine, is a 2 kOhm resistor sufficient?

I am going to buy an inductive probe for my Creality Ender 3 to enable ABL (Automatic Bed Leveling). And now, I have one last question left on my mind:

I am going to buy a Vishay Optokoppler Phototransistor SFH610A-1 DIP-4 Transistor DC.

Is it sufficient to put a 2 - 2.2 kΩ resistor between the input of the octocouplers LED side and the 24 V Output of the probe, to lower the current and voltage enough to work with the octocoupler? Or do I need something else?

On the transistor side, I will simply attach the 2 wire Z-endstop cable, +5 V on Collector and GND on Emitter.

• Possible duplicate of Inductive Sensor in 24 V machine? – 0scar Feb 19 '19 at 6:17
• Capacitive sensor trigger distance depends on the amount of moisture in the air and as such are not very accurate for a range of operating conditions. A 3D touch sensor is more reliable when using glass. Furthermore, using a higher voltage for powering the sensor has been asked before – 0scar Feb 19 '19 at 14:21
• Ok, so, I should use an inductive sensor then, right? Because, I do not have other options. Additionally, I know that there are similar questions, but I am unable to answer to them. So sorry for making a new thread :/ – der-andyman Feb 19 '19 at 23:21
• Ok, last question then: I am going to buy the mentioned octocoupler. Is it sufficient to put a 2 - 2,2 k Ohm resistor between the input of the octocouplers LED side and the 24V Output of the probe, to lower the current and voltage enough to work with the octocoupler? – der-andyman Feb 19 '19 at 23:42
• ok, with the changes it is clearly a different question - though I would use a proper optocoupler board... – Trish Feb 20 '19 at 1:09

## 1 Answer

### TL;DR

Yes, a 2 kΩ resistor is sufficient to limit the current to about 12 mA through the optocoupler. With a maximum current specification of 60 mA you require at least 400 Ω; any resistor in between the values should be suitable for this optocoupler component when used at 24 V. More information is found below.

Having a glass bed and using an inductive probe may not work optimally. In such cases a 3D touch sensor is a very good alternative. For inductive sensors, remember that these sensors optimally detect steel, aluminium is harder to detect (about 60 % less than iron; a glass sheet in between the bed and the sensor requires you to acquire a sensor with a large detection range, e.g. 8 mm or more. To optimize the detection distance such sensors need to be powered to the maximum voltage they can handle (usually 36 V) or the highest voltage you have available (e.g. power supply 12 or 24 V). To protect the board, that is only allowed to receive up to 5 V, an optocoupler is an excellent way to guarantee the separation of voltage levels.

Considering your questions, it is fair to assume you are not an experienced electronics tinkerer, purchasing an optocoupler module is the best alternative, you just screw the wires into the respective input screw terminals as shown in this answer.

As the optocoupler separates two circuits, you can safely use 24 V on the one side and the 5 V on the other side, you do not need an additional resistor when you use a module board. If you plan to buy separate components to build your own circuit, you need to look at the maximum current that the optocoupler can handle on the input side (that will be 24 V). From the documentation from the optocoupler one reads that it is limited to 60 mA. A maximum current would therefore require a resistor of:

$$R=\frac{U}{I}=\frac{24}{60\times10^{-3}}=400\ \Omega$$

My 12 V optocoupler module uses a 1 kΩ resistor implying a 12 mA current. In your case allowing 12 mA of current yields a 2 kΩ resistor.

• Ok, so when I understand this correctly, I do not need to use as much as 2 k Ohms, as e.g. 400 Ohms would already be enough. However, it should be better for the optocoupler, if I use some more resistance, isn't it? I would say, 1 k Ohm should be a good value... As I do not want the maximum of 60 mA to flow. One question to the linked thread and the wiring: There they connected the Black Signal Wire and the Golden +12V Wire to the input of the optocoupler. Why is this? I mean, I want Signal and GND, don't I?? – der-andyman Feb 20 '19 at 18:55