LightingTroubleshooting

Image brightness changes frame to frame: fix mains lighting flicker

Why image brightness changes frame to frame: the 100 Hz mains ripple test, the 10 ms exposure rule, and DC or strobed lighting fixes that steady brightness.

LumaSpec Vision10 min read Share on LinkedIn

On this page 11 sections
  1. 01Read the symptom before touching anything
  2. 02Why mains lighting ripples at twice the line frequency
  3. 03Predict the beat cycle from your frame rate
  4. 04Rule out the display and the auto modes first
  5. 05Fix 1: set the exposure to a whole number of ripple periods
  6. 06Fix 2: feed the light DC from a light controller
  7. 07Fix 3: strobe the light in step with the camera
  8. 08Ambient light dilutes the fix
  9. 09Which fix to choose
  10. 10Keep it fixed
  11. 11Questions

A mean gray level that steps up, then down, then back again — frame after frame, in a repeating cycle — is almost never a camera fault. Swapping cables, frame grabbers, PCs and drivers changes nothing, because the camera is measuring something real: the light on the part is not steady. Mains-powered LED and fluorescent lighting ripple at twice the line frequency, and an exposure shorter than one ripple period catches a different phase of that ripple in every frame. This guide shows you how to predict the beat cycle from your frame rate, how one exposure setting makes any frame rate flicker-free, and when the lasting fix is a DC-driven light or a synchronized strobe.

Read the symptom before touching anything

Two brightness faults look alike and have different fixes. A level that wanders over minutes points at an automatic exposure or gain mode chasing the scene; turn every auto mode off, as camera image brightness drifting over time describes. A level that cycles over a handful of frames and returns to its starting value points at a periodic light beating against your frame rate, which is the subject here. Log the mean gray level of 100 consecutive frames in your acquisition software. A pattern such as 148, 121, 133, 148, 121, 133 is flicker; a slow staircase is an auto mode. If a mains-driven or strobed light is anywhere near the scene, work through the checks below. The companion guide on camera flicker under artificial lighting covers the same fault from the lighting side.

Why mains lighting ripples at twice the line frequency

Mains voltage is a sine wave and crosses zero twice per cycle. Drivers and ballasts pass that shape into the light output, so a fixture on 50 Hz mains brightens and dims at 100 Hz, and one on 60 Hz mains ripples at 120 Hz. The ripple periods are 10 ms and 8.33 ms respectively — call it T_ripple from here on. Incandescent lamps are the quiet exception: the filament stays hot between zero crossings. An LED run from a bench supply or a DC controller is equally steady, which is why the same light can flicker in one station and behave in the next.

Predict the beat cycle from your frame rate

The frame period and the ripple period beat against each other. Because the frame rate is not locked to the mains, each exposure starts a fixed phase later than the last, and the brightness walks through the ripple in a repeating cycle:

phase step = T_frame mod T_ripple frames per cycle = T_ripple / phase step

Worked example: a camera at 30 fps has a frame period of 1000 / 30 = 33.3 ms. Under 50 Hz mains the phase advances 33.3 − 3 × T_ripple = 3.3 ms per frame, and the pattern repeats every T_ripple / 3.3 ≈ 3 frames. An 8,000 µs exposure integrates only 8 of those 10 ms, so each frame in the cycle collects a different amount of light. If your logged means repeat every three or four frames at 30 fps, this is the diagnosis. Change the frame rate to 24 fps and the cycle should stretch to about 6 frames (41.7 mod 10 = 1.7 ms per frame), which confirms it without new hardware.

Rule out the display and the auto modes first

Two software effects imitate flicker and cost nothing to check. Some tools map a 10-, 12- or 14-bit stream into an 8-bit display window dynamically: when the brightest and darkest pixels in the frame move, the whole display shifts even though the stored values have not changed. Turn the dynamic mapping off and read raw pixel values instead. At the same time switch off auto exposure and auto gain, which react every time a bright part enters the field of view. If raw means with fixed settings still cycle frame to frame, the light is the source and the fixes below apply.

Fix 1: set the exposure to a whole number of ripple periods

An exposure window that spans exactly one ripple period collects the same charge whatever phase it starts in; two or three periods do the same. Set the exposure accordingly:

t_exp = k × T_ripple, k = 1, 2, 3, …

On 50 Hz mains that means 10, 20 or 30 ms; on 60 Hz mains, 8.33, 16.67 or 25 ms. Return to the worked example: the 30 fps camera has a 33.3 ms frame period, so a one-period exposure fits easily. Change 8,000 µs to 10,000 µs and every frame integrates one complete ripple cycle; the phase step becomes irrelevant and the mean holds to within noise. If the scene is dim, 20,000 µs is equally flicker-free and doubles the light, and the camera still runs 30 fps because 20 ms remains below the 33.3 ms frame period.

The rule holds for rolling shutter sensors too: the rows start at different moments, but when every row integrates a whole number of ripple periods, all rows collect the same charge and the horizontal bands disappear. Near-misses do not count — 9.9 ms or 10.5 ms leaves a visible residual — so enter the exposure numerically in the driver rather than judging it from the image. Swapping to a global shutter area scan camera removes the bands but not the level cycling, so treat it as a banding fix only. The trade-off is motion blur: an exposure this long smears a fast part, and if that is unacceptable the light has to change instead. The sizing numbers are in exposure time versus shutter speed for moving parts.

Fix 2: feed the light DC from a light controller

A controller with filtered constant-voltage or constant-current output removes the ripple at its source, and then any exposure works: 1 ms for fast parts, 30 ms for dim scenes. Most stubborn cases trace to a light wired straight to mains, run through a dimmer, or fed from an unfiltered switch-mode supply. Moving the light onto a dedicated light controller ends the ripple and gives you a stable, adjustable drive. Match the output type to the light — constant voltage where the light is specified at 24 V, constant current where the drive current is the rating — and size the total power above the connected load.

