PNP vs NPN Sensors Explained
A sensor that looks dead is often a PNP or NPN mismatch with the PLC input. This guide explains the difference and how to match them.
The short version
A 3-wire sensor has a supply wire, a 0 V wire and an output wire. When the sensor detects something, its output switches. What it switches to decides whether it is PNP or NPN.
| Type | When active, the output connects to | The load goes between the output and | Also called |
|---|---|---|---|
| PNP | The positive supply (+24 V) | 0 V | Sourcing output (it sources current to the load) |
| NPN | 0 V (the negative supply) | +24 V | Sinking output (it sinks current from the load) |
The load is the PLC input. So a PNP sensor needs an input that provides a path to 0 V, and an NPN sensor needs an input that provides a path to +24 V.
Matching a sensor to a PLC input
| PLC input type | Current flows | Works with |
|---|---|---|
| Sinking input | Into the input, out through the common (0 V) | PNP (sourcing) sensors |
| Sourcing input | Out of the input, in through the common (+24 V) | NPN (sinking) sensors |
The names cause confusion because the sensor and the input use opposite words. The rule that holds is: a sinking input needs a sourcing (PNP) sensor, and a sourcing input needs a sinking (NPN) sensor. Many PLC input modules in North America are sinking inputs used with PNP sensors, but this varies by region, brand and module, so check the module's datasheet and wiring diagram.
Some modules accept either type, depending on how you wire the common terminal.
Standard wire colors
For 3- and 4-wire sensors, the common color code is:
| Color | Function | M12 connector pin |
|---|---|---|
| Brown | Supply (+24 V) | 1 |
| Blue | 0 V | 3 |
| Black | Output (usually normally open) | 4 |
| White | Second output (often the opposite state) or a function input | 2 |
Not every sensor follows the code, and some manufacturers use their own. Check the datasheet.
Testing a sensor with a meter
- Power the sensor and measure the supply between brown and blue to confirm the supply voltage is present and correct.
- PNP: with a DC voltmeter, measure from the output (black) to 0 V (blue). It should read about 0 V when inactive and close to the supply voltage when active.
- NPN: measure from the output (black) to +24 V (brown), or to 0 V. When inactive the output floats near the supply voltage (with a load or pull-up present), and when active it drops to near 0 V.
- Operate the sensor (for example, place a target in front of it) and watch the output change. Most sensors also have an indicator LED for the output state.
An unloaded NPN output can read erratically with some meters because it is not driven high when inactive. Test it with its load connected.
Common mistakes
- Wrong type for the input. The sensor's LED lights but the PLC never sees it.
- Normally open versus normally closed. Check which state the sensor's output has when no target is present.
- 2-wire sensors. They have a small leakage current when off and a minimum load current when on. A high-impedance or low-current input can see the leakage as a false on, or may not turn on at all.
- Missing common. The sensor and the input need a common reference. If they are powered from different supplies, tie the 0 V together unless the design is intentionally isolated.
For counting pulses from sensors and encoders, see the encoder counts calculator.
This is general guidance for training and reference. Always follow the sensor and input module datasheets for wiring.