System designGuide

Adding AI surface defect inspection to existing cameras

Keep your existing cameras and add AI surface defect inspection on a vision controller: pixel budget, cycle-time math, and the pass/fail link to the PLC.

LumaSpec Vision13 min read Share on LinkedIn

On this page 12 sections
  1. 01Keep dimensional measurement rule-based
  2. 02The retrofit architecture: camera, node, PLC
  3. 03Pixels first: can your installed camera see the defect?
  4. 04Lighting is part of the model
  5. 05The compute tier: where the model actually runs
  6. 06Timing: the verdict must beat the takt
  7. 07What the PLC actually receives
  8. 08Training data and the acceptance test
  9. 09Before you order: six checks
  10. 10When the standard answer is wrong
  11. 11The decision
  12. 12Questions

You run machine vision on PLC-governed lines: cameras check dimensions, presence and position, and the PLC rejects on their result words. Now surface defects — scratches, porosity, chatter marks, staining — need coverage, and the instruction is to bring in AI without ripping out cameras that are calibrated and trusted. You do not have to replace them. The retrofit that works splits the job in two: dimensional checks stay rule-based on the installed cameras, and a separate AI stage classifies surface defects and returns one compact verdict per part to the PLC.

This guide gives you the numbers that decide it: how many pixels a defect needs, the cycle-time sum per verdict, which compute tier to order, and which words the PLC scan should consume. Every example shows its arithmetic, so you can redo it with your own part and takt.

Keep dimensional measurement rule-based

A model does not hold a tolerance. It returns a class and a map of where it saw a deviation, and every retrain can move that boundary — the opposite of what a ±0.05 mm feature needs. Dimensional work stays with calibrated tools: edge-based measurement behind known optics, a hand-eye calibration when no wizard exists for robot-mounted cameras, or the CMM for the tightest features. Leave those programs untouched.

AI earns its place on appearance. Scratches, pits, porosity and incomplete machining are easy for a person to see and exhausting to describe with rules, which is exactly the trade AI wins. Run both stages on the same frames where you can: the existing dimension tools fire first, then the frame goes to the AI node, and a part that fails either stage rejects. The pixel budget below tells you whether your installed cameras can carry both jobs or only one.

The retrofit architecture: camera, node, PLC

Nothing on the optical bench changes. Same cameras, lenses, mounts, fixtures and part presentation. Three additions sit behind them:

  1. An AI node — a vision controller — that joins the camera network and pulls frames from every station.
  2. A result link from that node to the PLC: fixed I/O words for the verdict, a richer channel for maps and scores.
  3. A versioned model store, one folder per part family with its golden images and training set, so any model can roll back.

The sequence per part: the PLC declares part-in-position and fires the trigger; the light strobes and the camera exposes; the frame lands on the node; inference returns pass/fail, defect class and defect coordinates; the PLC consumes the words in its scan and drives the reject. The PLC keeps every safety function and the reject actuator — a vision verdict is an input to that logic, never the safety layer itself. For the camera-to-node half of this handover, see connecting a GenICam camera to an industrial controller over Ethernet. If the vision side is new to you, the PLC programmer's guide to machine vision fills the background.

Pixels first: can your installed camera see the defect?

The floor: at least 3 pixels across the smallest defect you must catch — 3 for detection, 4 to 5 when a classifier must also grade severity. Everything else follows from that number.

mm_per_px = FOV / sensor_width_px defect_px = defect_size / mm_per_px (target: 3 or more) max_FOV = sensor_width_px × defect_size / 3

Worked example, from your quality records: the smallest defect is a 0.20 mm scratch, and the station frames a 120 mm × 80 mm bracket with 15% staging margin, so the field of view is 138 mm wide. A 2448-pixel sensor divides out to 138 / 2448 = 0.056 mm per pixel, and the scratch spans 0.20 / 0.056 = 3.5 pixels, 17% above the floor. The same sensor covers up to 2448 × 0.067 = 163 mm of part in one shot.

Wider parts step the sensor up, not the model: a 260 mm housing needs 260 / 0.067 = 3,898 pixels, so 12 MP, and a 320 mm casting needs 4,798 pixels, so 25 MP. Decision: parts to about 160 mm and 0.2 mm-class defects keep the installed cameras; 160 to 270 mm takes one 12 MP camera per station or a two-tile pass; beyond that, 25 MP or a tiled fixture. Enter your own part width and defect size in the resolution calculator.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

Most installed stations already meet the budget. The MV-SC5060XM-08M-WBN, for instance, is a 6 MP mono smart camera with a fixed 8 mm M12 lens on GigE, and it uses a rolling shutter — fine on a stopped part under strobe, wrong for continuous web.

