Interfacing to photo-electric sensor

Ok guys, here is a challenge from me. I am messing with a lot of sensors, and this is one of them. The exact number is PD30CNP06PPDU, its a photo-electric sensor with a dust-sensor built in.

I have managed to get a relay-based sensor output to integrated with my Spider ( https://www.ghielectronics.com/community/forum/topic?id=11284 )

But this one combines power-supply and voltage level. Which means that I am afraid of frying my Spider. The sensor needs at least 10V to work, and I expect it to signal HIGH with 10V as well on the input pin.

Here is the data-sheet: http://www.productselection.net/PDF/UK/pd30cnp06ppm5du.pdf

If you help me solve this one, I promise not to bother with anymore diagrams…

You always seem to be selecting “interesting” devices. Are you choosing them, or are you just given a sensor and asked to make it work? I’m just interested to know that, because this type of device is intended for industrial connection, not really that micro-controller friendly…

You have an image of the PNP, not the NPN, is that the one you have?

You can see from the wiring diagrams that there are pull-up or pull-down resistors in the circuit. I assume that this means you’re expected to supply those, although I can’t see anywhere that describes that. My first thought here would be to ignore the micro interfacing and to breadboard everything, and monitor it with a simple multimeter. That way you can firstly prove the sensor works, measure the actual voltages presented on Pin4, and figure out if you want to use NO or NC setup.

Then, you can experiment with “level shifting” to get a voltage that is micro-safe, assuming your input voltage is the signal level you get on Pin4. At one end of the spectrum you could try using a voltage divider to reduce the voltage (resistor pairs of appropriate values to take input voltage down to uC safe levels, or you could look at other more specific shifters to assist (I won’t try to locate one of those; the input voltage may be your biggest issue)

I’m not sure what you would be monitoring if you don’t have any pull-up resistors in the circuit, which is what you seem to insinuate. Without pull-up resistors, you’ll see no voltage on the multimeter regardless of the output state, obviously.

If you do put pull-up resistors in the circuit, a multimeter is just going to tell you what you already know – that the output goes between 0 and V+. Not particularly informative.

This is actually a pretty common problem to solve.

For the NPN version, simply wire the pull-up resistors to 3.3V instead of to +V (which is 10-30V). This way, the two outputs will either be 0 or 3.3V, depending on the output status.

If you have the PNP version, you’ll have to replace each of the pull-up resistors with a voltage divider. For a 12V supply, you could use a 27k and a 10k resistor to knock the voltage down to 3.3V.

As you can see, the NPN version is easier to interface with – so if you haven’t already purchased the sensor, I’d recommend that route. However, either model will work fine with your Gadgeteer board.

Let us know if you have further questions about interfacing! Good luck!

EDIT: I’m bored so I made you a diagram:

Awesome! Brilliant, its actually the PNP version I have, but I have realized that I need to go the NPN versions in the future. Thanks for drawing and explaining this really well.

These drawings deserve to go into the documentation for digital inputs on the GHI Support section :wink:

Now I feel prepared for many more types of sensors.

FYI, I am building stuff that goes into the deep forests and the fields, and thats why I am using industrial strength sensors which are IP65, IP66 tested (waterproof etc) and are messing with solar cells and big batteries.

Thanks again, I really appreciate this.