Explainer
Why a PNP proximity switch does not fit an active-low input
Short answer
A PNP proximity switch sources positive voltage on its output, while an active-low input only asserts when something pulls its terminal to 0 V. Wired directly, the input never sees a valid low, so the controller never sees the switch operate. Replace the sensor with an NPN (sinking) type, or keep the PNP switch and add a one-transistor inverting interface; add current limiting when the sensor side runs above 12 VDC.

On this page
- Sourcing and sinking: what the two output types do
- What an active-low input waits for
- Why the direct connection fails
- Choose the fix
- The one-transistor interface
- Worked example: base resistor for a 24 VDC PNP output on a Darlington
- Current limiting above 12 VDC
- Test the polarity before the machine runs
- Questions asked
A PNP proximity switch cannot drive an active-low input, and no wiring trick or software setting changes that. A PNP output is a sourcing output: when it switches on, it connects its output wire to the positive supply. An active-low input asserts only when something pulls its terminal down to the common return. The two conventions push in opposite directions, so the input never sees the transition it is looking for. The decision is simple: fit an NPN (sinking) sensor of the same family, or keep the PNP switch and add a one-transistor inverting interface between it and the input. This article explains both conventions, shows why the direct connection fails, and works the resistor numbers for the converter.
Sourcing and sinking: what the two output types do #
A three-wire DC proximity switch has supply, 0 V and output wires, and what the output does when the switch turns on is the whole difference. A PNP output is called a sourcing output because it sources positive power to the load: active means the output wire sits at the positive supply voltage, and the load completes the circuit down to 0 V. An NPN output is called a sinking output because it accepts current from the load and returns it to that common rail: active means the output wire is pulled down to near the common rail, and the load supplies the positive side. Both types exist across the common 24 VDC industrial sensor range, so the output type is a purchasing decision, not a given. Check it on the sensor datasheet before you design anything around it.
What an active-low input waits for #
An active-low input asserts when its terminal is pulled to 0 V. The input carries its own pull-up to positive supply, or it expects the sensor to act as a switch to common; either way, the sensor's job on this kind of input is to sink current, not to supply it. Many stepper drives and motion controller inputs are built this way: the terminal sits high while idle, and the sensor pulls it low to signal. So the correct sensor for an active-low input must leave the terminal alone when idle and short it toward the common rail when active. An NPN sensor does that natively.
Why the direct connection fails #
Wire the PNP switch straight to the active-low input and both states are wrong. With a target present, the PNP output drives the terminal to positive supply, the opposite of the asserted low. With no target, the output transistor turns off and leaves the terminal floating, so the input reads whatever its pull-up and stray leakage decide, and it can sit on the wrong side of the logic threshold. In neither state does the terminal make the low-going transition the input waits for, so the controller never registers the switch. This is why inverting a polarity setting in software cannot rescue the pairing: there is no transition to reinterpret.
The pairing does work when the destination is an optocoupler rather than a drive input, and the guide on wiring PNP proximity switches to optocoupler inputs covers that case. The failure described here is specific to inputs that require the low-going signal itself.
Choose the fix #
| Fix | What you do | Where it fits |
|---|---|---|
| Swap the sensor for an NPN type | Same sensing family, size and cable length, sinking output | You are buying or reordering sensors anyway; this is the permanent fix |
| One-transistor inverter | PNP output feeds a Darlington base through a resistor; the collector sinks the input | The PNP switches are already mounted, wired or expensive to replace |
| Interposing relay | PNP output energizes a relay coil; a normally open contact pulls the input low | You want galvanic isolation or the input draws more current than a small transistor stage handles comfortably |
When you are buying sensors anyway, buy NPN and be done. When the PNP switches are already installed on the machine, the transistor interface is the cheaper repair and takes one resistor and one transistor per input.
The one-transistor interface #
The wiring is short. Connect the PNP output to the base of an NPN Darlington through a resistor, the emitter to the common rail, and the collector to the input terminal. The input's own pull-up holds the terminal high while the transistor is off. When the PNP switch turns on, it feeds the base through the resistor, the transistor saturates, and the collector pulls the input terminal low, which is the asserted state. When the switch turns off, the resistor returns the base to the common rail, the transistor stops conducting, and the input floats back high through its pull-up. The stage reproduces exactly the behavior of a sinking sensor.
Worked example: base resistor for a 24 VDC PNP output on a Darlington #
Inputs for this example:
- Output high voltage when the PNP switch is active: 24 VDC, the usual class of industrial DC proximity switch supply.
- Base-to-emitter drop of the conducting Darlington: about 1.4 V, because two forward-biased junctions sit in series inside the device.
- Target base current: 5 mA, enough to saturate a small Darlington for input-scale load currents.
The rule, in words: the base resistor equals the output high voltage minus the base-emitter drop, divided by the target base current.
The arithmetic: the resistor must drop 24 V minus 1.4 V, which is 22.6 V. At the target current, 22.6 V divided by 0.005 A gives 4520 Ohm. The nearest standard value is 4.7 kOhm.
Check with the chosen value: 22.6 V divided by 4700 Ohm gives 4.8 mA of base current.
Decision: 4.7 kOhm works for this case, because 4.8 mA saturates the Darlington for the few tens of milliamps a controller input needs sunk, which is far below any small-signal Darlington's rated collector current. Read the input's rated input current from the drive manual and keep it below the transistor's rated collector current on the transistor datasheet before you build the stage. This is a calculated example for these inputs, not a measured result. The same resistor arithmetic, worked for a TIP120 driver stage, appears in the guide to calculating current-limiting resistors for TIP120 driver circuits.
Current limiting above 12 VDC #
When the sensor side runs above 12 VDC, the converter stage needs deliberate current limiting, and the series resistor is what provides it: at 24 VDC the resistor drops roughly twice what the same stage drops at 12 VDC, so a value picked for one supply overcurrents the other. Size the resistor from the actual supply voltage and the target current, as the worked example above does, rather than copying a value from a different supply. The same rule applies to any optocoupler LED you place in this path.
Test the polarity before the machine runs #
Test the completed interface with the drives disabled: present a metal target to the sensor and confirm the input changes from inactive to asserted, then remove the target and confirm it returns to inactive. If the input reads backwards, correct the wiring or the interface, not a software polarity flag, because the hardware stage is what determines which state the input can actually reach. Keep the test with motion disabled so a reversed home or limit signal cannot move an axis the wrong way the first time it fires. An inverting stage built on the noisy side of a cabinet can also pick up switching noise, and the notes on hardening 24 V optocoupler inputs against industrial EMI noise apply to any input fed from that side.
Questions asked
Can I flip the input polarity in software instead of changing the sensor?
No. A polarity setting only changes how the controller interprets the input; it cannot create the missing voltage level. A PNP output on an active-low input either holds the terminal at positive supply or leaves it floating, and it never produces the low-going transition the input looks for. Change the sensor type or add an inverting interface first, then set polarity in software if your controller offers it.
Does an NPN sensor have the same problem on an active-high input?
Yes, it is the mirror image. An NPN output sinks current toward ground when active and floats when idle, so it can pull a terminal low but never drives it to positive supply. An active-high input needs the sensor to source voltage, so it needs a PNP sensor or a sourcing-style interface, exactly as an active-low input needs an NPN sensor or a sinking-style interface.
Can I use a relay instead of a transistor to convert the signal?
Yes. Wire the PNP output to the coil of a small DC relay rated for the sensor's output current, and use a normally open contact between the input terminal and the common return. When the sensor switches on, the contact closes and pulls the input low, behaving like a sinking sensor. The relay adds isolation, at the cost of slower switching and eventual contact wear.
How do I tell whether an installed sensor is PNP or NPN?
Read the datasheet first; many makers encode the output type in the ordering code. Electrically, measure the output wire against 0 V, first with no target and then with a metal target present. A PNP output rises to the positive supply when the target arrives; an NPN output drops to near 0 V on a wire that sat above 0 V while idle.
What changes the base resistor value in the transistor interface?
The sensor's output high voltage and the base current you want. A lower sensor supply shrinks the resistor proportionally: on a 12 VDC output, the same 5 mA target needs about 2.1 kOhm, because (12 minus 1.4) V divided by 0.005 A is 2120 Ohm. Keep the collector load current within the transistor's datasheet rating either way.

