~krystianch/krystianch.com

7515117d746e20ae74acf5ddabecad91392edb39 — Krystian ChachuĊ‚a 2 months ago 5e3515f
Publish light
1 files changed, 16 insertions(+), 15 deletions(-)

M content/posts/light/index.md
M content/posts/light/index.md => content/posts/light/index.md +16 -15
@@ 1,7 1,6 @@
---
title: "HSV night light"
date: 2024-01-18
draft: true
date: 2024-01-19
---

{{< vfigure res="videos/demo.mp4" >}}


@@ 16,8 15,9 @@ conical frosted glass cover.
[[3D models]](https://git.sr.ht/~krystianch/tiny-light/tree/master/item/hardware/3d-printables)

The enclosure is 3D printed.
The top transparent part acts as a light diffuser and the bottom part houses
the electronics.
The top transparent part acts as a light diffuser.
Inside there is a 3 W RGB LED.
The bottom part houses the electronics.
The front panel features an on-off switch and three knobs, which
control the hue, saturation and brightness of the light.
On the back there is a barrel jack socket to connect a 12 V power supply.


@@ 30,16 30,16 @@ On the back there is a barrel jack socket to connect a 12 V power supply.

{{< figure res="images/v1.jpeg" caption="First prototype. Conical part reused from a ceiling light." >}}

The first iteration of the project is a single prototype that uses the cover
The first iteration of the project was a single prototype that uses the cover
for an old ceiling light as a diffuser.
The frosted glass cover sits on top of a 3D printed base, which also provides the
space for the front panel.
The conical glass part sits on top of a 3D printed base, which also
provides some space for the front panel.
Of course this is not a sustainable way to create more lamps.
This is why later I designed a smaller, wholly 3D-printable enclosure.
The prototype also has three 3 W LEDs instead of one and a continuous rotation
hue knob (see section: [Issues](#issues)).
This is why I designed a smaller, wholly 3D-printable enclosure.
The prototype also has three 3 W LEDs which makes it a 9 W lamp.
It also has a hue knob with continuous rotation (see section: [Issues](#issues)).
The prototype's frosted glass cover diffuses the light way better than the
transparent 3D printed plastic, but I had only one of those. 
transparent 3D printed plastic, but I only had one of those. 

## Theory of operation



@@ 48,10 48,10 @@ The three knobs set the coordinates in the
These coordinates are translated to RGB and respective LED channels are driven
with power proportional to the R, G, and B coordinates.

This process is performed by a microcontroller.
This process is performed by a microcontroller in a loop.
First, the position of all knobs is read by the built-in 10-bit
<abbr title="analog-to-digital converter">ADC</abbr>.
Then, the knob positions are mapped to the correct ranges, which is 0 - 360
Then, the knob positions are mapped to the correct ranges, which is 0.0 - 360.0
degrees for hue and 0.0 - 1.0 for saturation and brightness.
Next, [these formulas][1] are used to convert HSV coordinates to RGB.
Finally, RGB coordinates (range 0.0 - 1.0) are mapped to 8-bit integers (range


@@ 124,7 124,7 @@ light while rotating the hue knob near +/- 5 degrees.

The next issue is the lack of calibration.
Due to the different luminous flux per milliamp of current for each of the LED
channels, the hue, saturation and brightness controls are not exactly orthogonal.
channels, the hue, saturation and brightness controls are not fully independent.
For example, the hue and saturation of the light also change a little when
turning the brightness knob.
This effect is most noticeable when brightness is low.


@@ 158,7 158,8 @@ beautifully, the transparent
<abbr title="polyethylene terephthalate glycol-modified">PETG</abbr> plastic
doesn't.
Even a 3 mm thick layer of it refracts light in such a way that the primary
colors peek through, especially in the lower part that is closest to the LEDs inside.
colors peek through, especially in the lower part that is closest to the LEDs
inside.
I've experimented with various levels of infill for the prints to mitigate this
effect.
However, both values I tried had some downsides.