0
\$\begingroup\$

I am attempting to connect an inductive proximity sensor to my 3D printer. The sensor I'm using is a Zhongde PL-08N2 sensor, which is an NPN output NC (Normally Closed) sensor. As I understand it, this sensor has an open collector output, and I am powering it with 24v. When powered up, the sensor's indicator light is normally on, and turns off when metal is placed near the sensor (which I believe indicates normal, correct operation).

The board I am connecting this sensor to is an SKR 1.3 controller board, which operates at 3.3v (though the digital inputs are 5v tolerant) and has a 10K pullup on the board for all the endstop connectors:

SKR 1.3 Endstop Input Schematic

Of course, I cannot allow the 24v from the sensor to be applied to the input pin, so I used a reverse-biased diode as described at the bottom of this page:

Diode used to protect pin from 12v sensor output

This did not, however, work for me. The board shows that the sensor is always triggered, whether or not any metal is near the sensor. I believe that may be because the setup in that link is an NPN output NO (Normally Open) sensor, and my sensor is NC.

When I have used this type of sensor before, I used a resistor divider to set the sensor output to an appropriate level, but in that case, there was no hardware pullup on the control board I used. Given that pullup, I do not know how to calculate an appropriate resistor divider for this sensor.

How can I connect this sensor to get the appropriate (3.3v/5v) logic output?

\$\endgroup\$
1
  • \$\begingroup\$ The easiest way is to use a small relay. Another simple solution is to buy a opto coupler board. \$\endgroup\$ – Marko Buršič Feb 4 '20 at 18:37
0
\$\begingroup\$

schematic

simulate this circuit – Schematic created using CircuitLab

Figure 1. The simplest solution.

Just be careful that no accidental 24 V connection is made to the signal line. If the microcontroller has internal pull-ups R1 can be omitted.

I think internally to the sensor, the "sense" output will be pulled up to the 24v input when it's not triggered; I believe that would damage the microcontroller?

It would if there is an internal pull-up but you said open-collector. Your link points to a catalog page and there is no datasheet. (This should have been enough to discourage you from a purchase.)

Testing is easy to do:

  • Power up the sensor with a high-value resistor - 1 MΩ, say - between the collector and ground and your voltmeter across it.
  • Move the target into and out of range. If the voltmeter reading stays close to zero then there is no pull-up. If it increases towards 24 V in either state then there is.

schematic

simulate this circuit

Figure 2. Using an opto-isolator provides level-shifting and prevents accidental connection of 24 V to the microcontroller. This version uses the opto-isolator in active-high mode. Swap the positions of Q2 and R1 for active-low mode.

\$\endgroup\$
9
  • \$\begingroup\$ I think internally to the sensor, the "sense" output will be pulled up to the 24v input when it's not triggered; I believe that would damage the microcontroller? \$\endgroup\$ – Mark Feb 4 '20 at 20:20
  • \$\begingroup\$ See the update. \$\endgroup\$ – Transistor Feb 4 '20 at 20:58
  • \$\begingroup\$ With a 1M resistor between the output and ground, when not sensing anything, there is .7v across it, and when sensing something, there is 24v across it. I guess this means it's not open-collector? \$\endgroup\$ – Mark Feb 4 '20 at 22:23
  • \$\begingroup\$ I guess. See the next update. \$\endgroup\$ – Transistor Feb 4 '20 at 22:44
  • \$\begingroup\$ And this opto-isolator circuit will work even though there's an onboard (i.e. not software selectable) 10k pullup to 3.3v on the control board? \$\endgroup\$ – Mark Feb 4 '20 at 22:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.