Tag Archives: led

Mitigate the LED bright spots

IMG_6876PSicon

As a Playstation lover, I liked the concept of the decoration I saw on playstation-gear.com.

However, I was wondering if there is a way to make the light more equally diffused on the surface of the icons. It is as well a nice DIY exercice for the weekend.

First lets 3D draw the models with Fusion360. The shapes are hollowed and closed with a cap holding the LEDs:

fusion03

I populated the caps with SK6812 RGBW leds, and control them with an ESP32:

IMG_6864

I printed the body in one part, changing the filament color after the first millimeter to have the front transparent, but not the sides. I painted the inside with white acrylic to enhance diffusion:

IMG_6880

Then the idea was to diffuse the bright spots cast by the tiny LED. So I took a picture of them right away:

IMG_6862-2

Clean and filter this picture to have a black and white image representing the light intensity on the icon surface. I used the Fusion360 plugin image2surface to generate a mesh. Converting this mesh to t-spline surface, then cut a body with it to have the diffusion volume proportional to the light intensity.

Print this diffusion volume in transparent and assemble the 3 parts:

It’s not perfect and the process can be iterated, but with the right colors and a bit of animation, I think it is as good as the sold one.

IMG_6885

The 3D files can be found on thingiverse here.

IMG_6876

Creative Commons License

A bed Lamp – Sunday project

bedLamp

An issue of falling asleep while reading in bed is the lamp will be on forever. A lamp that fade gently off after a certain time is strategically good for a peaceful couple relationship and for a rainy Sunday project.

Few constraints

  • Fading off after 1 hour
  • Pseudo color (temperature) control
  • 5V powered

Electronics

LEDThe LED used is a SK6812 with 4 channel, R, G, B and warm white.

The microcontroller is a PIC12F1840. A potentiometer gives an analog value for the color.

To control the SK6812, I used the work of Steve Phillips. He discover that the serial protocol is easier to implement than described in the SK6812 ‘datasheet’. Basically “A 0 bit is given when the high voltage time is less than roughly 0.35µs.” and for a 1 bit “As long as you don’t pull low for 50µs between high voltage points, you are fine.

schema

The analog value is read in a loop and is used to determine the color and intensity of the led. If this value does not change during 1 hour, the color is faded gently.

The PIC code is in this repository : https://github.com/pierre-muth/Bed_Lamp

3D printed body

I used Fusion 360 for the 3D drawing. A set of gears make the potentiometer rotation linked to the base rotation. In order to get a reasonably directional cone of light, I made a “nozzle” like shape, that can be orientated thanks to a ball joint connection.

Printed in PLA during a night on a Prusa i3 MK3, and the inside is painted in white. Files are on thingiverse here.

IMG_6790

Result

IMG_6782

IMG_6783

bedLamp

Thanks for reading!

Creative Commons License

Destination moon

Recently inspired by some 3D printed rockets lamp, I thought maybe it’s a good occasion to start the exercice myself from scratch.

 

As a child, reading the Tintin ‘Destination moon‘ adventures really expand my dreams and I still enjoy reading this comic. The iconic red and white rocket has not too complicated shapes, but still interesting. Of course the rocket it is yet modeled, and plenty of 3D files can be found over internet. However the most accurate in my opinion is the work of Gregory V.

So I started Fusion360 with some contraints in mind.

  • As accurate as possible shape from the comic
  • A size up to 50 cm tall
  • Assembling without extra parts

I used the same solution as Gregory for the alternating red and white parts, but the structure rods are printed with the two central pars.

 

And the assembly looks like the following :

assembly

Lets start the lovely Prusa i3 and be patient. The rocket is printed in three times. For a total of approximately 45 hours and 480 grams of PLA.

 

To generate a dynamic plume of smoke effect, this time I used 3D Studio Max and its ‘meta-particle’ system :

tintin3DS

Few white LEDs connected to the USB port of the computer gives a result which I’m quite satisfied!

IMG_6053

Thanks for reading and if you’d like to go further, this repository might interest you.

Creative Commons License

Another Candle

candleV1 v22

Christmas lightnings around houses are not my favorite, however I like the atmosphere of warm little candles put on the bottom borders of the windows . That’s the starting point of a long and lazy digression.

Instead of burning continuously paraffin wax, could we make a reusable electronic one ? Of course, there is tons of cheap products available. But they are somehow not really convincing me. And I’m not the first one to look on that subject.

I’ll try here to summarize what I’ve found and what I’ve enjoyed to do. Sources and drawings can be found in this github repository.

Over internet:

You can spend a lot of time completely lost on internet as I did, by just googling ‘led candle’ or ‘flickering led’ or ‘micro controller candle’ etc…

I’ve found a nice Tim’s blog post about the reverse engineering of a flickering led. It is really worth a read, he details everything from measurements to analysis, and reproduce the algorithm. This is followed by another post which really interested me. How a real candle flame behave.

