Most of what a PLC knows about the machine comes through digital inputs, and most of what it does goes out through digital outputs. Wiring them correctly is where theory meets the panel.
Common input devices
- Push buttons and selector switches: operator commands. Start buttons are usually green with a normally open contact; stop buttons are red with a normally closed contact.
- Limit switches: a mechanical lever or plunger pressed by a moving part.
- Inductive proximity sensors: detect metal without contact, typically within a few millimetres. Very reliable for detecting cylinder positions and machine parts.
- Capacitive sensors: detect almost anything, including liquids and plastic, so they are used for levels through a tank wall.
- Photoelectric sensors: a light beam detects objects at a distance, on conveyors and doorways.
- Float and level switches, pressure switches, thermostats: process conditions as ON/OFF signals.
Normally open and normally closed
A normally open (NO) contact is open when nothing is pressing it, and closes when operated. A normally closed (NC) contact is closed at rest and opens when operated. “Normally” means “in its resting, un-operated state”, not “usually during operation”.
Stop buttons, emergency stops and overload contacts are wired NC for a very good reason: if the wire breaks or falls off a terminal, the circuit opens and the machine stops. A broken wire on an NO stop button would leave you with a stop button that does nothing. This is called fail-safe wiring and you will see it again in lesson 10.
Sensor cables: brown, blue, black
Electronic sensors need power to work, so they have more than two wires. The standard colour code (IEC 60947-5-2) is:
| Wire | Colour | Connects to |
|---|---|---|
| +V supply | Brown (BN) | +24 V DC |
| 0 V supply | Blue (BU) | 0 V |
| Output (NO) | Black (BK) | PLC input |
| Second output (NC) | White (WH) | PLC input, if used |
Two-wire sensors also exist. They sit in series with the input like a switch, but they leak a small current when off and drop a few volts when on, so check that the PLC input is compatible.
Sinking and sourcing, explained by current
Forget memorising rules for a moment. For an input LED to light, current has to flow in a loop: out of the +24 V terminal of the supply, through the input circuit, and back to 0 V. Something in that loop has to switch.
- A PNP sensor, also called sourcing, connects its black output to +24 V when it detects something. Current flows out of the sensor into the PLC input, so the other side of the input (its common, COM) must go to 0 V. That is a sinking input: it sinks current to 0 V.
- An NPN sensor, also called sinking, connects its black output to 0 V when it detects something. Current must therefore come from the PLC side: the input common goes to +24 V. That is a sourcing input.
So: PNP sensor → sinking input (COM to 0 V). NPN sensor → sourcing input (COM to +24 V). If you get it wrong, nothing breaks, but the input never turns on, because both ends of the input are at the same voltage and no current flows.
Try every combination in the simulator below. Tick “Target in front of the sensor” and watch whether the PLC input LED turns on.
NPN / PNP sensor wiring simulator
See which sensor works with which PLC input, and why
Formula and notes
PNP → sinking input (COM = 0 V) NPN → sourcing input (COM = +24 V)
Current must flow in a loop: from +24 V, through the sensor and the PLC input LED, back to 0 V. A PNP sensor connects its output to +24 V, so the input must return to 0 V. An NPN sensor connects its output to 0 V, so the input must be fed from +24 V. Wire colours follow IEC 60947-5-2: brown +V, blue 0 V, black output.
Regional habit: PNP sensors and sinking inputs are the norm in Europe, Africa and much of the world; NPN is common on Japanese and some Asian machines. Many modern PLCs let you choose per group of inputs by where you connect the common.
Wiring outputs
Outputs follow the same loop idea. A relay output is just a contact: one side to the load, the other to the supply that powers the load. A transistor output switches either +24 V to the load (sourcing, PNP style) or the load to 0 V (sinking, NPN style).
- Drive contactor coils from the PLC, and let the contactor switch the motor.
- Fit a flyback diode (or use coils with built-in suppression) across DC inductive loads such as solenoid valves and relay coils. Without it, the voltage spike at switch-off shortens the life of transistor outputs.
- Respect the current per common, not just per point. Eight outputs at 2 A on one 8 A common is already at the limit.
- Fuse output groups so a short circuit in the field does not take out the whole card.
Safety: isolate and lock off the supply before working on terminals. Inputs at 24 V DC are low risk, but relay outputs and the PLC supply may be at mains voltage.
Frequently asked questions
Can I connect an NPN sensor to a PLC that only has sinking inputs?
Not directly. Use an interface relay, a PNP version of the sensor, or a pull-up resistor arrangement recommended by the sensor manufacturer.
What does the white wire on a sensor do?
On four-wire sensors it is usually a second output that is the inverse (NC) of the black output. Check the sensor label or datasheet.
