Vision OK/NG Sorting: How a Camera Signals the PLC to Reject Bad Parts

Vision OK/NG sorting uses a machine vision camera to inspect every part on the conveyor and send the pass/fail result to the PLC, which fires a pusher, air jet or diverter gate to remove rejected parts. The sequence is sensor triggers → camera captures and inspects → camera outputs OK/NG → PLC tracks the part to the reject station → reject actuator fires. There are two main ways to send the result: digital I/O (simple and fast, ideal for OK/NG) and industrial networks such as Modbus, PROFINET, EtherNet/IP or TCP (which can also carry values and text). Typical jobs are assembly verification: parts present, correct orientation, counting and model sorting. HIKROBOT case examples include inspecting 300 parts per minute and deep learning weld checks on gears with 100% correct classification in the test set.
What is vision OK/NG sorting?
Vision OK/NG sorting means using an industrial camera to inspect parts on a production line and decide whether each one passes (OK) or fails (NG). The result goes to the PLC that controls the machine, so failed parts are removed without stopping the line. The camera is the “eyes” and the PLC is the “hands”, and the two must stay in step: if the result arrives late or the position is tracked wrongly, the reject station removes the wrong part.
This guide focuses on connecting the camera to the PLC and on assembly checks before sorting. For an overview of camera types, read machine vision camera types.
How does a sorting camera work, from trigger to reject?

- Trigger. A sensor detects that the part has reached the camera and signals it to capture. HIKROBOT’s bottle cap, bottle label and chocolate pack cases list external trigger support as a requirement.
- Capture. The camera takes the image with lighting chosen for the job, so the feature stays clear even on a fast line.
- Inspect and decide. The software checks the set conditions, such as part present, correct position, complete count, size within tolerance or code readable, and returns OK or NG.
- Send the result to the PLC over digital I/O or an industrial network. A smart camera processes on board and can output OK/NG directly.
- PLC tracking. The PLC holds each part’s result until that part travels from the camera to the reject station, counting time or pulses from a conveyor encoder.
- Reject. A pusher, air jet or diverter gate acts only on NG parts, while OK parts continue to the next step.
How can a camera send signals to a PLC?

HIKROBOT documents state that its smart cameras have multiple I/O ports for input and output signals and support TCP, UDP, Serial, I/O, Modbus, PROFINET, EtherNet/IP and FTP. The capsule inspection case also notes that the discrete OK/NG output can go directly to a PLC, indicator lights or a buzzer.
| Method | What it carries | Best for |
|---|---|---|
| Digital I/O | On/off signals: trigger in; OK, NG and ready out | Standard OK/NG sorting where speed and simple wiring matter |
| Modbus, PROFINET, EtherNet/IP | OK/NG plus numbers such as measurements, counts, model number or defect code, written to PLC registers | Lines already on a networked PLC that need more than pass/fail |
| TCP / UDP / Serial | Text, such as characters read or commands from the PLC | Code reading or OCR jobs that compare strings |
| FTP | Images | Saving NG images for later review |
Communication works both ways. In HIKROBOT’s dot-print OCR case, the PLC sends the expected text to the camera, which compares it with the characters it actually reads. The automotive gear knob case specifies I/O communication with the PLC over TCP.
For the full range of automotive inspection jobs, including measurement, defects and DPM codes, see automotive parts vision inspection.
How do you make sure the right part is rejected?
The most common sorting problem is not a wrong inspection result but rejecting the wrong part because the timing is off. Design these points in from the start:
- Measure the distance from camera to reject station and have the PLC queue each part’s result, since several parts may be on the belt in between.
- Use an encoder if line speed varies. Tracking by distance is more accurate than a fixed time delay.
- Keep enough spacing between parts. In HIKROBOT’s bin colour case, bins on the moving conveyor are about 150 mm apart.
- Define what happens with no result. If the camera does not answer in time or cannot capture, reject that part by default.
- Confirm the reject. Fit a sensor on the reject chute to verify that NG parts actually left the line.
What can an assembly verification camera check before sorting?

| Check | Example from HIKROBOT cases |
|---|---|
| Part presence and orientation | Metal part in an automotive speedometer: present and facing the right way |
| Position and alignment | Automotive gear knob: numbers in the correct position, not shifted, with the line aligned to them |
| Marks on assembly parts | Metal gear part: cut mark present, correctly positioned and sized, on both sides |
| Correct assembly | Chain assembly with many possible error types and high accuracy needs · inserts in phone back covers |
| Counting and model sorting | Counting components on a backlight and telling different models apart on one line |
| Colour | Material bin colour on a moving conveyor, with settings saved per model |
| Process completed | Deep learning check that gearbox gears were welded: 1,052 welded and 151 unwelded parts, all classified correctly |
If NG means scratches or surface defects, read defect detection cameras. If NG means out-of-tolerance size, read dimension measurement cameras.
Can a camera sort into more than OK and NG?
Yes. The camera sends a group or model number to the PLC so parts can be diverted to several lanes by model, size or packaging type. When groups look very different from one another, deep learning image classification is common (see AI vision inspection with deep learning). Examples from HIKROBOT documents:
- Sorting parcels by packaging on a conveyor: boxes 98.0% correct · woven bags 98.7% · plastic bags 97.5% · foam boxes 95.0% (first test round, model still being refined)
- Sorting parcels into standard, irregular and pouch: 98.10%, 99.82% and 99.77% correct, followed by a 3D camera measuring volume to split by size
- Wheel hub model recognition: moving from template matching to deep learning kept GPU processing within 20 ms, and new models can be registered without full retraining
Setting criteria: false rejects (OK→NG) vs escapes (NG→OK)
Every sorting system makes two kinds of error: false rejects (good parts thrown away) and escapes (bad parts reaching the customer). Agree on targets for both before the project starts. In HIKROBOT’s automotive A/C radiator defect case, the customer required zero escapes and false rejects below 5%. In a 261-sample test there were 3 escapes (1.15%) from two defect groups and 1 false reject (0.38%). Figures like these show which defect groups need more samples before going live.
Real-world examples: figures from HIKROBOT cases

