How-to
Wiring PNP proximity switches to optocoupler inputs
Short answer
Give every PNP three-wire proximity switch its own optocoupler input, and combine after isolation when one axis has two endpoint switches. Size each series resistor as R = (Vsupply - Vdrop - VF) / IF from worst-case datasheet values: at 24 V with a 0.5 V sensor drop and a 1.2 V LED that gives 2.2 k ohm at 10 mA. Never copy a resistor from another board, and never series the sensor outputs.
On this page
Give each PNP three-wire proximity switch its own optocoupler input, combine channels after isolation, and calculate every LED series resistor instead of copying one: for the five-switch retrofit — two sensors on X, two on Y, one on Z — that means five LED channels, each with its own 2.2 k ohm, 0.5 W resistor for a 24 V sensor supply, a 0.5 V sensor drop and a 1.2 V LED at 10 mA. The sensor outputs themselves stay out of any series or shared connection: a three-wire PNP output is an amplifier that sources supply voltage, not a contact. If the retrofit also replaces mechanical limit switches, the machine-side half of that job is covered in replacing a mechanical limit switch with a proximity sensor.
One channel per sensor #
Three wires carry the whole sensor: brown to +V DC, blue to the supply common, black to the output. On a PNP unit the load connects between the black wire and the common, and the made output sources current at close to full supply voltage; NPN mirrors this with the load returned to L+, which is why the two output types never share one input arrangement.
That output is an amplifier with three governing numbers — rated continuous output current, ON-state voltage drop and OFF-state leakage current — all stated in the sensor datasheet; proximity switches are rated under IEC 60947-5-2, the product standard those limits come from. One LED channel per sensor keeps the five switches electrically independent: you bench-test or unplug any one of them without touching the other four, and a wiring fault on one axis cannot propagate into another.
Why the sensor outputs stay out of series #
With contacts you series two limit switches into one signal. With sourcing transistor outputs that construction fails three ways. The first sensor's output would have to power the second sensor's internal amplifier, so whenever the first is OFF the second is unpowered and cannot report anything. When the first is ON, both ON-state drops subtract from what the load receives. And the first output transistor carries the second sensor's entire supply current, continuously. Some sensor families document a permitted series connection with a stated stage count and drop budget; commit to it only if your sensor's datasheet is one of those. An optocoupler LED in the chain would stack a third drop — one more reason the combining belongs on the far side of the interface.
Size the input resistor per channel #
Each channel is one resistor in series with the optocoupler LED:
R = (Vsupply − Vdrop − VF) / IF
- Vsupply: sensor supply voltage, measured at the sensor
- Vdrop: sensor ON-state output voltage drop, from the sensor datasheet
- VF: optocoupler LED forward voltage at the chosen current, from the optocoupler datasheet
- IF: the LED current you choose to run
Worked example — a calculated example for exactly these inputs, not a measured result. Supply 24 V, sensor drop 0.5 V, a 4N35-class optocoupler LED at VF = 1.2 V, target IF = 10 mA:
R = (24 V − 0.5 V − 1.2 V) / 0.010 A = 22.3 V / 0.010 A = 2230 Ω → fit 2.2 kΩ, the nearest standard value.
That resistor dissipates P = (22.3 V)² / 2200 Ω = 0.23 W, so a 0.25 W part runs at 90 % of its rating; use 0.5 W. Re-run the arithmetic at worst-case low supply: at 22.8 V (a 5 % sag), (22.8 − 0.5 − 1.2) V / 2200 Ω = 9.6 mA, and that current must still saturate the output for the load the input presents.
Resistor values do not travel. The 330 Ω input resistor often copied from small optocoupler boards computes correctly at 5 V: (5 − 0.5 − 1.2) V / 330 Ω = 3.3 V / 330 Ω = 10 mA, on target. Behind the same sensor supply that resistor would drive 22.3 V / 330 Ω = 68 mA through the LED and the sensor output, past what either is built to carry.
Two datasheet checks close the input side. OFF state: leakage current with no target present flows through the same LED path, so leakage times your resistance must stay below the voltage where the LED begins conducting, or the channel never fully releases. Drive margin: a transistor optocoupler delivers only its current-transfer-ratio fraction of IF to the output, so the controller input must draw less than that fraction; if it draws more, raise IF, move to a logic-output optocoupler, or drive an interposing relay.
Combine on the controller side #
The controller gives you one limit input per axis while each axis carries two endpoints. Do the logic with the isolated outputs and pick the wiring that matches the function:
- Parallel optocoupler outputs: collectors commoned onto the input line with its pull-up, emitters commoned. Either sensor made pulls the input. This is the endpoint function — the axis must stop at whichever end it reaches — so it is the wiring for the X and Y pairs.
- Series optocoupler outputs: one transistor's collector to the other's emitter, so current flows only when both LEDs are driven — a true AND. Reserve it for an input that must assert only under two conditions at once, and check that the two collector-emitter saturation voltages, from the datasheet, together still meet the input's levels; a higher-voltage input shrugs them off, a 5 V TTL input's maximum LOW level might not.
- Interposing relays: each sensor drives a small relay coil instead of an LED and the contacts become the dry interface. Parallel normally-open contacts reproduce either-endpoint logic; series normally-closed contacts put both relays into one monitored loop where an open wire or a lost coil also signals, which is the fault detection the direct wirings lack. The coil current must sit inside the sensor's rated continuous output current.
A transistor optocoupler's base pin stays unconnected for switch-speed signals. Inputs characterized under IEC 61131-2 publish guaranteed ON and OFF bands of voltage and current; the combination has to land inside those bands, not the nameplate voltage.
Commissioning the interface #
- De-energize both the sensor supply and the controller before touching wiring.
- Land brown on +V DC and blue on common for all five sensors, each black wire on its own resistor-and-LED channel, and verify polarity before power-up: an inductive sensor with swapped supply leads can hold its indicator ON and drop it on activation, inverted behavior a bench check catches.
- Power the sensor supply alone and present metal to each sensing face one at a time; the sensor's indicator and the controller-side terminal must change together while the other four channels hold state.
- Measure both levels of every channel at the controller input: the made level, and the level the input actually settles to with the sensor clear.
- Trip the two X endpoints one at a time and confirm the shared limit input responds to either; repeat for the Y pair, then the single Z channel alone.
- Open one sensor wire and confirm the machine's reported state matches what its risk assessment requires before enabling motion; if a silent loss is unacceptable, use the normally-closed relay loop or controller-side supervision instead of the direct parallel wiring.
- Record the resistor values, the supply voltage and the measured levels per channel in the machine file, because the next technician will otherwise have to reverse-engineer this interface from photographs.
These inputs are operational limits, not safety functions: standard proximity switches and transistor optocouplers are not safety-rated components, and anything that must stop the machine under fault conditions belongs to the safety circuits the machine's risk assessment defines.
Questions asked
Can the two sensors on one axis share a single optocoupler?
Not on the sensor side. Each sourcing output feeds its own LED channel, and the combining happens after isolation: parallel the two phototransistor outputs into the one limit input so either sensor can pull it, which matches two endpoints on one axis. Series-stacking the transistors instead builds an AND, an input that changes only when both sensors are made — right for a shared guard condition, wrong for opposite ends of travel.
The board I am copying uses 330 ohm input resistors — do they work at 24 V?
No. That value is a 5 V calculation: (5 - 0.5 - 1.2) / 330 gives 10 mA, on target. Across the sensor supply the same 330 ohms drives 22.3 / 330, about 68 mA, through the LED and the sensor output — past their ratings. The same supply gives 2230 ohms, so fit 2.2 k ohm at 0.5 W for those inputs.
Why would an input flicker or never release with the sensors clear?
Look first at OFF-state leakage. The current a sensor passes with no target, stated in its datasheet, flows through the LED path; multiplied by your series resistance it must stay below the point where the LED conducts. If it does not, lower the resistor value and recompute the ON current, or add a shunt resistor across the LED so leakage bypasses it, then confirm the made state still saturates the output.
Do the sensors need optocouplers if the controller inputs are 24 V sinking?
No. A three-wire PNP output drives a matching 24 V sinking input directly: brown to the positive supply, blue to common, black to the input. The optocoupler earns its place when the controller input is 5 V, when the sensor supply and the controller share no common, or when the machine needs the fault isolation between sensor wiring and controller.