Deployment and IT

AI inspection and the PLC: which signals the station exchanges and who stops the line

14 min read
Contents

The best model achieves little if its decision does not reach the PLC in time to reject the defective part. Next to imaging and data, PLC integration is the third part of every visual inspection deployment — and it is usually handled by the automation engineer who knows the line program. The guide to vision systems covers it briefly. Here we go deeper: which signals the AIVQC Production station exchanges, how to configure and test them, what happens during a fault, and why the PLC, not the vision system, decides whether the line stops.

Division of roles: the station judges, the PLC controls

Before the automation engineer starts assigning addresses, it is worth writing down one rule: the station judges the product, the PLC controls the line. The station takes the image, makes an OK, NOK, REVIEW or ERROR decision, passes the result on and watches its own health. The PLC knows where the product is, fires the ejector, stops or diverts the line, and is responsible for everything related to the safety of people and the machine.

  • The AIVQC Production station — runs the inspection, sends a reject pulse for a NOK part, a heartbeat and a healthy signal, and records the result in a local history.
  • The PLC program — triggers the inspection, tracks the part to the reject point, reacts to a missing heartbeat or healthy signal and decides whether the line stops or products are diverted.
  • The plant — sets the procedure for parts with a REVIEW or ERROR result and for products that passed during a fault, and decides who may acknowledge a fault.

AIVQC is not a machine safety device and does not stop the line by itself. The line must always be possible to stop safely by hand, and the safety circuits stay where they were — outside the quality inspection system.

Five signals over Modbus TCP

The station exchanges a few simple signals with the PLC over Modbus TCP — with no programming of the vision system itself. Two go from the PLC to the station, three the other way.

Diagram of the signals between the AIVQC Production station and the PLC over Modbus TCP: from the PLC to the station, trigger, line running and optional registers with speed, encoder position and product number; from the station to the PLC, a reject pulse for a NOK part, a heartbeat that toggles every second and a healthy signal that drops during a fault. The PLC program decides whether the line stops.
A few signals in two directions are enough for the station and the PLC to know everything they need about each other.
  • Trigger (PLC → station) — a product has reached the camera. It usually comes from a presence sensor or a product sequence in the PLC program.
  • Line running (PLC → station) — the conveyor is moving. A line stop ends continuous inspection, so the station does not keep judging the same stationary product.
  • Reject (station → PLC) — a pulse for a part with a NOK result, sent before the agreed result-delivery deadline.
  • Heartbeat (station → PLC) — toggles every second while the application runs. When it stops toggling, the station is not responding.
  • Healthy (station → PLC) — the station can inspect. During a fault it goes false and stays false until the fault is acknowledged.

Optionally, the PLC can pass line speed, encoder position and a product number in registers, scaled to millimetres. They help when triggering relies on a conveyor encoder or when the PLC already numbers the parts.

Triggering: how the station knows when to look

Lines, stations, camera roles and triggering are described once, in the AIVQC Trainer settings, and reused by every deployment. The options are a presence sensor, a PLC product sequence, an encoder, or continuous inspection while the line is moving. The station works in one of two modes: it detects and counts every product in the frame, or gives a simple OK/NOK result with a gate in the middle of the frame.

The sensor is rarely right under the camera, so there is a delay between the signal and the image. It is set from a measurement on the running line, not from a calculation on paper — a loaded conveyor does not always move the way the documentation says. The camera runs continuously, and the station checks that it is analysing a fresh frame rather than an image from a moment ago. How to choose the camera and field of view for a moving product is covered in the article on vision system hardware.

Reject: the result deadline and tracking the part

Every cycle has a timing budget. The station qualification test requires at least 30 inspections per second and a frame-to-decision time of no more than 33.3 ms at the 95th percentile. A slower line gives more time, but the rule stays the same: if the result is not ready before the deadline agreed with the PLC, the station does not guess — it reports a fault.

Between the camera and the ejector the product still travels some distance. It is the PLC program that knows which part is reaching the ejector and fires it at the right moment — from distance and speed, or from the encoder position. So the automation engineer's job is not only to receive the reject pulse but also to assign it to the right part. When several products fit between the camera and the ejector at once, the PLC keeps a queue of parts and writes the results into it.