- Phone back covers: label, scratch and label position checks at 300 parts per minute with a smart camera
- Helmets: surface inspection and curve distance measurement all around, at a cycle of 60 parts per minute
- Gearbox gears: deep learning weld presence check on a smart camera, 1,203-part test set, 100% correct
- Milk cartons: warped shims detected before sealing so cartons are rejected before they deform, 252-sample test set, 100% correct
- Capsules: several cameras cover a wide field of view to check cutting on a running line, sending OK/NG straight to a PLC, indicator or buzzer
- Bottle counting and label checks: on a high-speed conveyor with external trigger support
Smart camera or PC-based system with deep learning?
| System | Best for sorting jobs |
|---|---|
| Vision sensor | Simple single-point presence or position checks, OK/NG over I/O |
| Smart camera | Assembly checks, counting, model sorting and OCR with on-board processing, multiple saved recipes, and results over I/O or network |
| Industrial camera + PC | Multi-camera setups or deep learning classification into many groups, with flexible choice of camera and lens |
How to start an OK/NG sorting project
- Define OK and NG clearly, with images of both and targets for false rejects and escapes.
- Line data: speed (parts per minute), part spacing and distance from inspection to reject station.
- PLC data: brand, model and protocol, to decide between I/O and network signalling.
- Reject unit: choose a pusher, air jet or diverter gate to suit the part’s weight and shape.
- Test at real speed: capture, inspect and trial the reject before permanent installation.
Summary
A vision OK/NG sorting camera inspects every part and sends the result to the PLC, which drives the reject unit. OK/NG travels simply and quickly over I/O, while measurements, counts, models or text go over Modbus, PROFINET, EtherNet/IP or TCP. Success depends on clear OK/NG definitions, accurate tracking so the right part is rejected, and agreed targets for false rejects and escapes. Better Code, the official HIKROBOT distributor in Thailand, tests with your real parts, installs, connects to your PLC and provides after-sales support.
Frequently asked questions about vision OK/NG sorting
How does a vision OK/NG sorting camera work?
A sensor triggers the camera when the part arrives. The camera inspects against set conditions, decides OK or NG and sends the result to the PLC. The PLC tracks the part to the reject station and fires a pusher, air jet or diverter gate to remove NG parts.
How does a camera send signals to a PLC?
Over digital I/O for OK/NG results and trigger signals, or over a network such as Modbus, PROFINET, EtherNet/IP, TCP, UDP or Serial for measurements, counts or text. HIKROBOT smart cameras support these protocols, plus FTP for sending images.
Should I use I/O or Modbus / PROFINET?
If you only need pass/fail, I/O is the simplest and fastest. If you also need values such as measurements, counts, model numbers or defect codes, or your line already runs a networked PLC, use Modbus, PROFINET or EtherNet/IP depending on what your PLC supports.
Will the right part be rejected if conveyor speed changes?
Have the PLC track distance from a conveyor encoder rather than using a fixed time delay, and queue each part’s result. The right part is then rejected even when speed changes. A confirmation sensor on the reject chute is also recommended.
What can an assembly verification camera check?
Whether parts are present, correctly oriented and positioned, the count, the model, the colour and whether a process step was completed. HIKROBOT cases include speedometer metal parts, gear knob numbers, chain assembly and welds on gearbox gears.
Can a camera sort into more than two lanes?
Yes. The camera sends a group or model number to the PLC to divert parts into several lanes. When groups look very different, deep learning classification is used; for example, a HIKROBOT case sorted parcels into standard, irregular and pouch with 98.10% to 99.82% accuracy.
Where can I buy HIKROBOT OK/NG sorting cameras in Thailand?
Contact Better Code (Better Code Co., Ltd.), the official HIKROBOT distributor in Thailand, via LINE @bettercode or +66 2-170-9611. The team tests with your real parts, selects the camera and lighting, defines the PLC signals, and handles installation and after-sales support.
Sources
- HIKROBOT – Smart Product Application Cases (Dec 2021): OK/NG output to PLC, indicators or buzzer; communication protocols; gear knob, speedometer metal part, gear cut mark, chain assembly, component counting and model differentiation, bin colour, phone back cover and OCR verified against a PLC string
- HIKROBOT – Deep Learning Application Case Set (2021): gearbox gear welds, milk carton shims, parcel classification, wheel hub recognition, and escape/false-reject criteria in the A/C radiator case
- HIKROBOT – Introduction to Machine Vision: a vision system comprises camera, lens, lighting, software and communication with PLCs, robots and I/O devices
Want a camera to reject bad parts automatically?
Send photos of OK and NG parts, your line speed and your PLC model. The Better Code team will test HIKROBOT cameras with your real parts and recommend the signalling and reject unit that suit your line.






