0
\$\begingroup\$

As part of my "detecting the presence of an item on a conveyor" I'm looking at industrial through beam connectors. A lot of them are 3 wire NPN or PNP devices like this (highlighted):

enter image description here

I'm wondering how to use the output of either of these to signal to the Pi; the devices themselves are fairly configurable in that you can buy NPN/PNP that will output either when something is in the beam or when something is not in the beam, and I was thinking to detect a transition anyway so it probably doesn't matter which I choose in terms of beam on/off. In my reading around about NPN and PNP I've determined that PNP would output the supply voltage (24v in my case) when outputting and some floating(?) voltage when not. I think I could use two series resistors of high value and suitable 7:1 ratio to divide the 24v output voltage down to ~3v to register as high for the GPIO - but would I need to connect the 0v to the pi's GND also ? Is that safe?

Alternatively is it better/possible to use an NPN, 3.3v from the Pi through a pullup resistor and the output of the NPN takes the place of the switch in this diagram?:

enter image description here

The specific product I'm looking at is a Panasonic CY-100 series - that link has a few resources including datasheet but it appears that a lot of these photo sensor devices seem to have similar workings

\$\endgroup\$
2
  • \$\begingroup\$ Datasheet links would be nice, if available. That helps to clarify any questions we have without wasting both of our times more than necessary. Also, do you already have a 12 VDC or 24 VDC supply available? Or would this be an extra expense (space, money, etc?) \$\endgroup\$
    – jonk
    Feb 6, 2020 at 23:03
  • \$\begingroup\$ Links to data sheets added, thanks! I do already have 24vdc power supply as I have to activate other controls with it \$\endgroup\$
    – Caius Jard
    Feb 6, 2020 at 23:34

1 Answer 1

3
\$\begingroup\$

Based on the descriptions, the left side shows what is probably inside these receivers.

The first diagram that uses the "NPN" is safer than the "PNP" IMO.

Yes, you need to connect the ground to the RPi.

Edit: added a third option, most conservative.

schematic

simulate this circuit – Schematic created using CircuitLab

\$\endgroup\$
2
  • 2
    \$\begingroup\$ Might want to drive an opto-isolator transistor instead to be sure you're not sending voltage spikes to the GPIO. \$\endgroup\$
    – Natsu Kage
    Feb 6, 2020 at 23:27
  • \$\begingroup\$ @NatsuKage - I added a third option. \$\endgroup\$
    – Mattman944
    Feb 7, 2020 at 0:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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