Also agree with the quality department what happens to parts with a REVIEW or ERROR result. Neither means OK: REVIEW is a part for a person to check, for example when the product was partly out of frame, and ERROR means the station could not run the inspection. Whether such parts are diverted, go to a separate bin or the line stops is the plant's decision, and it is worth writing down before start-up.

Heartbeat and healthy: two ways of detecting a problem

The most dangerous inspection system is one that silently lets products through when something has stopped working. That is why the station gives the PLC two independent signals. A dropped healthy signal says: "I know I cannot inspect right now." The heartbeat catches the case where the station cannot say anything at all — because the application has frozen or the computer has shut down.

The station latches a fault on, among other things, no fresh image in time, analysis taking too long, a product arriving while the station was still busy, a missed result deadline or lost communication with the PLC. The healthy signal drops and stays false — a later good cycle does not clear the fault on its own. An authorised person acknowledges it after fixing the cause, so nobody overlooks the products that passed in the meantime.

The PLC side needs a watchdog: if the heartbeat has not changed for longer than a set time, the PLC treats the station as faulty. The automation engineer chooses that time — clearly longer than the one-second signal period, so a momentary network delay does not stop the line, and short enough that not too many uninspected parts pass in the meantime.

Diagram of station fault handling: either the station detects a problem (no frame, timing exceeded, lost link) and latches a fault, so the healthy signal drops; or the application is down and the heartbeat stops toggling, which a PLC watchdog detects. In both cases the PLC stops or diverts the line, then the cause is fixed, parts from the fault window are checked in the inspection history, and an authorised person acknowledges the fault so the healthy signal returns.
A fault is visible on both sides of the link, and getting back to work takes a deliberate human decision.

Typical fault scenarios and how the line reacts

Walk through these scenarios with the automation engineer and the quality department before start-up — and for each one write down what the line does and who confirms the return to work.

  • Camera disconnected or showing no image — the station gets no fresh frame in time, latches a fault and drops healthy. The PLC stops or diverts the line according to its program.
  • Network link to the PLC broken — the station detects lost communication, and the PLC sees that the heartbeat has stopped toggling. The problem is visible on both sides.
  • Frozen application or computer shut down — nothing is left to drop the healthy signal, so the heartbeat and the PLC watchdog decide. The station supervisor restarts the application.
  • Products too close together or a double trigger — a product arrives while the station is still busy, and a fault is raised. Check the sensor, the spacing between products and the station timing budget.
  • Result too late — the computer does not fit the timing budget. That is the signal to go back to the qualification test results and the station computer class.
  • Problem right after an update — the station supervisor rolls back to the previous application version.
  • Line stop — the line running signal ends continuous inspection, and a stop always finishes the current product. An operator logging out or a session ending never interrupts an inspection in progress.

After every fault the question remains of what passed through the station in the meantime. The local inspection history records the result, recipe, operator, shift and batch, and for NOK results also the image with the defects marked. That is the starting point for deciding whether parts from that period need checking again.

Testing: simulation first, then the stopped line

Simulation mode lets you check the whole logic together with the automation engineer responsible for the PLC program, before the station affects the running line. Every address is checked in simulation first, then on the stopped line, and only then with the line running. A practical checklist:

  • Trigger — for every PLC signal the station answers with exactly one result or an explicit error.
  • Reject — the NOK pulse reaches the PLC, which assigns it to the right part and fires the ejector at the right place.
  • Heartbeat — the PLC sees it toggle every second, and after the application is closed the watchdog reports a fault within the planned time.
  • Healthy — after a fault is provoked, for example by unplugging the camera on the stopped line, the signal drops and the PLC reacts as programmed; after the fault is acknowledged, healthy returns.
  • Line running — stopping the conveyor ends continuous inspection.
  • Optional registers — speed, position and product number are scaled correctly.
  • Sensor-to-camera delay — measured on the running line and checked with known OK and NOK parts.

The last step is the station qualification test with the target camera, model, recipe and normal workload, including the signals to the PLC. Its criteria are described in the article on hardware requirements.

When the line already has an inspection station

If the line already has a sensor, an ejector and part-tracking logic in the PLC, most of it can often stay. What changes is the source of the decision and a few addresses in the PLC program. How to judge what to keep and what to replace is covered in Retrofit or a new station?.

Connecting to the PLC is a job for the automation engineer who knows the line program — not for a vision-system specialist. If you like, we can help: we will go through the signal list and the fault scenarios with your automation engineer before the station starts driving the reject.

See if we can detect your defect →