Smart cameras & vision sensorsHikrobot MV-SC5060XM-08M-WBN SC5000X series Smart Camera, 6 MP, Mono, 8 mm focal length, M12-mountMV-SC5060XM-08M-WBN
Interface
GigE
Resolution
6-10 MP
Sensor format
1/2.4"
Shutter
Rolling
$1,629.00View part

Mono wins for defect contrast because every pixel keeps its full sensitivity; color pays only when the defect is itself a color change, such as staining, rust or mixed-material splash. Check the resolution and shutter filters in the smart cameras category before you assume a swap.

Lighting is part of the model

An AI model learns the appearance you train, light included. Two habits keep that distribution fixed. First, turn every auto mode off the camera: auto exposure and auto gain quietly rescale each image, and the model starts calling illumination drift a defect — the failure mode behind brightness that drifts over time.

Second, strobe instead of running the lights continuously: a 0.2 to 1 ms flash freezes vibration on a stopped part and holds brightness flat across a shift, and closed-loop lighting control corrects LED ageing before it reaches the images. Stop the lens two to three stops down from wide open so height steps on the part stay within depth of field.

On a four-light station the LS-CTL-0070 does this job directly: a 4-channel, 200 W digital control box with strobe on constant-voltage 24 V outputs, driven over RS232.

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

Geometry still comes first. Glossy machined faces put defect contrast into darkfield or dome setups, and no amount of retraining fixes the wrong geometry — start from lighting for metal surface defect inspection. For shiny or multi-height parts, HDR capture and fusion keeps bright and dark regions in one exposure set. Strobe-capable models in every channel count sit in the light controllers category.

The compute tier: where the model actually runs

Tier Where it runs What it serves Fits when
On-camera deep-learning tools Inside a smart camera One sensor Single station, compact model, verdict needed in-camera
Vision controller Cabinet beside the line Every camera on one switch The retrofit default: PLC protocols, light channels, spare PCIe
GPU training server Office or cell-side rack Model building, large fleets Training offline; inference when a CPU cannot hold the takt

A smart camera with built-in deep-learning tools handles one station, but it serves one sensor and its headroom bounds the model size. A vision controller is the retrofit default: one box takes every camera on a private switch, drives lights from built-in channels, speaks the plant protocols and leaves PCIe free for a GPU later.

For a first cell, the MV-VC3301H-128G66 carries the software side: an Intel Core i3, 8 GB of memory, a 128 GB SSD, five-plus LAN ports, four built-in light channels and the VM6200Pro vision license included.

Vision controllersHikrobot MV-VC3301H-128G66 I3-8100, 8GB+128G SSD, No PoE, PCIe expansion supported, Incl. VM6200Pro licenseMV-VC3301H-128G66
LAN ports
5+ LAN ports
USB 3 ports
3-4 USB 3 ports
Light outputs
4 built-in channels
Memory
8 GB
$2,419.00View partBuild a system with it

When inference grows or cameras multiply, the MV-VC5525-256G70-NN steps up to a 12th-generation Intel Core i5 with 32 GB of memory, PoE camera ports, eight built-in light channels and PCIe expansion for a GPU card.

Vision controllersHikrobot MV-VC5525-256G70-NN VC5000 Vision Controller, 12th-I5, 32GB+256G SSD, Supported PCIEMV-VC5525-256G70-NN
LAN ports
5+ LAN ports
USB 3 ports
3-4 USB 3 ports
PoE
PoE camera ports
Light outputs
8 built-in channels
$4,479.00 · quotedView and quoteBuild a system with it

Long image retention and growing model libraries take the MV-VC4712-256G10-2TH: an Intel Ultra 7 255H, 16 GB × 2 memory, a 256 GB SSD plus a 2 TB drive, six built-in light channels, PoE camera ports and PCIe expansion, shipped without a VM license key — pair it with the license or run your own inference stack.