The real flame:

To summarize, and as probably everyone knows, the candle flame brightness has two types of behavior. Usually it is rather constant, and it happens some time that the brightness starts to oscillate for one or two seconds. One thing I can add to that is the flame is gently moving, from one side to another one.

Another property of the flame is its light spectrum. And here as well, a lot of people studied this. It is a very warm light with plenty of red / infra-red. We can find some measurements from 1000 to 2000K of color temperature.

Start the Project:

We roughly know what to mimic, so let’s choose some components according these constraints.

For the LED, I looked for the warmest white on the range of 10-20 mA. My ‘local’ provider is Farnell, so after some sorting and filtering I end up with a Wurth warm white led, €0.18.

medium-pic10f320-sot-23-6To add a bit of challenge I choose a very small micro-controller, but still accessible with my tools and knowledge. The PIC10F320 has only 6 pins, 64 bytes of RAM and 256 bytes of program memory. But it has 2 PWM output and an ADC, all for €0.42

To power everything from an AA battery I choose to use a step up converter. The €0.38 MCP1624 is able to output 50mA at 3.3V from a single AA battery, and is working down to 0.35V.

From this point we can control and power two led and read an analogue value such as the ambiant luminosity (using a photo-resistor for example). It is possible to mimic the flame swing by balancing the brightness of the two LED, plus the random oscillations with the total brightness. We can switch off the LEDs when the day is too bright as well.

Code contraints and Prototyping:

After some soldering I manage to put the components on a small development boards and start coding.

 

 

I used the Microchip IDE and their XC8 C compiler. The challenge here is that the compiler is in ‘free’ mode, so the compiled code is rather large. I didn’t want to use assembly mainly because I’m not quite confident to prototype with it. But I admit it is the preferable way to do something with only 256 bytes of program available. It’s perfectly legit to argue that an ATtiny10 would at least do the job better. I should invest time to the AVR side one day !candle_XC8

After many iteration to reduce the program size, I end up with only 4 free bytes. Wow. Some C operations give more compact program for the same function (for example initialisation to 0 or an arbitrary value).

The code uses the famous Linear feedback shift register as random generator. The flame position, the speed to go from one to the other position, the oscillations occurrence and their period number are random. The two LEDs are dimmed with the build in PWM, and the speed of change with the Timer0.

It is still open to more complex code as I can use the PIC10F322 with 512 bytes of program space (or even ATtiny10 which seems to be almost pin compatible).

I acquired the two LEDs PWM signal with my recently acquired DSLogic :

candlePWM

And plot them with a quick and dirty Java program:

candlePWMchart2

You can notice the oscillation mode on the chart after 4th second, and the flame swing mode surrounding it. For the oscillations, the total brightness is changing while otherwise it stays constant at 50% (the sum of the two led brightness).

Getting serious with a PCB:

Let’s startup Kicad, do the schematics and play a bit with the PCB drawing. I have in mind a design for a 3D printed case, we’ll see that later.

 

 

Several times now I ordered PCB from OSHPark, and never been disappointed. I could use their manufacturing precision to down size the board area up to 17x17mm, giving $2.45 for 3. I let an option for a push button, we never know…

pcb_oshpark

Less serious with the 3D shape:

It is time to think how to hold everything together. I applied for the free student Fusion360 licence. I have to say the program is very nice to handle and to learn.

candleV1 v20

The idea is to hold the battery on the PCB with the three part threads. Just screw them together and it should light-up. The only compromise is the ground wire that goes from the PCB to the bottom part along the battery body.

I also made a join part to be able to have some versions with two AA battery stacked, making it taller and with a longer battery life.

candle_mechanical_draw

Then I removed the dust of my M3D micro printer, far from the best printer nowadays, but the cheapest when it went out.

IMG_5275IMG_5271IMG_5270

Soldering and programming:

And the boards crossed the Atlantic ocean and arrived in the mailbox! It’s always a pleasure to solder components on these high quality boards (even 0805 with a soldering iron).

 

 

To program the PIC, I forgot to order some 1.27mm spacing pin headers. However, there is a solution with two 2.54mm ones:

IMG_5302

Life-time: 

I don’t own yet a nice multimeter, so the current measurement I did with my actual (too) cheap one is rather approximate. I got around 12mA with the LEDs on, and around 4mA in sleep mode, drawn from the battery. Maybe the current of the sleep mode is still high due to the step-up circuit, which runs all the time…

However it stays on at least 3 consecutive days on a single AA Ni-MH rechargeable battery. I logged the battery voltage of one candle with my raspberry-pi logging station. It start with a fully charge single AA Ni-MH battery and I remove the sleeping mode:

battery2

 

Final result:

IMG_5299

IMG_5306

It is rather hard to catch the effect on a video, as the aim was to create a LED candle as quiet as a real candle could be.

candle

Thanks for reading !

(and my apologies for the approximate language)

Creative Commons License