Code readingHow-to

Vision sensor OK/NG output to a PLC: wiring it so results arrive

Wire a vision sensor's OK/NG output to a PLC input: assign the judgment line, match NPN or PNP polarity, and prove the wiring with a forced output.

LumaSpec Vision11 min read Share on LinkedIn

On this page 9 sections
  1. 01Which wire carries the OK/NG result from a vision sensor?
  2. 02How do you assign the judgment to that output line?
  3. 03NPN or PNP: which output does your sensor have, and which PLC input fits it?
  4. 04How much current can a vision sensor output line switch?
  5. 05What do you wire and configure, in what order?
  6. 06How do you prove the wiring works before production?
  7. 07Why does the PLC input still never change state?
  8. 08When should the result travel over a network instead of a wire?
  9. 09Questions

The sensor runs its test in milliseconds and the PLC never hears about it — the classic first-week fault on a vision cell. The judgment usually exists inside the sensor; what is missing is the last stretch of wiring: an output line that was never given a job, or a result wire landed on the wrong PLC terminal with the wrong common. This guide is for controls technicians and integrators connecting a vision sensor or smart camera pass/fail contact to a PLC discrete input. You will assign the judgment to a physical output line, match NPN and PNP polarity to the input group, size the load in milliamps, and prove the whole path with a forced output before a production part ever runs.

Which wire carries the OK/NG result from a vision sensor?

The judgment travels on a dedicated discrete output line inside the sensor's I/O cable — typically one of three to sixteen switched lines in a 12- or 17-pin harness — and it stays at its rest level until the software assigns that line to the overall test judgment.

A vision sensor's round I/O connector multiplexes everything at once: trigger in, result out, strobe sync out, sometimes a second judgment line. Which physical pin carries the OUT line comes from the pinout table in that sensor's own manual, never from a diagram for a different model — 12-pin and 17-pin harnesses routinely land the same function on different pins.

The assignment, not the copper, is where most dead outputs begin. Vision sensors ship with output lines set to a no-function or undefined state, so a healthy line carries nothing until software gives it a job. Any sensor with a discrete harness behaves this way. The HK-TD032-12-WBN is a 1.6 MP mono vision sensor with a global shutter and an M12 lens mount:

Smart cameras & vision sensorsHikrobot HK-TD032-12-WBN 1.6 MP mono vision sensorHK-TD032-12-WBN
Interface
Fast Ethernet
Resolution
Up to 3 MP
Sensor format
1/2.9"
Shutter
Global
$1,699.00View part

The vision sensor finder filters the shop's smart cameras by shutter, mount and interface, so you can pick a model whose I/O connector matches the panel layout.

How do you assign the judgment to that output line?

In the sensor's I/O or output-signal settings, set the line you wired — usually output line 0 — to the overall judgment result, choose whether ON means OK or NG, and pick a pulse or a hold-until-next-trigger mode before you touch a wire.

Open the I/O page in the sensor software and find the signal-type setting for each OUT line. From the factory it usually reads no function or undefined. Set it to the overall judgment — the pass/fail of the whole inspection, not one tool's result — then set the polarity: ON at OK or ON at NG. Decide once and write it on the drawing; half of all polarity arguments start here.

Choose the output mode next. A 50-100 ms pulse is the safe default: a PLC scan typically runs 1-10 ms and the input filter adds a few more, so a 1-5 ms pulse can fall entirely between two scans. Hold-until-next-trigger keeps the level until the next part arrives, which removes the scan-timing question and makes bench debugging easier.

The trigger IN line on the same harness deserves the same one-line-at-a-time attention. The hardware trigger configuration guide covers the settings that stop a camera sitting in free run, the camera trigger common reference covers pulse levels and timing, and controlling vision routines from a PLC over GPIO or serial applies the same assignment logic from the other direction.

NPN or PNP: which output does your sensor have, and which PLC input fits it?

An NPN output switches the 0 V side and needs a PLC input whose group common sits at +24 V DC; a PNP output switches the +24 V side and needs a group common at 0 V DC — crossed polarities give you an input that never moves.

Sensor output What it switches PLC input group common Input reads ON when
NPN (sinking) the 0 V side +24 V DC the output pulls the terminal down to 0 V
PNP (sourcing) the +24 V side 0 V DC the output applies +24 V to the terminal
Relay / dry contact either polarity match the contact's common the contact closes

