Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Electrical (http://www.chiefdelphi.com/forums/forumdisplay.php?f=53)
-   -   PNP versus NPN sensors (http://www.chiefdelphi.com/forums/showthread.php?t=143251)

Tom Line 05-02-2016 20:10

PNP versus NPN sensors
 
Disclaimer - I am not an electrical engineer.

It's my understanding that NPN style sensors sink to ground. I.e. - if you plug the signal cable of a NPN into the roborio DIO, it will pull the signal pin to ground and roboRIO will "see" it.

How would you go about hooking up a PNP sensor to the roboRIO?

Kevin Sevcik 05-02-2016 20:26

Re: PNP versus NPN sensors
 
RoboRio DIOs have a pullup resistor, which is why connecting an NPN directly to them can work. To make a PNP output to it, you basically need to reverse this situation. Connect a pull-down resistor from the signal pin to ground, then you can connect your PNP output to the signal pin as well. Your pull-down resistor will have to be low enough resistance to overcome the pullup resistor, but high enough resistance that your PNP output will still drive the volts high enough to register as a high level on the DIO.

For DIO 0-9 and DIO 0-13 on the MXP with the 40kohm resistors, a pull down of 10k would barely be enough, 5k pulldown would be safer.

An important caveat is that this only works with 5V PNP sensors. A 12V PNP output is going to blow up your DIO port unless you use a more complicated circuit.

Tom Line 05-02-2016 22:41

Re: PNP versus NPN sensors
 
Wouldn't running the signal wire through a cheap voltage divider like this allow me to feed into the DIO?

http://www.robotshop.com/en/dfrobot-...FQovaQodmWwKOw

engunneer 05-02-2016 22:48

Re: PNP versus NPN sensors
 
yes, you can voltage divide down your 12V PNP to get a 5V output. you can buy this board if you want, but its also easy to do with soldering a few resistors.

Chris_Elston 05-02-2016 22:51

Re: PNP versus NPN sensors
 
1 Attachment(s)
Here is a reference of NPN and PNP.

Donut 05-02-2016 22:55

Re: PNP versus NPN sensors
 
Quote:

Originally Posted by Kevin Sevcik (Post 1535754)
An important caveat is that this only works with 5V PNP sensors. A 12V PNP output is going to blow up your DIO port unless you use a more complicated circuit.

Pay particular attention to this as many common PNP sensors output the same voltage they are supplied with, which is typically 12V or more for the sensor to function (5V is not a common supply voltage for industrial environments that are the target market of most sensors).

Another option is to use an interposing relay to convert from PNP to NPN. Get a relay with a coil rated for the output voltage of the sensor, connect the signal wire of the sensor to the positive coil lead and a common wire to the negative coil lead. Then connect the RoboRio input to the NO lead of the relay output and a common wire to the common lead of the relay output (these will be the only leads on a SPST relay, make sure to use NO and common if using a SPDT relay). You can use this same method to convert between different voltage levels also (using a 12V PNP sensor to trigger a 5V sinking input, just have to feed 5V to the common side of the relay output).

Donut 05-02-2016 23:14

Re: PNP versus NPN sensors
 
Quote:

Originally Posted by Tom Line (Post 1535796)
Wouldn't running the signal wire through a cheap voltage divider like this allow me to feed into the DIO?

http://www.robotshop.com/en/dfrobot-...FQovaQodmWwKOw

Unless I am missing something on that voltage divider, it's going to try to output 5V, which still makes it PNP. That won't work for feeding the RoboRio inputs that expect an NPN style sensor.

SuperBK 06-02-2016 01:10

Re: PNP versus NPN sensors
 
A more reliable way than relying on a voltage divider and two resistors pulling against each other is to use an opto-isolator with a NPN output to invert the signal. That is basically the same thing that Donut is saying, but just doing with a solid state device instead of a relay.

Also be away that a sensor with an NPN output may not pull the voltage down low enough for a logic low into the DIO port of a roboRIO. Last year we used some QM series reflective sensors from Automation Direct that only went down to around 1.7 volts. We had to run them through opto isolators to get a good logic low, which is generally 0.7 volts or below.

Ether 06-02-2016 12:08

Re: PNP versus NPN sensors
 
1 Attachment(s)
Quote:

Originally Posted by SuperBK (Post 1535829)
A more reliable way than relying on a voltage divider and two resistors pulling against each other is to use an opto-isolator with a NPN output to invert the signal.

Could a simple (and quite inexpensive) NPN transistor be made to work?

adciv 06-02-2016 21:14

Re: PNP versus NPN sensors
 
Quote:

Originally Posted by Kevin Sevcik (Post 1535754)
An important caveat is that this only works with 5V PNP sensors. A 12V PNP output is going to blow up your DIO port unless you use a more complicated circuit.

The roborio is not the digital side car. Per specs, the DIO ports can take up to 16v. They were designed with being able to take 12v in mind.

Kevin Sevcik 06-02-2016 22:21

Re: PNP versus NPN sensors
 
Quote:

Originally Posted by Ether (Post 1535947)
Could a simple (and quite inexpensive) NPN transistor be made to work?

I'm hesitant about that without my Art of Electronics to remind me about transistor fundamentals. I think that's alright, but you should have high values for the resistors. Probably dividing down till the base voltage is less than 3.3V. If I remember correctly, an NPN has a diode from base to collector which would be forward biased if you drive the base with more than 3.3V. Which I think would be bad, or atleast wouldn't work properly.

Quote:

Originally Posted by adciv (Post 1536231)
The roborio is not the digital side car. Per specs, the DIO ports can take up to 16v. They were designed with being able to take 12v in mind.

That's fascinating information, where did you find it? The RoboRIO specs that I looked at when formulating my answers stated 5.25V max for the logic high of the DIOs, with no mention of a max voltage. The analog IO is listed as +-16V protection, but there's no reason to assume that carries over to the DIO.

apalrd 06-02-2016 22:41

Re: PNP versus NPN sensors
 
Quote:

Originally Posted by Ether (Post 1535947)
Could a simple (and quite inexpensive) NPN transistor be made to work?

Quote:

Originally Posted by Kevin Sevcik (Post 1536260)
I'm hesitant about that without my Art of Electronics to remind me about transistor fundamentals. I think that's alright, but you should have high values for the resistors. Probably dividing down till the base voltage is less than 3.3V. If I remember correctly, an NPN has a diode from base to collector which would be forward biased if you drive the base with more than 3.3V. Which I think would be bad, or atleast wouldn't work properly.

You can use an NPN BJT with a single series resistor of high enough resistance to limit the base current. I don't think the voltage divider is necessary.

You can also use a FET with a pull-down resistor on the gate. This is what I would pick. The resistor value doesn't matter, as long as the current through it isn't higher than the limit for the PNP in the sensor.

Al Skierkiewicz 08-02-2016 07:32

Re: PNP versus NPN sensors
 
Tom,
It might make this a better discussion if you tell us the sensor you are looking at.

adciv 08-02-2016 07:56

Re: PNP versus NPN sensors
 
Quote:

Originally Posted by Kevin Sevcik (Post 1536260)
That's fascinating information, where did you find it? The RoboRIO specs that I looked at when formulating my answers stated 5.25V max for the logic high of the DIOs, with no mention of a max voltage. The analog IO is listed as +-16V protection, but there's no reason to assume that carries over to the DIO.

During Alpha testing, NI covered some design info. They talked about the protections they were incorporating and I remember them talking about the protections incorporated. I've got an Alpha Rio lying around I can attach a battery directly tonight to demonstrate (if I'm wrong and it fries, I won't care).

cgmv123 08-02-2016 15:37

Re: PNP versus NPN sensors
 
Quote:

Originally Posted by adciv (Post 1536826)
During Alpha testing, NI covered some design info. They talked about the protections they were incorporating and I remember them talking about the protections incorporated. I've got an Alpha Rio lying around I can attach a battery directly tonight to demonstrate (if I'm wrong and it fries, I won't care).

Remember that survivable voltage is different than functional voltage. The RoboRIO was designed to survive battery voltage on any pin, but those pins may or may not be functional until the battery voltage is removed.


All times are GMT -5. The time now is 12:45.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi