ExamRobotic

PNP and NPN sensor simulator

Wiring a 3-wire sensor to a PLC looks easy until the input refuses to light. Here you can connect an inductive PNP or NPN sensor to a 24 V supply and a PLC input, wire by wire, and see where the current flows, what voltage there is at every point and why it works or not. Make all the mistakes you like: nothing burns out here.

The sensor

Output type

Contact

The part

The PLC card

Wiring: which terminal does each wire go to?

What a multimeter would read

Find the fault

A correctly wired sensor is set up with a random fault, and you are not told which. Find it by moving the part and watching the LEDs and the measurements, just as you would at the machine.

Try this

    How to use it

    PNP vs NPN in one sentence

    Both have three wires: brown to +24 V, blue to 0 V and black for the signal. The difference is what the black wire does when the sensor detects:

    PNPNPN
    On detection, black goes to+24 V (switches the positive)0 V (switches the negative)
    With nothing detected, black isleft floatingleft floating
    The card common goes to0 V+24 V
    The PLC inputsinks currentsources current
    Most common inEuropeAsia and machines built there

    One way to remember it: the P in PNP goes with Positive, and the N in NPN goes with Negative.

    Sinking and sourcing: the naming mess

    Sinking and sourcing describe which way the current flows, seen from whoever is talking. A PNP sensor sources current and the input that receives it sinks it. With an NPN it is the other way round. The confusion comes from some manufacturers naming the card by how the input works and others by the sensor it accepts: a "sinking input" and a "PNP input" can be exactly the same thing. The safe approach is to look at the wiring diagram in the card manual, which shows where the common goes.

    Some cards, like the built-in inputs of the S7-1200 CPU, accept current in both directions (inside there is a bidirectional optocoupler) and work with PNP or NPN depending on where you connect the common. Many remote I/O cards, however, only let it through one way. That is why an NPN on a "PNP only" card gives the right voltages and still does not light the input. Try it in the simulator.

    Why almost everything in Europe is PNP

    Picture a chafed signal wire rubbing against the machine frame, which is earthed and normally tied to 0 V. With a PNP, that rub is a short circuit: the sensor protects itself and the input stays at 0. With an NPN, touching 0 V is exactly what the sensor does on detection, so the input switches on by itself and the PLC thinks there is a part. A fault that gives a false signal is much worse than one that leaves the signal at zero. That is why Europe almost always uses PNP with the common at 0 V. NPN is common on machines from Asia, and North America uses both: check before ordering a replacement.

    Note that neither PNP nor NPN turns a standard sensor into a safety device. Guards, light curtains and emergency stops are monitored with safety sensors and safety relays, not with standard PLC inputs.

    Sensing distance and materials

    The rated sensing distance (Sn) of an inductive sensor is measured with a standard steel target. Other metals are detected closer: multiply Sn by the correction factor from the datasheet. Typical values:

    MaterialFactorWith Sn = 4 mm
    Steel14 mm
    Stainless steel0.6 to 1 (depends on the alloy)2.4 to 4 mm
    Brass0.4 to 0.51.6 to 2 mm
    Aluminium0.3 to 0.451.2 to 1.8 mm
    Copper0.25 to 0.41 to 1.6 mm
    Plastic, wood, cardboard0Not detected

    To make it work every time, you stay within the assured operating distance (Sa), which is 81 % of Sn: with a 4 mm sensor, the part should pass at 3.2 mm or less. A flush sensor, which can be mounted embedded in metal, has a shorter range than a non-flush one of the same size. And they all have hysteresis: they switch off a little further away than where they switch on, so the output does not chatter when the part vibrates right at the limit.

    NO or NC

    A normally open (NO) sensor switches its output on when it detects. An NC sensor does the opposite: its output is on while nothing is detected and goes off on detection. NC is used when a broken wire should be treated as the safe condition. For example, a high-level sensor on a tank: if it is NC, both "tank full" and "broken wire" leave the input at 0 and the pump stops. There are also 4-wire sensors with one NO and one NC output.

    How to troubleshoot a sensor

    1. Check the power LED. If it is off, measure between brown and blue at the sensor itself or at its connector. If there are no 24 V, look for a broken wire or a blown fuse.
    2. Bring a part close and watch the output LED. If it does not light, check the distance, the material, and that the sensing face is clean and undamaged.
    3. If the LED lights but the PLC does not see it, measure between I0.0 and 1M, not between I0.0 and 0 V. With a PNP you should see about 22 or 23 V on detection.
    4. If there is voltage between I0.0 and 1M but the input LED stays off, the card is not reading it: either it is the wrong type, or that input is damaged.
    5. If the output LED flashes, on many sensors that warns of a short circuit or overload: look for a chafed or pinched black wire. Check the manual, because others flash when the part passes right at the edge of the range.
    A simulator is not an installationThe values are those of an ideal case: consumption, residual voltage, input thresholds and the way a short circuit is signalled vary from one manufacturer to another. Before connecting a real sensor, read its datasheet and the card wiring diagram, and make the connections with the power off.

    To understand the topic in depth: Commissioning with the programmer, with theory and a practice test.