NeoPixels Revealed: Warping time and space to actually see inter-pixel jitter
In the PWM article, we discovered that each NeoPixel has a clock that free-runs at about 500Hrz and each pixel will only update its displayed color at the end of a clock cycle. This means that there should be about 2ms of jitter when updating a pixel, which absolutely limits the maximum refresh rate.
This sounds good in theory, but how can we actually see something that happens over the course of 1-2ms?
My first strategy was to haul out the amazing Nikon 1 J4 which can shoot at an astonishing 1,200 frames per second. It is no Phantom, but at 0.8ms per frame it is just good enough to catch some of the jitter. Here is a video of a string of NeoPixels blinking off and on a couple of times over the course of 0.05 seconds…
The amber indicator LED on the far left lights up immediately after the latching reset pulse is sent, then for the next couple of frames you see the Neopixels individually update at random times according to the phase of their internal PWM clocks. It takes a full 3 frames (9-12) which corresponds to about 2.4ms (3 frames *0.8ms/frame) for all the pixels in this string to update.
While this is really cool and seems to confirm that the pixel jitter really exists in the real world, we are sampling at a rate very close to the rate of the thing we are trying to measure which could mislead us. If only we could get more temporal resolution. How can we see down to microseconds without spending $20k on a fancy camera?
Hmm… My camera has lots of spatial resolution (5232 x 3488!), and we only even really need one of those two spatial dimensions (width) to see our linear string of NeoPixels. If only we could trade the other spatial dimension that we are not using (height) for temporal resolution… but how can we trade space for time?
All it takes is tripod with a tiltable head and a quick wrist! Here is the setup…
If we point the camera at the pixels and then quickly scan the camera’s field of view across the pixels, we will record their time transitions as changes along the y-axis of our photo! Here was my very first attempt at dimensional arbitrage…
I think this image is pretty freaking beautiful! It very clearly shows the LED jitter with a resolution on the order of sub-milliseconds. It even captures the fact that I was only actually blinking the leftmost 42 pixels – the rest just happened to be 50% white and blinking at the PWM frequency of about 400hz. To the naked eye, this string just looks like a slightly dimmed white line, but with this time warp technique we can see into the secret high-speed world. I can hear the Scalosians buzzing!
This trick is nothing new. It is the same thing going on with the now trendy light painting displays and I’ve even been doing it since the 90’s. But it is still an amazing way to turn a $100 camera into a $20K high speed recorder – as long as you don’t mind loosing a dimension.
After some practice to get my tripod-tilting fast and steady and also turning out the lights in the room, I was able to get this close up shot…
The amber indicator LED on the left is on for just 125 nanoseconds (2 CPU cycles at 16Mhz). It marks the end of the latching reset pulse that tells the NeoPixels to update their displays. You can very clearly see the displays each update when their PWM cycles finish. Keep in mind that the camera was tilting from down to up, so time runs from top to bottom. If you look really closely, you can even see the very brief 120us off period that happens between PWM cycles of the pixels that are on for more than one cycle. Try clicking on the photo to zoom. It looks like the necking of a string of hot dogs. See? Just by counting, we can see that some of the pixels are on for 1 PWM cycle, while others are on for 2, and a couple that hit it just right are even on for 3 cycles- all depending on what phase their PWM cycle happened to be in when the latch pulse arrived.
Ok, enough shop talk. Let’s now look at a pretty NeoPixel time warp picture!…
This photo shows the string cycling though full brightness red, green, blue, and white. To the naked eye this also just looks like a solid white bar – but if you happen to shift your gaze quickly you can just catch the colors out of the corner of your eye as they paint across your retina. It is a neat effect because the colors disappear again as soon as you look at them.
FAQ
Q: How fast can you go?
A: The limits on time resolution include
- The vertical resolution of the camera,
- How much light hits the image recorder,
- How fast you can tilt the camera.
My camera has 5000+ pixels in the Y axis and the NeoPixels are really bright, so the limiting factor for me is how fast I can tilt. I’ve gotten much higher resolution by putting the camera far away from the pixels and zooming in. This increases the effective speed. If you wanted to go even faster, you could use a spinning mirror instead.
Q: How long was the strip powered up for before you did the test? I bet the pixels started of all in sync, but drifted over time.
A; I actually thought this too, and so did a test about 1-2 second after repowering the string. The results are the same. I should have guessed this because in the first image, you can see that even in the short instant of the exposure the drift between pixels is noticeable otherwise the dot pattern on the right would be smooth.
Your camera should take 1200 images per minute not per seconds. It’s 20 frames per second equivalent to 50ms per shoot.
Anyway, those pictures as nice :-)
Nope, it really is an amazing 1200 frames per second! Slow motion mode of “416 x 144/1200 fps (aspect ratio 26 : 9; plays at 30p/29.97 fps)”
Hooo, you’re right, my mistake.
It seems to high to be true :p
Hmm… according to the analysis of the propagation of the Din to Dout signal you did in a prior post, shouldn’t there be a 200ns delay between each NeoPixel as this is the time it needs to pass on the signal, and thus also changes the time for each pixel before it latches at it reaches the reset time with the last low signal?