System designHow-to

Trigger a camera from a PLC output to log rare failures

Wire a PLC discrete output to a camera's opto-isolated trigger input, set the trigger mode and pulse width, and log a timestamped image of every rare failure.

LumaSpec Vision10 min read Share on LinkedIn

On this page 11 sections
  1. 01The decision: camera I/O, not a shutter-button relay
  2. 02What you need
  3. 03Wire the trigger loop
  4. 04Set the trigger mode and the pulse
  5. 05Choose the camera for the scene
  6. 06Freeze the moment with light
  7. 07Worked example: a day of evidence at 60 parts/min and a 0.1% failure rate
  8. 08Get the images off and review them
  9. 09Mistakes that empty the evidence locker
  10. 10Before you order
  11. 11Questions

Every so often the process makes a bad part when nobody is standing there, and the shift note never mentions it. The machine's PLC already knows the moment it happens — it drives an output for exactly that condition. Fire an industrial camera's opto-isolated input from that output and every event leaves a timestamped image behind, ready to review when the shift ends. This guide walks the wiring, the trigger settings, the camera choice and the storage math, so a line chasing a 0.1% rejection rate collects its own evidence without anyone babysitting it.

The decision: camera I/O, not a shutter-button relay

Do not de-solder a shutter button and wire a relay across it. A consumer camera powers itself off between shots, wants a half-press before the full press, hides its images on a memory card and stamps nothing with a time. An industrial area scan camera is built for this job: its opto-isolated input accepts the 24 V logic your panel already uses, the camera stays powered and armed for weeks, and each trigger returns one complete frame to a PC with a time stamp, captured while the failure is still on the table.

This is the same hardware trigger a photoeye inspection station uses; the only change is that the PLC's failure bit fires it instead of a part-present sensor. The sections below wire the loop, set the trigger, pick the camera and size the evidence locker.

What you need

  • A camera with at least one opto-isolated input. Filter the camera finder by interface and mount; the input lives on the camera's power and I/O connector.
  • A power and I/O cable with bare leads at the PLC end. One multi-core lead usually carries the supply and the trigger together.
  • A spare discrete output. A 24 V transistor output is ideal; a dry relay contact also closes the loop, with a bounce caveat covered in the FAQ.
  • A data path to a PC. GigE runs up to 100 m to a switch; USB3 keeps its runs to a few meters.
  • Power for the camera. PoE from the switch, or a DIN-rail supply matched to the voltage the camera's I/O pinout lists — the power supplies page filters enclosed supplies.
  • Acquisition software that saves on trigger, plus disk space sized by the worked example below.

Wire the trigger loop

The input is not a logic pin. It is an LED behind an isolator, and the PLC output closes a small current loop through it. Three wiring decisions decide whether the first pulse works:

  1. Direction. Work out which side sources and which side sinks from the pinout before landing wires — the opto-isolated GPIO direction walkthrough shows both topologies.
  2. Loop current. An industrial 24 V output drives the loop directly with the series resistance the pinout calls for; a 5 V controller output drives the same loop with a smaller resistor, and the how to trigger a camera from a 5 V controller output walkthrough works that arithmetic.
  3. Common reference. Tie the PLC output's common to the camera input's reference, or the loop never conducts. The classic symptom is a camera that ignores every pulse; the trigger common reference guide diagnoses it step by step.

One cable handles the field wiring. The LS-CBL-0300 carries power and trigger together in a single 7 m, 8-core M8 lead with open ends for the terminals.

CablesCamera Power and I/O Cable, M8 8-pin connector, Male to Open end (8-core), 7 m, drag-chain use (LS-CBL-0300)LS-CBL-0300
Type
Power and I/O cables
Length
6-8 m
$79.00View partBuild a system with it

For the data run on a fixed mount, the LS-CBL-0199 is a 3 m GigE camera cable with screw locks and a high-flex, drag-chain-rated jacket.

Cables3 m GigE camera cable, high-flex (drag chain), screw locks (LS-CBL-0199)LS-CBL-0199$54.00View partBuild a system with it

