summaryrefslogtreecommitdiff
path: root/content/posts/led-characterization.rst
diff options
context:
space:
mode:
Diffstat (limited to 'content/posts/led-characterization.rst')
-rw-r--r--content/posts/led-characterization.rst138
1 files changed, 97 insertions, 41 deletions
diff --git a/content/posts/led-characterization.rst b/content/posts/led-characterization.rst
index 411d156..e3c03e6 100644
--- a/content/posts/led-characterization.rst
+++ b/content/posts/led-characterization.rst
@@ -18,12 +18,16 @@ interesting, with up to two RGB or RGBW (red-green-blue-white) LED tapes. For am
really important so you could dim it down a lot without flickering. I ended up using the same driver stage I used in the
`multichannel LED driver`_ project for its great color resolution and low hardware requirements.
-.. figure:: https://upload.wikimedia.org/wikipedia/commons/d/d6/RGB_color_cube.svg
- :width: 100%
- :alt: An illustration of the RGB color cube
-
- An illustration of the RGB color cube. `Picture by Maklaan
- <https://commons.wikimedia.org/wiki/File:RGB_color_cube.svg>`_ (`CC BY-SA 3.0`_), from Wikimedia Commons.
+.. raw:: html
+
+ <figure>
+ <img src="/images/rgb_cube.svg" alt="An illustration of the RGB color cube.">
+ <figcaption>An illustration of the RGB color cube.
+ <a href="https://commons.wikimedia.org/wiki/File:RGB_color_cube.svg">Picture</a> by
+ <a href="https://commons.wikimedia.org/wiki/User:Maklaan">Maklaan from Wikimedia Commons</a>,
+ <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA 3.0</a>
+ </figcaption>
+ </figure>
To make setting colors over Wifi more intuitive I implemented support for HSV colors. RGB is fine for communication
between computers, but I think HSV is easier to work with when manually inputting colors from the command line. RGB is
@@ -41,13 +45,16 @@ color. `HSV`_ is an early attempt to more closely align these numbers with our p
this mathematical model, mapping a color from one color space into another color space is just a coordinate
transformation.
-.. figure:: https://upload.wikimedia.org/wikipedia/commons/4/4e/HSV_color_solid_cylinder.png
- :width: 50%
- :align: center
- :alt: An illustration of the HSV color space as a cylinder
-
- An illustration of the HSV color space as a cylinder. `Picture by SharkD
- <https://commons.wikimedia.org/wiki/File:HSV_color_solid_cylinder.png>`_ (`CC BY-SA 3.0`_), from Wikimedia Commons.
+.. raw:: html
+
+ <figure>
+ <img src="/images/hsv_cylinder.png" alt="An illustration of the HSV color space as a cylinder.">
+ <figcaption>An illustration of the HSV color space as a cylinder.
+ <a href="https://commons.wikimedia.org/wiki/File:HSV_color_solid_cylinder.png">Picture</a> by
+ <a href="https://commons.wikimedia.org/wiki/User:SharkD">SharkD from Wikimedia Commons</a>,
+ <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC-BY-SA 3.0</a>
+ </figcaption>
+ </figure>
CIE 1931 XYZ is much larger than any other color space, which is why it is a good basis to express other color spaces
in. In XYZ there are many coordinates that are outside of what the human eye can perceive. Below is an illustration of
@@ -61,13 +68,19 @@ particular in the blues and greens we loose *a lot* of colors to sRGB.
.. raw:: html
- <video width="480" controls loop>
- <source src="/video/sRGB.mkv" type="video/h264">
- <source src="/video/sRGB.webm" type="video/webm">
- Your browser does not support the HTML5 video tag.
- </video>
-
-`mkv/h264 download </video/sRGB.mkv>`__/`webm download </video/sRGB.webm>`__
+ <figure>
+ <video controls loop>
+ <source src="/video/sRGB.mkv" type="video/h264">
+ <source src="/video/sRGB.webm" type="video/webm">
+ Your browser does not support the HTML5 video tag.
+ </video>
+ <figcaption>Illustration of the measured sRGB color space within XYZ. The thick, white line is the spectral
+ locus.
+
+ <a href="/video/sRGB.mkv">mkv/h264 download</a> /
+ <a href="/video/sRGB.webm">webm download</a>
+ </figcaption>
+ </figure>
The wrong colors I got when fading between colors were caused by this coordinate transformation being askew. Thinking
over the problem, there are several sources for imperfections:
@@ -107,10 +120,9 @@ their respective XYZ coordinates. If all three channels are measured in one go w
magnitudes of the channels in XYZ will be accurate.
To map any color to the LEDs, the color's XYZ coordinates simply have to be mapped onto the linear coordinate system
-produced by these three points within XYZ. LEDs are extremely linear in their luminous flux vs. current characteristic
-so this model will be adequate. The spectral integrals mapping the channels' measured responses to XYZ need only be
+produced by these three points within XYZ. LEDs are mostly linear in their luminous flux vs. current characteristic so
+this model will be adequate. The spectral integrals mapping the channels' measured responses to XYZ need only be
calculated once and their results can be used as scaling factors thereafter.
-.. FIXME Add led/current graph here
Measuring the spectrum
----------------------
@@ -179,7 +191,18 @@ Pointing a camera at the spectrograph would be the obvious thing to do. This pro
flaw: I wanted to acquire quantitative measurements of brightness across the spectrum. Since I don't have a precise
technical datasheet specifying the spectral response of any of my cameras I can't compare the absolute brightness of
different colors on their pictures. Some other sensor was needed.
-.. FIXME Spectrum picture
+
+.. raw:: html
+
+ <figure>
+ <img src="/images/daylight_spectrum_dvd.jpg">
+ <figcaption>The daylight spectrum as seen using a DVD as a grating.
+ <a href="https://commons.wikimedia.org/wiki/File:SpectresSolaires-DVD.jpg">Picture</a> by
+ <a href="https://commons.wikimedia.org/wiki/User:Xofc">Xofc from Wikimedia Commons</a>,
+ <a href="https://creativecommons.org/licenses/by-sa/4.0/">CC-BY-SA 4.0</a>
+ </figcaption>
+ </figure>
+
Measuring light intensity
~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -311,7 +334,17 @@ check for when I made some mistake easy to spot in the resulting data.
After one color channel is captured, the LED tape has to be manually set to the next color and the next measurement can
begin.
-.. FIXME raw measurement plot
+.. raw:: html
+
+ <figure>
+ <img src="/images/raw_plot_cheap_rgb.svg" alt="A plot with three wide peaks, two large peaks on both sides and
+ one smaller one in the middle. The middle one overlaps the two on the sides. The large ones are about 2.5V in
+ amplitude. Overall, the plot is about 300 stepper steps wide with each peak being around 130 steps wide.">
+ <figcaption>A plot of the raw preamp output voltage versus stepper position. From left to right, the three peaks
+ are blue, green and red. Step 0 corresponds to the bottommost stepper position and the shortest wavelength.
+ </figcaption>
+ </figure>
+
Data analysis
~~~~~~~~~~~~~
@@ -346,8 +379,20 @@ estimate is produced by a least-squares fit of a linear function. This fine esti
sensitivity correction of all original measurements and the scale is changed from stepper motor step count to
wavelength in nanometers.
-.. FIXME processed spectrum plot
+.. raw:: html
+
+ <figure>
+ <img src="/images/processed_plot_cheap_rgb.svg" alt="A plot with three wide peaks, all three of different
+ heights. The leftmost peak is highest at 6nA, the middle peak lowest at 1.6nA and the rightmost peak in between
+ at 4nA. The middle one overlaps the two on the sides. Overall, the plot spans about 300nm on its x axis with
+ each peak being around 100nm wide.">
+ <figcaption>A plot of the processed measurements. From left to right, the three peaks are blue, green and red.
+ </figcaption>
+ </figure>
+
+.. FIXME re-do these measurements, avoiding clipping
+.. FIXME re-do calibration using CCFL
.. FIXME calibration for brightness imbalance due to wedge-shaped projection of spectrum
Color space mapping
@@ -371,14 +416,19 @@ models can be found in the `project repo`_.
.. raw:: html
- <video width="480" controls loop>
- <source src="/video/led_within_srgb_scale=1.0.mkv" type="video/h264">
- <source src="/video/led_within_srgb_scale=1.0.webm" type="video/webm">
- Your browser does not support the HTML5 video tag.
- </video>
-
-`mkv/h264 download </video/led_within_srgb_scale=1.0.mkv>`__/`webm download </video/led_within_srgb_scale=1.0.webm>`__
-
+ <figure>
+ <video controls loop>
+ <source src="/video/led_within_srgb_scale=1.0.mkv" type="video/h264">
+ <source src="/video/led_within_srgb_scale=1.0.webm" type="video/webm">
+ Your browser does not support the HTML5 video tag.
+ </video>
+ <figcaption>Illustration of the measured LED color space scaled to fit within XYZ with sRGB (light gray) for
+ comparison. The thick, white line is the spectral locus.
+
+ <a href="/video/led_within_srgb_scale=1.0.mkv">mkv/h264 download</a> /
+ <a href="/video/led_within_srgb_scale=1.0.webm">webm download</a>
+ </figcaption>
+ </figure>
As you can see, the result is pretty disappointing. The LED's color space parallepiped is very narrow, which is because
the blue channel is much brighter than the other two channels. An easy fix for this is to scale-up the RGB space and
@@ -392,13 +442,19 @@ around with a couple of factors and settled on 2.5 as a reasonable compromise. B
.. raw:: html
- <video width="480" controls loop>
- <source src="/video/led_within_srgb_fancy_camera_path_scale=2.5.mkv" type="video/h264">
- <source src="/video/led_within_srgb_fancy_camera_path_scale=2.5.webm" type="video/webm">
- Your browser does not support the HTML5 video tag.
- </video>
-
-`mkv/h264 download </video/led_within_srgb_fancy_camera_path_scale=2.5.mkv>`__/`webm download </video/led_within_srgb_fancy_camera_path_scale=2.5.webm>`__
+ <figure>
+ <video controls loop>
+ <source src="/video/led_within_srgb_fancy_camera_path_scale=2.5.mkv" type="video/h264">
+ <source src="/video/led_within_srgb_fancy_camera_path_scale=2.5.webm" type="video/webm">
+ Your browser does not support the HTML5 video tag.
+ </video>
+ <figcaption>Illustration of the measured LED color space at scale factor 2.5 within XYZ with sRGB (light gray)
+ for comparison. The thick, white line is the spectral locus.
+
+ <a href="/video/led_within_srgb_fancy_camera_path_scale=2.5.mkv">mkv/h264 download</a> /
+ <a href="/video/led_within_srgb_fancy_camera_path_scale=2.5.webm">webm download</a>
+ </figcaption>
+ </figure>
Firmware implementation
-----------------------