PLC Connections: Comparing PNP and the Challenging NPN Type Sensors

This post presents the “how to” and the “why” for connecting type PNP and NPN industrial sensors to a typical Programmable Logic Controller (PLC). We will concentrate on PLCs with 24 VDC digital inputs. We will also assume that the PLC features digital positive-logic thresholds defined as:

  • voltages less than 5 VDC are considered logic-zero
  • voltages greater than 15 VDC are considered logic-one

Finally, we will assume each of the PLC’s I/O pins has a static 10 kΩ input resistance.

Be sure to verify these specifications against your PLC’s data sheet as there are PLCs outside of this typical range. Also, recognize that some PLCs have negative logic inputs. This will not be addressed in this post, other than to say that the core message is flipped.

Sensor Types

Three-wire industrial sensors are typically sold as type NPN or PNP. Many sensors are available in both configurations. They look identical, and the part numbers are often closely related. This can lead to purchasing errors and delays. This is especially true in PLC applications where there is a natural preference for type PNP.

The NPN and PNP designation refer to the internal construction of the sensor, specifically the type of transistor used in the output stage. Recall that there are two types of transistors including the NPN and the PNP.

Perhaps you once used an NPN transistor in a project such as the venerable 2N3904. The classic configuration is to ground the NPN transistor’s emitter, place the load between the positive power supply and the collector, and then drive the base through a current limiting resistor. In this configuration, the transistor pulls the load down to ground.

The configuration using a PNP transistor is a bit different. Now, the PNP transistor’s emitter is tied to the positive power supply. The load is connected between the collector and ground. When the base is activated, the transistor pulls the load up to the positive voltage rail.

We can summarize this by simply stating:

  • PNP pulls up

  • NPN pulls down

In the language of PLC and industrial controls:

  • PNP sources current
  • NPN sinks current

PLC to PNP Sensor Interface

The PNP type sensor to PLC configuration is presented as Figure 1. The three-wire sensor is presented as a block containing a generic sensor module and a PNP output transistor. This is a relatively simple configuration especially when we consider the constraints identified in the opening section.

When activated, the PNP transistor pulls up against the PLC’s input resistance. In an ideal situation, the PNP transistor will be fully turned on and the voltage on the black wire will be 24 VDC. The PLC will identify this as a logic-one as it is considerably higher than the previously identified 15 VDC threshold.
When deactivated, the PNP transistor does not pull. Consequently, the voltage on the black wire will be zero and the PLC will register a logic-zero.

Figure 1: PNP sensor to PLC configuration.

Tech Tip: The three-wire open collector configuration allows sensors to be connected in parallel using a wired OR configuration. You can find additional information about this type of configuration in this related post. While this is a valid configuration, the system will be easier to troubleshoot if each sensor is connected to an independent PLC channel.

PLC to NPN Sensor Interface

Figure 2 presents the NPN sensor to PLC interface. The added complexity is immediately apparent. You can now understand why the PNP sensor if the preferred solution given the constraint we identified earlier.

Recall that the NPN transistor pulls the load down. The external 1 kΩ resistor is an essential component as it provides the critical load for the NPN transistor to pull against. Without this external resistor, the sensor’s output (black) wire will always be zero. Many technicians and engineers have fallen into this trap wondering why the sensor is “defective” when it is incorrectly configured.

We need to step back at this point and apply Ohm’s law to ensure the external resistor is sufficient. For a moment, let’s ignore the sensor. What remains is a voltage divider between the external 1 kΩ and the PLC’s internal 10 kΩ resistor. Using the voltage divider rule we can calculate the PLC input voltage as:

V_{PLC} = 24 * \dfrac{10 }{1 + 10} \approx 22\ VDC

This voltage will be safely interpreted as a logic-one by the PLC.

We can now activate the sensor. It will pull at the center of this 22 VDC voltage divider to ground. In an ideal situation, the PLC’s input voltage will now be zero.

Figure 2: NPN sensor to PLC configuration.

PNP vs NPN Logic Inversion

At this point, you may be tempted with the belief that NPN and PNP sensors are interchangeable. This is almost true. Looking back, we interpret an active PNP sensor as a logic-one. Contrasted with an active NPN sensor interpreted as a logic-zero.

Changing sensor types will require a modification to the PLC program to account for the inversion. Hopefully, the programmer used input mapping and the associated I/O pin appears in one and only one location. With I/O mapping this will be an easy change that you can make with confidence. Without a map – well maybe just wait for the correct sensor to arrive, but that is another story.

Best Wishes,


P.S. Sensor selection between a PNP and NPN should be guided by failsafe considerations. Always ask what will happen if there was a broken wire or a sensor failure. This is related to the concept of an emergency stop. Things that stop a machine should be wired using normally closed contacts so that a broken wire will turn off the machine.

Thank you. Do you have any content in your website that can help newbies to learn about PLC?

Thank you, bidrohini.

At this point there is limited PLC data on this forum. Perhaps we can change that in the future. For now I will refer you to:

Please let us know if these links are useful. Also, if you are reading this, please add additional links or comments below.

Best Wishes,


1 Like

Thanks a lot. I will check these out soon.

1 Like