0
\$\begingroup\$

TL;DR ver:

LED light controlled with Arduino lights up during an interval of 2 frames, not one in a video footage of 30 FPS. It slowly turns on... but why?

=====

I have a (mouse) behavioral experiment set up with an Arduino Mega board (ATMega2560 chip), which is programmed to control an LED to turn on and off repeatedly (blink) with 1 second intervals. The Arduino code is very simple with DigitalWrites and time controls. LED is a commonly seen 3pi 567nm yellowgreen one.

Also, the board is programmed to send GPIO pulse signals every time it DigitalWrites to the LED. The video is taken with Logitech C922 webcam (30 FPS, 720p) and the whole point of blinking LED is to sync the video footage with a cell recording done simultaneously.

However, after examining the video footage, It just seemed to me that the LED signal was not 'crisp' enough. The LED brightness visually peaked during an interval of 2 frames, not one. It almost took 1/15 of seconds which was much longer than I expected.

Frame N, N+1, N+2, cropped

GPIO signals were crisp with less than 1 millisecond of delay and seemed to reflect DigitalWrite. GPIO signals were crisp with <1ms duration to peak or trough

So... after surfing the internet for any clues, I found out that direct emission diodes had a turn-on time of single digit or at most tens of 'nano'seconds, which was not what I was seeing in the video footage.

Some LEDs with junction capacitance or parasitic(?) capacitance seem to lengthen the RC time leading to slower switching. (https://lednique.com/led-speed/)

Also, there seemed to be a technical delay regarding DigitalWrite function over direct board writing in Arduino, but the magnitude of the delay seemed negligible to this case.

regular digitalWrite() in Arduino Uno core (16MHz) takes about 6.28 µs while digitalWriteFast() port manipulation takes 125 ns (https://github.com/NicksonYap/digitalWriteFast)

I have no background in electrical engineering, and I was wondering if this can be explained. My hypothesis is either

  1. It is a faulty diode with big junction capacitance.
  2. Sudden change in brightness cannot be recorded in a low-end video capturing device (such as Logitech webcam C922) and nanosecond change in brightness is recorded in the footage with delays.

Swapping the LED with the same type (only have one type atm) did not change the slow turn-on.

I am not aware of real-world data and whether faulty LEDs can actually turn on that slowly (over 1/15 second), so I'm asking for advice.

Any advices are welcome. I will try to additionally upload specific details if needed.

Thanks in advance :D

\$\endgroup\$
9
  • \$\begingroup\$ Interlaced video? \$\endgroup\$
    – winny
    Commented May 4 at 16:36
  • 2
    \$\begingroup\$ I suspect that the issue is with your cameras, not the LED. \$\endgroup\$
    – Drew
    Commented May 4 at 16:51
  • 2
    \$\begingroup\$ LED "turn on" time is in range of us (and less). If you turn on LED in the middle of exposure time, then you can see reduced intensity in that frame (image chip integrate light over time). \$\endgroup\$ Commented May 4 at 17:04
  • \$\begingroup\$ Are you synchronizing the LED with the camera frame rate? If not then on average it's going to take two frames to reach full brightness because of how cameras work. \$\endgroup\$ Commented May 4 at 17:14
  • \$\begingroup\$ winny Yes, it is interlaced. Drew Very interesting, thanks. MichalDudka This. Very interesting and thank you for the insight. @user1850479 No, the LED blinks 1Hz and frame rate is 30fps. Can you articulate more on why it takes two frames? Is it because they say it is natural to have shutter speed double the amount of fps? Logitech webcam does seem to have 30fps 1/60s exposure time to sensor. Thank you for the comment. \$\endgroup\$ Commented May 5 at 2:31

2 Answers 2

4
\$\begingroup\$

The LED doesn't light up slowly. LEDs are used for data transmission from a few MHz to tens of MHz so they do turn on and turn off quite fast - if you don' count for white LEDs.

So in reality, a better question to ask would be why it appears to light up slowly.

The camera does not take an infinitely short sample of the light it sees, the light is gathered during the whole exposure period, which can be as high as one frame of video in low light and it can be as short as necessary in bright light.

There are two distinct methods of doing the exposure, global shutter and rolling shutter. It does not really change the result much in your case.

It basically means, at 30 FPS, the light can be gathered for 1/30th of a second and then the frame is read out and sent to computer.

The LED appearing halfway lit when it turns on or off is just because it turns on or off at some point during the 1/30th of a second exposing one frame. It might have been only 50% or any other percentage turned on and off during the frame exposure, so that is why it appears being not fully off and not fully on.

In frames before or after, the LED is either fully on or off during the frame.

\$\endgroup\$
2
  • 3
    \$\begingroup\$ Indeed. I develop digital cameras for various applications, and sometimes I use arrays of LEDs to characterize the precise exposure start/stop times for the image sensor chips. \$\endgroup\$
    – Dave Tweed
    Commented May 4 at 19:25
  • \$\begingroup\$ Very nice. Accepted as answer because the explanation was a bit more EE newbie-friendly. Using this phenomenon to determine precise exposure time is a cool application it seems. Thanks! \$\endgroup\$ Commented May 5 at 2:45
8
\$\begingroup\$

My first inclination is that the LED turned on part way through the camera's exposure time and that the "photon integral" (I've just made that up) is incomplete as a result.

If you have a better camera - your phone? - then try a video with maximum aperture and minimum exposure time.

\$\endgroup\$
1
  • \$\begingroup\$ The 'photon integration' does seem to the reason why turning on is 'smoothed'. Not sure if I can change exposure time on this webcam, but I'll definitely try what you suggested with my cellphone. Thanks a lot! \$\endgroup\$ Commented May 5 at 2:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.