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.

TypeWhen active, the output connects toThe load goes between the output andAlso called
PNPThe positive supply (+24 V)0 VSourcing output (it sources current to the load)
NPN0 V (the negative supply)+24 VSinking 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 typeCurrent flowsWorks with
Sinking inputInto the input, out through the common (0 V)PNP (sourcing) sensors
Sourcing inputOut 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:

ColorFunctionM12 connector pin
BrownSupply (+24 V)1
Blue0 V3
BlackOutput (usually normally open)4
WhiteSecond output (often the opposite state) or a function input2

Not every sensor follows the code, and some manufacturers use their own. Check the datasheet.

Testing a sensor with a meter

  1. Power the sensor and measure the supply between brown and blue to confirm the supply voltage is present and correct.
  2. 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.
  3. 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.
  4. 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

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.