Three-wire sensor cables follow a stable color convention in most European-built gear: brown to the supply, blue to 0 V, black as the switched output. Treat the colors as a hint and the manual's pinout as the rule, because other conventions exist. The fastest identity check is the manual; the second is a meter across OUT and 0 V with the line forced on — a PNP output shows the full supply there, an NPN output pulls to 0 V.

A crossed pair is the fault that masquerades as a dead sensor: the software reports OK, and the PLC input LED never flickers because input and output are each waiting for the other to speak.

How much current can a vision sensor output line switch?

Size every load to tens of milliamps: a standard discrete PLC input draws 5-15 mA and sits well inside the per-line limit, while relay coils, lamps and sounders need an interposing relay sized to the line rating in the sensor's I/O table.

Worked example, with one assumed value: take the line rating as 50 mA, a typical discrete vision-sensor figure — your model's I/O table states its own limit. The judgment line is to also pick up a panel-mounted signal relay with a 24 V DC, 0.6 W coil:

I = P / V = 0.6 W / 24 V = 0.025 A = 25 mA margin = 50 mA / 25 mA = 2

A 25 mA coil uses half the line budget, leaving room for the PLC input in parallel if both share one line. A 1.2 W coil would draw 1.2 / 24 = 50 mA — the entire budget — so stay at 0.6 W or less, or put the load behind the relay contact instead. A standard discrete input alone, at 5-15 mA, never comes close to the limit.

Strobe lights are the load people wrongly hang on an OUT line. The judgment line switches the light controller's strobe input — itself a low-current electronics input — while the controller drives the lamps. Most single-camera strobed cells fit a 4-channel, 200 W digital controller with RS-232 and a strobe mode:

Light controllersDigital control box, 4 ch, 200 W, RS232 (LS-CTL-0070)LS-CTL-0070
Output
Constant voltage 24 V
Channels
4 channels
Control
Digital
Feature
Strobe
$549.00View partBuild a system with it

Adapting between controller and light, the light controller cable adapter guide lists the connectors and the current each one carries; the shop's light controllers group by channel count and output type.

What do you wire and configure, in what order?

Eight steps take the cell from bench to a proven PLC bit; the polarity table above and your sensor's pinout page are the only two references you need.

One decision saves an hour: use a prefabricated open-ended cable rather than hand-pinning a round connector. Start from the maker's cable with open leads:

For SC6000-series smart cameras, the 17-pin power and I/O harness breaks out to open leads over a 7 m static run:

CablesHikrobot MV-SCA-P-M12A17pF-open-ST-7m 17-pin power cable, M12 A-coded 17-pin female to open leads, 7 m, Static, For: SC6000MV-SCA-P-M12A17pF-open-ST-7m
Type
Smart Camera Power and I/O Cables
$59.00View part

The cable finder filters the rest of the cables by connector and length. Then work in this order:

  1. Power the cell down, lock and tag it out, and unplug the sensor harness before touching a terminal.
  2. Fit the open-ended I/O cable and lay the leads out at the PLC marshalling terminals.
  3. Mark every lead from the manual's pinout page: trigger IN, judgment OUT, the supply lead, 0 V, and any spare common.
  4. In the sensor software, assign the chosen OUT line to the overall judgment, set ON at OK or ON at NG, and give it a 50-100 ms pulse or hold-until-next-trigger mode.
  5. Land the OUT lead on the PLC input terminal, then tie that input group's common per the polarity table, on the same supply the sensor runs from, so both sides share one reference.
  6. Power up and confirm the PLC input LED sits at its expected rest level.
  7. Force the OUT line on from the sensor's I/O menu and watch the input LED and the PLC input monitor bit follow it.
  8. Run ten known-good and ten known-bad parts, confirm the bit tracks each one, release the force, and set the inspection live.

How do you prove the wiring works before production?

Force the judgment line on from the sensor's I/O menu, then measure DC volts between the PLC input terminal and its group common — if the meter and the PLC input LED both follow the force, the wire is good and anything still wrong is configuration.

Test outward from the sensor. Watch the sensor's own I/O monitor while it runs a part: if the OUT line never toggles there, stop, because nothing downstream can work until the output-line assignment earlier in this guide is in place. If the sensor toggles but the PLC does not, move to the meter.

With the line forced, a PNP path shows the full bus voltage at the input terminal against its common and about 0 V released; an NPN path shows the reverse. The input LED should track the meter. A meter that moves with an LED that does not means the input group's common is landed wrong — re-read the polarity table.

