Measuring Panel Light Flicker on 50 Hz Mains With an Arduino and a Photodiode

2026-12-03来源 dev.toEnglish

There's a call we get every few months. An office manager says the staff have headaches by mid-afternoon and wants to know if the new panel light over their desks is to blame. Nobody can see anything wrong. The ceiling looks perfectly steady. That doesn't settle it, because the flicker an LED driver produces usually sits at 100 Hz, well above what people notice by staring upwards.

We supply the Hyundai backlit panel with an isolated driver to offices across Pakistan, and when a question like that comes in, we'd rather measure than argue. This post builds a cheap flicker meter from an Arduino Uno and a photodiode, works out percent flicker and flicker index on the board, and explains how to read the numbers. It works on any brand, ours included.

Why 100 Hz, and why your eyes miss it

Pakistan's grid runs at 50 Hz. A driver rectifies that AC into DC, and whatever its output stage fails to smooth turns up as a ripple in the light at twice the mains frequency. So, 100 Hz. A well-filtered constant-current driver keeps that ripple small. A cheap one with a tiny output capacitor, or none, can let the light swing hard on every cycle.

You rarely see it directly. You see it sideways: a stroboscopic trail when you wave a pen under the light, or dark bands rolling across a phone camera pointed at the diffuser. The phone trick is a fair first check. It depends on the camera's shutter speed, though, and it gives you no number to put in a report.

Two numbers worth measuring

Percent flicker, also called modulation depth, is (max - min) / (max + min) x 100, using light output at the peak and the trough of the waveform. Zero means perfectly steady. A hundred means the light goes fully dark every cycle.

Flicker index looks at the shape as well. Find the average light level over a cycle, then divide the area of the waveform above that average by the total area under it. It runs from 0 to 1. Two lights can share a percent flicker figure and still differ here, if one dips briefly and the other sits low for most of the cycle.

For a yardstick, IEEE 1789-2015 recommends treating modulation below 0.08 x frequency as low risk, which is 8% at 100 Hz, and below roughly 0.0333 x frequency, about 3.3%, as no observable effect. It's a recommended practice, not a legal pass mark, but it's the line most people compare against.

Parts and wiring

  • An Arduino Uno or Nano clone, which any electronics market, Hall Road in Lahore included, will have
  • A BPW34 photodiode, or any fast silicon photodiode
  • One resistor, starting at 10 kΩ
  • Jumper wires and a USB cable

Wire the photodiode's cathode to 5V and its anode to A0, with the resistor from A0 to ground. Reverse-biased like this, the diode passes a current roughly proportional to the light falling on it, and the resistor turns that into a voltage the ADC can read. A bigger resistor gives more signal. Too big, and a bright panel light pins the reading at 1023.

Don't use an LDR. Cadmium sulphide cells respond in tens of milliseconds, so they average out a 100 Hz ripple and will tell you every light is perfect.

The sketch

An Uno's analogRead takes a little over 100 microseconds, so sampling every 200 microseconds is comfortable. Five hundred samples is 100 ms, ten full ripple cycles on a 50 Hz supply, and the buffer fits in the Uno's 2 KB of RAM.

// Flicker meter: photodiode on A0, Arduino Uno, 50 Hz mains const int SENSOR = A0; const int N = 500; // 500 samples = 100 ms = 10 ripple cycles const unsigned long DT = 200; // microseconds between samples (5 kHz) const float DARK = 0; // reading with the light off, set after first run int buf[N]; void setup() { Serial.begin(115200); } void loop() { unsigned long t = micros(); for (int i = 0; i < N; i++) { while (micros() - t < DT) {} t += DT; buf[i] = analogRead(SENSOR); } long sum = 0; int lo = 1023, hi = 0; for (int i = 0; i < N; i++) { sum += buf[i]; if (buf[i] < lo) lo = buf[i]; if (buf[i] > hi) hi = buf[i]; } float mean = (float)sum / N; float above = 0, area = 0; for (int i = 0; i < N; i++) { area += buf[i] - DARK; if (buf[i] > mean) above += buf[i] - mean; } float pct = 100.0 * (hi - lo) / (hi + lo - 2 * DARK); float index = above / area; Serial.print("mean="); Serial.print(mean, 1); Serial.print(" min="); Serial.print(lo); Serial.print(" max="); Serial.print(hi); Serial.print(" flicker%="); Serial.print(pct, 1); Serial.print(" index="); Serial.println(index, 3); if (hi >= 1020) Serial.println("clipping: move the sensor back or use a smaller resistor"); delay(1000); } 

Set DARK before you trust anything. Switch the light off, black the room out as best you can, note the mean the sketch prints, put that number in and upload again. Skip this and stray daylight lifts the minimum, which makes every light look steadier than it is.

Testing a panel light on mains, UPS and generator

Hold the sensor at a fixed distance under the diffuser, 30 cm or so, and keep it there for every reading. Test at night if you can, with the other lights off.

Then do what no showroom does. Run the same fitting off every supply it will see in real life. In most Pakistani offices that means the grid, a UPS or inverter during load-shedding, and quite often a generator. Some cheaper UPS units put out a stepped, modified sine wave, and a generator's voltage and frequency wander as the load changes. A driver that's calm on clean mains can behave quite differently on either.

If you can, take one more reading on a summer evening, when voltage in a lot of areas sags as every AC on the street kicks in. A driver pushed out of its regulation range often shows it in the ripple first. Log each run as supply, mean, flicker % and index. That table is your report.

Reading the results

Low single digits on mains means the panel light's driver is doing its job. Well above the 8% line, and climbing further on the UPS, is worth raising with whoever sold you the fitting. A flicker index close to zero with a gentle, sine-like ripple is the usual signature of a decent constant-current driver. A high index usually means the output is being chopped on and off, which is also what cheap low-frequency PWM dimmers do.

Measure an old LED panel light too. The electrolytic capacitors in a driver age faster in heat, and a ceiling void in a Multan or Sukkur summer gets very hot. A fitting that was fine at handover can drift years later, and this rig lets you check before anyone decides to replace a whole floor.

What this rig can't tell you

It isn't a calibrated instrument. The photodiode doesn't see colour the way your eye does, the ADC has only 10 bits, and one noisy sample can inflate the max or the min. Take several captures and look at the spread rather than trusting a single line. It won't measure lux, glare or colour rendering either.

Still, for very little money, it turns "the staff say the lights bother them" into numbers you can compare across fittings, supplies and years. If a reading looks odd and you'd like a second opinion on it, Hyundai LED's technical desk is happy to go through it with you.

原文:https://www.a8q9.cn/en/article/measuring-panel-light-flicker-on-50-hz-mains-with-an-arduino-and-a-photodiode-f75840.html

相关文章