Sensor Outputs and Wiring
NPN and PNP outputs, two-, three- and four-wire sensors, analog 4-20 mA and 0-10 V, IO-Link, and connecting sensors to PLC inputs.
On this page
- Discrete outputs: NPN, PNP, NO and NC
- Two-, three- and four-wire sensors
- Connectors and color codes
- Connecting to PLC inputs
- Two-wire sensors: leakage current and voltage drop
- Analog sensors: 4-20 mA and 0-10 V
- IO-Link and smart sensors
- Power supply and cable voltage drop
- Reading a datasheet
- Troubleshooting wiring problems
- FAQ
Discrete outputs: NPN, PNP, NO and NC
A discrete (switching) sensor has an output that is either on or off. Almost every modern industrial sensor uses a transistor output (solid state, no contact wear). The transistor connects the output wire to one of the supply rails:
| Type | When on, the output is… | Current flows… | Typical region |
|---|---|---|---|
| PNP (sourcing, “plus switching”) | Connected to +V | From the sensor output, through the load, to 0 V | Europe, Asia and most of the world |
| NPN (sinking, “minus switching”) | Connected to 0 V | From +V, through the load, into the sensor output | US, Japan; older equipment |
| Push-pull | Actively driven to +V or 0 V | Either way | Fast pulse outputs, some IO-Link ports |
| Relay or contact | A dry contact closed | Any, per the rating | Higher power or mixed voltages |
Normally open (NO) means the output is off when nothing is detected and on when the target is present; normally closed (NC) is the opposite (on when nothing is detected). Many sensors have both outputs, or a switch to select them. For a safe design an NC output is often preferred: a broken wire then looks like a detection, not an empty space (a fail-safe design; see Installing and Troubleshooting Sensors).
Two-, three- and four-wire sensors
| Wires | Connections | Notes |
|---|---|---|
| Two | In series with the load, like a switch | No separate supply: the sensor takes its power through the load. Needs a minimum load current and leaks a little when off (see below). Simple to wire, DC or AC |
| Three | +V, 0 V, output | The standard for DC proximity and photoelectric sensors: PNP or NPN; the sensor draws its own current (10 to 20 mA) |
| Four | +V, 0 V, an NO and an NC output (or two outputs) | Both logic senses at once, or an alarm output; the white wire is the second output |
| Five | +V, 0 V, and a change-over relay contact, or IO-Link plus outputs | Relay output sensors and multi-function types |
Connectors and color codes
Sensor cables follow the color code of IEC 60947-5-2, and standard round connectors (M8, M12) make replacement quick. The wiring of a four-pin M12 (A-coded) connector for a PNP sensor is:
| Pin | Color | Function | Notes |
|---|---|---|---|
| 1 | Brown | +V (10 to 30 V DC) | Supply positive |
| 2 | White | Second output or NC / not connected | Output 2, or an input for teach / sync |
| 3 | Blue | 0 V | Supply negative |
| 4 | Black | Switching output (NO) | On when the target is detected |
| 5 (5-pin) | Gray | Extra function or shield | Teach, IO-Link (C/Q is on pin 4) |
- M8 (3 or 4 pins) for small sensors, M12 (4 or 5 pins) for most industrial devices, and M12 D-coded and X-coded for Ethernet (see Cabling, Grounding and Noise). Pin numbering and colors are standard, but always check the sensor’s label.
- Use pre-molded cordsets with the right length and a flex-rated cable for moving parts (robots, drag chains). A cable that flexes constantly needs a fine-stranded, high-flex type.
- Do not use a color alone to identify a wire when a cable has been modified: test with a meter.
Connecting to PLC inputs
A 24 V DC input card is made to sink or to source current at each input. A sensor that sources current (PNP) pairs with a card that sinks it; a sensor that sinks (NPN) pairs with a card that sources. The two do not mix. Many cards can be wired either way by the choice of the common terminal (connect the common to 0 V for sinking inputs, or to +24 V for sourcing). Check the manual, and remember that the standard is IEC 61131-2.
| Sensor | Input card must be… | Common terminal goes to… |
|---|---|---|
| PNP (sourcing) | Sinking (current into the input, to 0 V) | 0 V |
| NPN (sinking) | Sourcing (current out of the input, from +24 V) | +24 V |
| Dry contact (mechanical) | Either | Switch from the supply to the input; mind the wetting current of small contacts |
- Input levels (IEC 61131-2, type 1): on above 15 V, off below 5 V, in between undefined; the input draws about 3 to 7 mA when on (an input resistance around 3 to 4 kΩ).
- Filters: the input has a filter time (1 to 10 ms) that rejects noise but also limits the speed; use a high-speed input for pulses above about 100 Hz (see Proximity Sensors).
- Grouping: inputs share a common in groups of 8 or 16; do not mix PNP and NPN sensors in one group.
- Wiring up a PLC: see I/O Wiring and Signals for the cabinet side.
Two-wire sensors: leakage current and voltage drop
A two-wire sensor is in series with the load, so it needs two things: a small current to power its electronics even when off (residual or leakage current, typically 0.5 to 2 mA) and, when on, a voltage drop of 3 to 6 V, which is subtracted from the supply. It also has a minimum load current to stay on (around 3 to 5 mA).
Worked example: leakage current on a PLC input
- A PLC input has an input resistance of 3.3 kΩ and treats a voltage below 5 V as off. A two-wire sensor leaks 1.5 mA when off: the voltage across the input is 1.5 mA × 3.3 kΩ = 4.95 V, right at the off threshold: the input may flicker or read on.
- Add a bleeder resistor across the input to reduce the voltage. For an off voltage of 2 V the parallel resistance must be below 2 V ÷ 1.5 mA = 1 333 Ω, so the resistor must be below 2 237 Ω: take the standard 2 200 Ω (parallel 1 320 Ω, giving 1.98 V when off).
- The resistor dissipates P = V² ÷ R = 24² ÷ 2 200 = 0.26 W when the input is on: use a 0.5 W part, and check that the sensor’s minimum on-current is still met. A 3-wire sensor avoids the problem altogether.
Analog sensors: 4-20 mA and 0-10 V
| Signal | Strengths | Cautions |
|---|---|---|
| 4 to 20 mA (current loop) | Immune to cable resistance and most noise, works over hundreds of meters, a live zero (4 mA) detects a broken wire, the transmitter can be loop-powered (2-wire) | Needs a loop supply; each receiver must be the right type (passive or active); ground loops if grounded at two points |
| 0 to 10 V, ±10 V | Simple, quick, easy to read with a meter | Voltage drop and noise over long cables; no broken-wire detection at 0 V; input impedance matters |
| 0 to 20 mA, 1 to 5 V, 0 to 5 V | Variations of the above | Check the range of the input channel |
Worked example: loop voltage budget
- A loop-powered transmitter needs at least 10 V at its terminals. With a 24 V supply the other elements of the loop (receiver and wire) can drop up to 14 V at the maximum current of 20 mA: a loop resistance of 14 ÷ 0.020 = 700 Ω.
- A receiver of 250 Ω and 100 Ω of cable use 350 Ω, leaving 350 Ω of margin. The receiver resistor turns the current into a voltage: 4 mA × 250 Ω = 1.0 V and 20 mA × 250 Ω = 5.0 V, a 1 to 5 V signal; a HART device needs at least 230 to 250 Ω in the loop.
- A current of 7.2 mA is (7.2 − 4) ÷ 16 = 20 percent of the span (use the Analog Scaling Tool). A current below 3.6 mA or above 21 mA signals a fault (NAMUR NE43).
- Voltage signals: a 0 to 10 V cable of 20 Ω into a 100 kΩ input loses 0.020 percent: negligible for a high-impedance input, but a 10 kΩ input would lose 0.2 percent, and noise pickup is the greater danger over a long cable.
- 2-wire, 3-wire and 4-wire analog transmitters: a 2-wire transmitter is powered by the loop. A 3-wire has a supply and a common return shared with the signal. A 4-wire (active) has its own supply and a separate 4 to 20 mA output. Know which kind the input expects: an active transmitter on a loop-powered input, or two supplies in one loop, will not work (or will damage something).
- Isolation: isolate channels from each other and from the supply (loop isolators), especially when sensors in different places have different grounds.
- Shield: ground the shield at one end only, at the controller (see Installing and Troubleshooting Sensors).
IO-Link and smart sensors
IO-Link (IEC 61131-9) is a point-to-point communication link between an IO-Link master and a sensor, with the same standard three- or five-wire M12 cable, up to 20 m, unshielded. It adds digital data to a normal switching or analog sensor: process values (as numbers, not a noisy voltage), parameters (set from the PLC, stored in the master so that a replacement device is configured automatically), events and diagnostics (dirty lens, over-temperature, wire break).
| Feature | Standard I/O | IO-Link |
|---|---|---|
| Signal | On/off, 4-20 mA or 0-10 V | Digital data on the C/Q line; the same sensor can also run in plain SIO mode |
| Data | One value | Process data (up to 32 bytes), parameters, events |
| Speed | n/a | 4.8, 38.4 or 230.4 kbaud (COM1, COM2, COM3) |
| Wiring | One cable per signal, shielded for analog | The same cable, one master port per device; unshielded up to 20 m |
| Replacement | Re-teach or set switches by hand | The master downloads the stored parameters to the new sensor |
| Cost | Lowest | A little more per sensor, plus the masters |
The master connects to the PLC over a fieldbus (PROFINET, EtherNet/IP, EtherCAT, Modbus TCP): see Fieldbuses and Device Networks. A hybrid sensor with IO-Link is a way to get diagnostics and remote parameter setting on an ordinary installation.
Power supply and cable voltage drop
Sensors want a clean 24 V DC (10 to 30 V). Use a regulated supply, fused per group, and keep the sensor supply separate from motor and valve supplies where a noisy load could disturb it. Check that the supply voltage at the last sensor is still within its limits under load.
Worked example: cable drop
Copper of 0.5 mm² has a resistance of about 0.034 Ω per meter. A 50 m run needs two conductors (out and back): 3.44 Ω. A single sensor taking 0.2 A drops 0.69 V. Twelve sensors of 0.1 A each at the far end draw 1.2 A and drop 4.1 V: from 24 V that leaves 19.9 V, still fine for 10 V minimum, but a 12 V supply would be marginal. Use heavier cable for long runs and high currents, and fuse each branch.
Reading a datasheet
| Item | What to check |
|---|---|
| Supply voltage and ripple | Within the range, including the drop on the cable |
| Output type and current | PNP or NPN, NO or NC, the maximum current (100 to 200 mA), short-circuit protection |
| Voltage drop and leakage | On a 2-wire sensor and on the output transistor (about 2 V) |
| No-load current | The sensor’s own consumption (10 to 20 mA): the supply must cover all of them |
| Protections | Reverse polarity, short circuit, overload, surge |
| Response and frequency | Switching frequency and response time against the application |
| Environment | Temperature range, IP rating (IP67, IP69K), shock and vibration, chemical resistance |
| Connection and cable | Connector type, cable length, flexing rating |
| Approvals | CE, UL, ATEX, food-grade, safety (only safety sensors, see Safety Sensors and Devices) |
Troubleshooting wiring problems
| Symptom | Likely cause | Check |
|---|---|---|
| Sensor LED lights but the PLC input stays off | PNP sensor on a sourcing card (or the reverse), a missing common, a broken signal wire | Sink or source; common; measure at the input terminal |
| Input stays on with the sensor off | Leakage of a 2-wire sensor, a short to +24 V, an NC output | Measure the voltage on the input; add a bleeder resistor; check NO or NC |
| Sensor does not light at all | No supply, reversed polarity (a protected sensor survives), a blown fuse | Measure 24 V at the sensor with a load |
| Intermittent signals | A damaged cable, a loose connector, vibration | Wiggle test, ohmmeter the cable, replace with a flex cable |
| Analog value jumps or is noisy | A bad shield, a ground loop, a long voltage signal, an unfiltered channel | Shield grounding at one end, a current loop, the filter setting |
| 4-20 mA reads 0 | A broken loop (open circuit), no loop supply, polarity reversed | Measure the loop current with a series meter; the supply at the transmitter |
| Wrong value, correct signal | The scaling in the program does not match the sensor’s range | Check the engineering units and ranges (see the Analog Scaling Tool) |
| One sensor disturbs others | Shared supply with a heavy load, a noisy cable run | Separate the supplies; route apart |
Related
- Sensors and Field Devices: the overview of this guide.
- Installing and Troubleshooting Sensors: mounting, protection, shielding and fault finding.
- I/O Wiring and Signals: the PLC side of these connections.
- Fieldbuses and Device Networks: IO-Link, AS-Interface and HART.
- 4-20 mA / 0-10 V Analog Scaling Tool.
FAQ
PNP or NPN?
Match the input card: a PNP sensor needs a sinking input, an NPN sensor a sourcing input. If you have a choice, use PNP (the world standard outside the US and Japan), and use the same type throughout a machine.
Why does a sensor still seem to be on when nothing is detected?
A two-wire sensor leaks a little current, which can be enough to hold a high-impedance input on. Measure the voltage on the input and add a bleeder resistor, or use a three-wire sensor.
Can I connect two sensors in series or in parallel?
Series (AND) works for three-wire sensors but the voltage drops add up; parallel (OR) needs diodes or sensors made for it. In many cases it is cleaner to wire each to its own input and combine them in the program.
Why 4 to 20 mA instead of 0 to 20 mA?
The live zero: 4 mA means “zero”, and 0 mA means a fault such as a broken wire. It also gives the transmitter enough current to power itself in a 2-wire loop.
References
- IEC 60947-5-2, Proximity switches (output types, color code); IEC 61131-2 (PLC equipment, input characteristics); IEC 61131-9 (IO-Link).
- IO-Link Community, IO-Link Interface and System Specification; NAMUR NE43 (signal level for failure information of transmitters).
- Manufacturer wiring guides: Pepperl+Fuchs, Sick, Balluff, Turck, ifm.
Last reviewed: October 2026. Voltage thresholds and currents are typical; use the data of your sensor and your input card.