Last, prove the pulse. A pulsed output can be shorter than what the PLC input monitor samples, so switch to hold-until-next-trigger while debugging; the level latches and you can walk the ladder calmly. Return to pulse mode at 50-100 ms once the path is proven.

Why does the PLC input still never change state?

Work down this list in order: a floating input common, an output line left at its factory no-function default, a per-tool result assigned instead of the overall judgment, and a pulse shorter than one PLC scan explain nearly every dead input — in that order.

  • Floating common. Force the output and measure DC volts from the OUT lead to the input group common. Nothing there means the common was never landed; tie it per the polarity table, on the sensor's own supply.
  • Line never assigned. The sensor's I/O monitor shows the OUT line flat no matter how many parts run. Apply the assignment from the second section: many sensors leave output lines at a no-function default.
  • Wrong result type. OK arrives and NG never does, because NG exists only as a single tool's fail rather than the overall judgment. Assign the overall pass/fail so any failed tool drives the line.
  • Pulse shorter than the scan. Scans run 1-10 ms typically and input filters add a few more; a 1-5 ms pulse can land between two scans. Set 50-100 ms, or hold mode.
  • Pinout from a different model. A diagram for a 12-pin harness says nothing about a 17-pin one; re-check the page for your exact model and cable.

When the input moves on the bench but not on the machine, suspect the cable itself: drag-chain flex eventually opens a conductor, and a meter at the PLC end while forcing the output finds the break in seconds. On a moving axis, start from a drag-chain-rated cable; the LS-CBL-0300 above is specified for drag-chain use.

When should the result travel over a network instead of a wire?

Keep the wire for one judgment per part and move to Ethernet or serial when the PLC needs measured values, part IDs, several results per trigger or a result history — a discrete line carries exactly one bit per trigger.

A discrete pair is the right tool when the PLC needs exactly one thing: good or bad, now. The moment the recipe wants a measured dimension, a part serial, more than one judgment per trigger or a log of results, put the same data on a network link and keep the discrete line as the fast fail signal.

Three patterns cover most cells. EtherNet/IP in implicit or explicit form suits PLCs that speak it — the vision sensor results over EtherNet/IP guide compares the two connection types. A fixed-position RS232 telegram fits when a legacy serial port is what the PLC actually has. For the wider architecture — scan cycle, handshakes, recipes — the machine vision PLC integration guide lays out the line-level picture.

For a new cell, continue on the code reading and integration topic page after this one, and let the configurator size the harness and controller together:

Build the whole station

The configurator matches a camera, lens, light, light controller and cables to each other, step by step, and lists only parts that fit what you already picked.

Start with the cables and extras

If the harness is already built and the bit still will not move, send us your pinout and PLC input settings through the contact page and we will work through it with you.

Questions

What wire size suits a discrete result line?

24 AWG (0.2 mm²) copper — what most harnesses already use — lists about 0.085 Ω/m in standard copper tables. A 10 m run is 20 m of loop, roughly 1.7 Ω, so at a 15 mA input current the drop is 1.7 × 0.015 A = 0.026 V, nothing against a 24 V bus. Use shielded cable for the bundle and ground the shield at the PLC end only.

Is an interposing relay needed between a vision sensor and a PLC?

Not for a plain 24 V DC digital input, which draws 5-15 mA. Add one for contactor coils, lamps, sounders or runs routed beside power ducts. Size the coil by I = P / V: a 0.6 W, 24 V coil draws 25 mA, half of a typical 50 mA line budget, while a 1.2 W coil uses the whole budget.

How can one vision sensor drive both an OK lamp and an NG lamp?

Assign two output lines: one to the overall OK judgment, one to the overall NG judgment. Drive each lamp through a relay coil sized as above, or directly if the lamp input is a low-current electronics input at the supply voltage. Keep both lines in the same mode — both pulse or both hold — so exactly one line is true per part.

Why does the OK result reach the PLC but NG never does?

The NG state usually exists only as a single tool's fail result, not as the overall judgment, so the NG line never receives a job. Force the NG state from the sensor's I/O menu: if the PLC bit moves, wiring and assignment are fine and the taught inspection is passing bad parts — re-teach the model or add a tool.

Can PLC input polarity be changed instead of rewiring the sensor?

Often, yes. Many input cards let you jumper each group's common to +24 V or to 0 V, so an NPN sensor and a PNP sensor can live on different groups of the same card. Check which group the input belongs to first: moving a jumper changes the polarity of every input in that group.