Two controllers cover the common stations:

Light controllersDigital constant-voltage light controller, 60 W, 4 channels (LS-CTL-0290)LS-CTL-0290
Output
Constant voltage 24 V
Channels
4 channels
$449.00View part
Light controllersConstant current controller, 4 ch, 120 W, 89 x 147 mm, for 24 V lights (LS-CTL-0180)LS-CTL-0180
Output
Constant current
Channels
4 channels
$359.00View part

The LS-CTL-0290 is a 60 W, 4-channel constant-voltage controller for 24 V lights. The LS-CTL-0180 supplies constant current, 120 W over 4 channels, for stations that need the drive held at a fixed current. Keep dimmers and unfiltered wall supplies out of the loop afterwards: either one reintroduces the ripple you just removed.

Fix 3: strobe the light in step with the camera

A strobe driven by the camera's own trigger cannot beat against the frame rate, because it fires only inside the exposure, and the short, bright flash freezes motion at exposures a continuous light cannot match. The requirement is a single trigger source: route the same sensor or PLC pulse to the camera trigger input and the strobe input, and never let the light free-run on its own clock, because that recreates the original fault. Where you overdrive the flash for brightness, stay inside the duty-cycle and pulse-width limits covered in the guide on strobe overdrive, duty cycle and timing.

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

The LS-CTL-0070 is a 4-channel, 200 W digital control box with a strobe mode and RS232 control. If frames come out black after rewiring, work through the strobe-timing checks in the guide on strobe lights and black images. If only the first frames after start-up are dark, the first-frame-dark guide separates trigger settling from exposure timing.

Ambient light dilutes the fix

Ceiling fixtures, a neighboring machine's work lamp and daylight through a window ripple with the same mains period. Your inspection light can be perfectly steady while part of the scene illumination comes from elsewhere, and the cycle reappears. Switch off or block every source except your inspection light and re-run the 200-frame log. If the cycling vanishes, shield the station or reject the ambient: a synchronized strobe rejects ambient by the ratio of flash to ambient integration. For the test method and wording you can put into an acceptance test, there is a companion piece on specifying ambient light rejection.

Which fix to choose

Fix What it needs Choose it when
Exposure = whole ripple periods One setting change The part tolerates a one-ripple-period exposure (one T_ripple as defined above)
DC light controller One controller per light or group Short exposures, rolling shutter sensors, dim scenes
Synchronized strobe One trigger source for camera and light Fast parts, ambient to reject, more brightness needed

Decide in one line: if the part is still enough to sit still for a whole number of ripple periods, set the multiple today and close the ticket; if motion rules that out, put the light on DC; if you need speed and ambient rejection together, strobe in sync.

Keep it fixed

  • Log the per-frame mean over 200 frames after every lighting or trigger change; the beat cycle is the earliest warning.
  • Set exposures to whole ripple periods — 10 ms steps on 50 Hz mains, 8.33 ms steps on 60 Hz — whenever a light is mains-driven.
  • Feed every inspection light from a DC light controller, never a mains dimmer or an unfiltered wall supply.
  • Trigger camera and strobe from one source, and never let a strobe free-run.
  • Note the site's mains frequency, 50 or 60 Hz, on the station drawing; lights and fixtures follow parts between plants.

Where the level must stay inside a tight band for months, closed-loop lighting control shows how to hold it there automatically.

To pick a controller, the light controller finder filters by output type, channel count and power, and the step-by-step configurator matches it to your camera and lights. If the 200-frame log still cycles after these fixes, send the plot and your frame rate through the contact page and we will read it with you.

Questions

What exposure times are flicker-free at 50 Hz and 60 Hz mains?

At 50 Hz mains the light ripples at 100 Hz, so flicker-free exposures are 10 ms and every whole multiple: 10, 20, 30 ms. At 60 Hz the ripple is 120 Hz, giving 8.33 ms and multiples such as 16.67 and 25 ms. The exposure must also stay inside the frame period, and it must be entered numerically: a nominal value that actually runs 4% short leaves a residual ripple cycle.

Why does the fault disappear at one frame rate and return at another?

When the frame period is itself a whole multiple of the ripple period, every exposure starts at the same phase and the brightness looks stable. At 20 fps the frame period is 50 ms, exactly five ripple periods on 50 Hz mains, so the problem can hide at that rate and reappear the day you move to 24 or 30 fps. A locking rate is a coincidence, not a fix, which matters when you compare stations that run different speeds.

Do all LED lights flicker, or only badly filtered ones?

Only drivers without enough output filtering pass mains ripple into the light. A switched-mode driver with a large output capacitor, a laboratory supply or a dedicated DC controller holds the current steady, and the same LED then shows no frame-to-frame change at any exposure. The chip is not the source; the electronics feeding it are, so test the light from a DC supply before you replace it.

Can I remove the flicker in software after capture?

Not reliably. Frames captured at different ripple phases genuinely contain different amounts of light, so per-frame gain correction amplifies noise and clips where the signal is high. Shading or gain correction can hide a few percent of variation on a static scene, but it cannot recover detail lost when the exposure dipped. Fix the acquisition with exposure multiples, DC drive or synchronized strobing, and keep software correction for residual shading.

The room lights are off and brightness still cycles — where else does ripple come from?

Ripple reaches the sensor by reflection as well as directly. Ceiling fixtures outside the camera's view bounce off a shiny part, an enclosure window or a polished fixture, and a task lamp on the next bench contributes through scatter. Run the 200-frame log with only your inspection light powered, ideally inside a shrouded station: a remaining cycle then points at your own light's driver, not at the building.