Set the trigger mode and the pulse

Configure the capture once; the events then run themselves. Using the standard GenICam feature names in your acquisition app:

  1. Turn the trigger on and point the trigger source at the input line you wired. If a forced pulse produces nothing, the GenICam line settings checklist resolves the usual mismatches.
  2. Set the exposure mode. Timed gives a fixed exposure you choose; TriggerWidth lets the PLC pulse itself gate the exposure — the trigger pulse width guide explains when each wins.
  3. Fix exposure, gain and focus once for the worst-lit failure state and leave them there. A documentation camera must not hunt mid-event.
  4. Force the output from the PLC for a full second and confirm exactly one frame arrives.
  5. Save every frame under a timestamp filename and log the trigger count alongside the PLC's event list.

Pulse length, in numbers. Inputs of this kind register pulses a few microseconds wide, so a 1 ms pulse carries a 100-to-1,000-fold margin (1 ms = 1,000 µs). Hold it longer than one PLC scan — a small controller scans in roughly 1-10 ms — and 10 ms is a comfortable default. Frame rate sets the only hard ceiling: each capture needs its exposure plus readout before the next trigger is accepted, the arithmetic in maximum frame rate on a hardware trigger, so a chattering sensor yields tens of captures per second, never thousands.

Choose the camera for the scene

If the part keeps moving when the pulse fires, use a global shutter: a rolling sensor scans line by line and shears fast motion into a skewed image that hides the defect. If the machine stops or the scene barely moves, rolling shutter carries no penalty and resolution buys documentation detail.

The MV-CU020-90GC is a 2.5 MP color GigE camera with a global shutter, a 1/1.7" sensor and a C-mount.

Area scan camerasHikrobot MV-CU020-90GC 2.5 MP Area Scan Camera, GigE, GMAX4002, ColorMV-CU020-90GC
Sensor format
1/1.7"
Lens mount
C-mount
Interface
GigE
Resolution
Up to 3 MP
$309.00View partBuild a system with it

For a stopped scene, 12 megapixels lets a reviewer read a date code or count thread turns in the evidence image. The LS-CMR-0166 records 4000 × 3000 frames at 30 fps over USB3 with a 12 MP rolling-shutter sensor.

Area scan cameras12 MP USB3 area scan camera, IMX226, 1/1.7" rolling shutter, 30 fps, 4000 × 3000 resolution (LS-CMR-0166)LS-CMR-0166
Sensor format
1/1.7"
Interface
USB3
Resolution
12 MP
Shutter
Rolling
$560.00View partBuild a system with it

Freeze the moment with light

A failure in a dim corner of the cell needs light for exactly one exposure. Wire the camera's strobe output to the light's strobe input: the line's timing against exposure and timestamp is covered in the camera strobe output timing guide. An LED pulsed during a 1-5 ms exposure freezes residual motion and marks the event in the image itself. Size the light's duty cycle for a low event rate and it will run for years; the LED strobe duty cycle guide shows the matching math.

Worked example: a day of evidence at 60 parts/min and a 0.1% failure rate

Inputs, and where each comes from:

  • 60 parts/min — an illustrative mid-rate for a small monitored cell; scale the result linearly to your own rate.
  • 0.1% failure rate — the rejection target being watched.
  • 8 h shift — the end-of-shift review cadence.
  • 4000 × 3000 pixels at 8-bit mono — the 12 MP camera's frame from the section above, saved lossless; color triples the bytes.

The rule, in words: events per shift equals parts per shift times the failure fraction, and log size equals events times bytes per frame.

events = parts per shift × failure rate log size = events × bytes per frame

Arithmetic:

  • Parts per shift: 60 parts/min × 60 min/h × 8 h = 28,800 parts.
  • Events: 28,800 × 0.001 = 28.8, so plan for 29 images.
  • Log size: 29 images × 12 MB = 348 MB ≈ 350 MB per shift.