Specification MV-VC3301H-128G66 MV-VC5525-256G70-NN MV-VC4712-256G10-2TH
CPU Intel® Core i3-8100 Intel® Core i5-12400 Intel® Core Ultra 7 processor 255H
Memory 8 GB 32 GB 2 × DDR5 6400 MHz non-ECC SO-DIMM memory slots; Up to 48 GB per slot, Up to 96 GB with two slots
Storage 128G SSD 256 GB SSD 1 × 7-pin SATA3.0, 1 × M.2 SATA 2280, 1 × M.2 NVMe 2280; 1 × 2.5"/3.5" drive bay
GPU Intel® HD Graphics 630 Intel® UHD Graphics 730 Intel® Arc 140T GPU
Operating system Windows 10 64-bit, Not activated Unactivated Windows 10 Windows 11 64-bit (not activated)
Encryption method VM6200Pro license key – MV-VC47**-**6-**: VM6200pro encryption supported; MV-VC47**-**0-**: encryption not supported
Video output HDMI interface × 1, VGA interface × 1; Supports independent display output at the same time; Max. resolution 1920 × 1080 @ 60 Hz HDMI interface × 1, VGA interface × 1; Supports independent display output at the same time; Max. resolution 1920 × 1080 @ 60 Hz Independent dual display supported; 1× HDMI port, Up to 1920 × 1080 @ 60 Hz; 1× VGA port, Up to 1920 × 1080 @ 60 Hz
Digital I/O 8 digital isolated inputs supported; 16 opto-isolated outputs supported (NPN/PNP switchable) Opto-isolated input × 8; Opto-isolated output × 12 ( supports NPN/PNP switching), digital-isolated low-side driver output × 8; Non-isolated bi-directional differential I/O × 4 18 digital isolated inputs supported; 18 isolated digital outputs
Network interface 6× Gigabit Ethernet ports GigE interface × 7, including interface for PoE × 4 4× Gigabit Ethernet ports; PoE power supported, 15 W per port, 25 W total across 4 ports
USB Interface USB 2.0 × 4; USB 3.0 × 4; Built-in USB 2.0 × 1 USB 2.0 × 4, USB 3.0 × 4, built-in USB 2.0 × 1 4× USB 2.0 ports; 2× USB 3.0 ports; 1 × internal USB2.0 port
Serial Port 2× full-function RS-232, RS-485/RS-422 switchable RS-232 × 2 by default, supports switching to RS-485 and RS-422 2 × configurable RS-232/RS-422/RS-485
Light interface 4-channel 24 V constant-voltage light drive, Max. power per channel: 72 W, Max. power (4 channels): 150 W 24 VDC constant voltage × 8; (Max. power consumption of single channel is 72 W, total max. power consumption 190 W) SMR-03V-BC female; 6-channel 24 V constant-voltage light drive, Max. power per channel: 72 W, Max. total power: 110 W
Price $2,419.00 $4,479.00 · quoted $6,049.00 · quoted

All 3 share: Certification CE, KC. Values as printed in each product's data sheet; open a part for its drawing and full specifications.

Decision: one or two stations with a loose takt run on the smaller controller; a full cell of cameras takes the PoE model; retention-heavy fleets take the storage-heavy node.

Timing: the verdict must beat the takt

t_sum = t_trigger + t_exposure + t_transfer + t_inference + t_handshake t_transfer = frame_MB / 110 (GigE practical throughput, MB/s)

A 6 MP mono frame runs about 6 MB. GigE moves roughly 110 MB/s in practice, so the transfer costs 6 / 110 = 55 ms. Trigger handover and the PLC handshake cost about 10 ms each, and a 1 ms strobe flash covers exposure on a stopped part. That leaves inference as the term you must measure. Budget 0.5 s per frame for a compact anomaly model on a CPU-class controller at around 1000 × 1000 pixel input — a planning figure, so time it on your first 50 production frames and use your measured number.

The sum for one station on a 6 s takt: 10 + 1 + 55 + 500 + 10 = 576 ms, roughly a tenth of the cycle. Decision: a CPU-class controller holds stations whose verdict budget is 1 s or more; below about 0.5 s, cut the input pixels, tile only the defect-prone regions, or use the PCIe slot for a GPU. If acquisition and processing drift apart anyway, acquisition faster than processing: fixing the frame-rate gap names the counters to watch.

What the PLC actually receives

Keep the PLC-facing payload small and fixed, written down in your own interface sheet:

  • Sequence counter, one increment per part.
  • Overall pass/fail bit.
  • Worst defect class byte, plus a defect count.
  • Defect coordinates as two 16-bit integers per defect.
  • Confidence byte.
  • Node-health heartbeat bit.
  • Model-version word.

EtherNet/IP implicit I/O assemblies carry exactly this shape — the same mapping pattern a barcode reader uses to feed a PLC. Modbus TCP is the lowest common denominator, and the vision controller Modbus integration guide shows the register map. When MES or SCADA also consumes results, OPC UA is the richer channel: the OPC UA machine vision companion specification standardizes result, defect and image objects, so MES-side clients can subscribe without a bespoke interface per station. MQTT fits when results buffer upward to a historian while the PLC stays on I/O words. Many lines run two channels at once: tight words to the scan, rich data upward.

Guard the handshake. The PLC gets a heartbeat from the node, applies a watchdog timeout, and goes to a defined state on timeout — reject and alarm is the usual choice. Check the device side against what to look at when a GenICam camera meets a PLC controller.

Training data and the acceptance test

Anomaly detection flips the data economics: the model learns what a good part looks like and rejects deviation, so most of the dataset is good frames. A starting budget that holds up in practice: 100 to 200 good frames per part family under production lighting and presentation, then 20 to 50 defective parts per defect class you must catch — production rejects plus parts you damaged on purpose. Set up folder structure and defect masks on day one; the dataset errors that sink first attempts are mundane, and the custom dataset training guide walks through them. Export the trained model to ONNX so runtime and version travel with the station — the ONNX pipeline from maps to pass/fail shows the path.

