Introduction
In this post, we are going to explain how PNP sensors work. PNPÂ concept is something that we can frequently find everywhere in the industrial environment, for example when we have to select a three-wire detector or photocell and especially when we design schematics and wiring.
All the inputs of the PLC controllers from Industrial Shields are based on PNP connection.
Technical details
The PNP sensors are based on injunctions transistors which are electronic devices switching and amplifying electrical currents.
A PNP transistor controls the main current flow altering the number of holes instead of the number of electrons in the base. The low cost, reliability and small size of transistors have made them one of the greatest inventions of the 20th century.
Basically, we need to know that the input that arrives in our Arduino based PLC is positive(+).
          
Main differences between PNP and NPN
Firstly, we should keep in mind that one of the main differences is in the design of the internal circuit and the type of transistor that the sensors have.
             
As we can see in the sketches above, the main difference between both systems both is that PNP provides to the industrial Arduino based PLC a positive input meanwhile NPN provides a negative one.
Moreover, PNP is more common in Europe while NPN is used in Asia. Due to this fact, PNP sensors are easier to find in Europe because there is more stock.
Some devices using PNP connections
Â
 
Inductive sensor       Capacitive sensor          Photocell sensor Â
Example of programming with Arduino IDEPLC Arduino for industrial automation used: ARDBOX-ANALOG
Â
On this simple example, we are printing on the Serial Monitor when a photocell digital sensor is detecting any movement.
void setup() {
 Serial.begin(9600);
}
void loop() {
 bool state = digitalRead(I0.0);
 //send message to port series in function of the readed value
 if (state == HIGH)
{
 Serial.println("Detection");
 //here will execute the actions
}
delay(1000);
}
PNP Digital Inputs on industrial PLC