Decision, with the threshold. At the target rate a shift's evidence is about 350 MB, so a 16 GB buffer holds 16,000 MB ÷ 350 MB ≈ 45 shifts — roughly nine working weeks. The picture flips if the process degrades: at 1%, 288 images × 12 MB ≈ 3.5 GB per shift, and the same buffer covers about 4.5 shifts. Keep lossless saves while a shift's log stays under about 2 GB; past that, switch to JPEG (about a tenth of the bytes) or cap retention at two weeks and alert when the disk passes 80% full.

Get the images off and review them

The camera stays armed; a small acquisition loop on the PC waits for each trigger, grabs the frame and writes it out — the Python hardware-trigger grab loop is about thirty lines and runs unattended. Put the wall-clock time and a sequence number in each filename, keep the PC's clock synced to the plant's time source, and each image pairs with the PLC's own event rows by timestamp. At review time, sort by hour: failures cluster, and a cluster at the same time every day points at a shift change, a warm motor or a raw-material batch faster than any statistics package.

Mistakes that empty the evidence locker

  • Wiring into the wrong pin. Strobe outputs, power pins and trigger inputs share one connector; a swapped wire captures nothing. Settle direction from the pinout before energizing.
  • Relay chatter counted as three events. A bouncing contact fires multiple captures for one event; if the count matters, drive the loop from a transistor output.
  • Rolling shutter on a moving part. The image shears and the defect hides in the skew — that is the global-shutter case above.
  • Exposure too long for residual motion. Even a stopped line vibrates; shorten the exposure and let the strobe carry the brightness.
  • Autofocus or auto-exposure left on. The one frame that matters gets hunted mid-capture; lock everything once.
  • A disk that fills silently. 350 MB per shift sounds endless until the failure rate runs to 1%; set the retention cap and the 80% alert from the worked example.

Before you order

  • Confirm the output card: voltage, transistor or contact, and one spare channel.
  • Match the cable to the camera's connector family and core count before choosing lengths; the power and I/O cables page filters by both.
  • Decide raw or JPEG now — it sets storage and the retention cap.
  • Trial the chain end to end: force one event, confirm one timestamped image on the PC, then walk away and let it collect.

If the wiring or the trigger settings stall, the camera configurator sizes the whole chain, and support is free with every order. More trigger and sync patterns live on the systems topic page.

Questions

Can a relay contact trigger the camera instead of a transistor output?

Yes. The input is a current loop, so any dry contact that closes it works, with the loop's supply and series resistance already in place. The catch is bounce: a contact can chatter for a few milliseconds and fire two or three captures for one event. If each event must map to exactly one image, drive the loop from a 24 V transistor output or hold the pulse long enough that re-closures land inside one exposure window.

What voltage does a camera trigger input need?

It is not a voltage input but a current loop through an opto-isolator, so what matters is the loop current the camera's I/O pinout specifies, set with a series resistor from the loop supply. Industrial 24 V outputs drive that loop directly; a 5 V logic output needs a smaller resistor so the isolator LED still reaches its operating current. Both the wiring topology and the resistor value follow from the camera's I/O pinout.

How many events per second can the trigger log?

It is the camera's frame rate: each capture needs its exposure plus the sensor readout before the next trigger is accepted. The LS-CMR-0166 tops out at 30 fps, so 30 captures per second is the absolute ceiling. Failure logging never gets near that — one event a minute is 60 per hour — and a sensor firing tens of captures a second is a wiring fault to chase, not log entries.

Do I need a frame grabber to capture triggered images?

No. GigE and USB3 cameras deliver hardware-triggered frames to an ordinary network port or USB3 port, and the acquisition software timestamps and saves each one. Frame grabbers belong to Camera Link and CoaXPress cameras, where the interface needs dedicated PCIe hardware. For a one-camera failure log, a standard network interface and a saved trigger configuration are the whole capture chain.

How do I match each image to the PLC's own event record?

Put the wall-clock time and a pulse counter in each filename, then keep the PC's clock disciplined against the same time server the plant historian uses. Sort images and event rows by timestamp, and the counter catches the case where a clock step or a dropped second would pair an image with the wrong event. That pairing is what turns a folder of pictures into evidence a quality auditor will accept.