Acceptance is a measured batch, not an impression. Run 200 known-good parts and 20 parts with seeded defects through the real trigger, and require zero escapes with a false-call rate at or under 1% — at most 2 false rejects among the 200. Tune the threshold and repeat until both hold, then record the batch. Re-run it after every lighting, lens or model change; how training loss behaves while early stopping with high training loss selects the epoch tells you whether a new model generalized or memorized.

For the commissioning sequence itself, a step-by-step AI defect inspection commissioning walkthrough covers the path from image audit to sign-off. Put acceptance criteria per defect class in writing before training starts — steel plate inspection shows how formal a written surface-defect acceptance specification gets.

Before you order: six checks

  • Pixel budget per station. Smallest defect from quality records, field of view from the part, the 3-pixel floor from above — this decides keep-or-replace per camera.
  • Cycle-time sum per station. Takt minus trigger, exposure, transfer, measured inference and handshake must stay positive with margin.
  • Ports and protocol. Camera count plus the PLC link against controller LAN ports; camera traffic on its own switch; the protocol your scan trusts present on the node.
  • Lighting stability. Strobe driver with fixed energy, camera auto modes off, closed loop where drift has bitten before.
  • Model governance. One folder per part family, versioned models, a tested rollback, a named owner for retraining.
  • Failure behavior. Heartbeat, watchdog and the defined PLC state on node loss, decided before commissioning rather than during it.

When the standard answer is wrong

  • The tight feature is dimensional — a missing hole, a wrong step, a chamfer out of spec. A rule tool finds geometry in minutes; do not train a model for it.
  • Takt under about 0.5 s per full frame. Audit sampling — every part through the rule tools, one frame in N through AI for drift watching — or a GPU node.
  • The part family changes weekly. Rule-based tools re-teach faster than models retrain; AI pays on stable families with many appearance defects. The on-camera version of that choice is the AI vs rule-based smart camera guide.
  • The line needs one number, such as a surface finish value or a depth. That is metrology hardware, not a classifier.

The decision

  • Parts to about 160 mm with 0.2 mm-class defects: keep the installed 5-6 MP cameras, add a controller node, budget 100-200 good frames per family.
  • Parts 160 to 270 mm: one 12 MP camera per station, or a two-tile pass on the existing cameras — four tiles at 576 ms each still fit a 6 s takt.
  • Verdict budget 1 s or more: CPU-class controller, no GPU. 0.3 to 1 s: trim input pixels or add a GPU through PCIe. Under 0.3 s: audit sampling.
  • PLC link: implicit I/O words with heartbeat and watchdog; OPC UA or MQTT upward when MES wants the maps.
  • Dimensional checks never move: they stay on the calibrated edge tools and the CMM.

Pick the node in the vision controllers category, re-run your pixel budget with the resolution calculator above, then check camera pixels in the smart cameras finder and the strobe in the light controller finder. To assemble the whole cell part by part, open the system configurator.

Questions

Can the AI run on the smart cameras already mounted on the line?

Sometimes. If your camera family ships on-device classifier or anomaly tools for that model, a small surface-defect check can run in the camera and its verdict rides the existing protocol. Two limits decide it: the sensor needs enough pixels for the defect budget, and a 100 Mbit/s model cannot also stream every frame to a review node. When either limit bites, put inference on a vision controller and leave the cameras as capture devices.

How many images does training actually need?

Budget 100-200 good frames per part family under production lighting, plus 20-50 defective parts per defect class you must catch. Anomaly detection leans on good images because it learns the golden appearance and flags deviation, so a short defect library works if it contains your hardest edge cases. Keep adding parts after launch and stop when escapes and false calls stop falling.

Which protocol should carry results to the PLC?

EtherNet/IP or Modbus for the deterministic words the scan consumes: sequence number, pass/fail, worst defect class, defect coordinates, heartbeat. Send those cyclically, sized as a fixed assembly, so the scan never waits on a variable-length message. Use OPC UA when MES or SCADA also wants defect maps and confidence scores, and MQTT when results buffer to a historian.

Does the AI model replace the CMM or the dimensional vision check?

No. A model returns a class and a defect map, not a calibrated dimension, and retraining can move its decision boundary between runs. Tolerances stay on calibrated edge tools or the CMM. One camera can serve both stages in the same cycle: the rule tools measure first, then the frame goes to the AI node for surface appearance only.

What happens when the cycle is faster than the AI verdict?

Three levers, in order: shrink the input pixels, tile only the defect-prone regions, or move to a GPU through the controller's PCIe slot. Inference time scales roughly with pixel count, so halving each image dimension cuts that step to about a quarter. If none fits, inspect every part with the existing rule tools and send one frame in N to the AI node as a drift audit.