Darkstar MK.II

Durable caving headlamp, tested on people

caving LED atmel

The original headlamp Darkstar was working well for me and for few of my friends, but the light output was not that high, there were few details I would make different today, etc. Therefore I decided to build another version as my balchelor thesis topic. This time I wanted to get as close as possible to professional lights. So, let's get to the design itself.


Driver schematics

The lamp is using my own design of switching buck current source. The operational principle is similar to one used in previous lamp model.

  • Assume Q3 is opened. Current flows through the coil, LED and R14.
  • When Q3 is closed, current continues to flow through the D4, coil, LED and R14, dropping as the magnetic field around coil collapses.
  • Current flowing through LED is measured by R14, voltage across this resistor (therefore referenced to ground!) is proportional to the current. This voltage is amplified by the opamp U3B (non-inverting amplifier).
  • Amplified voltage is compared with LED1_REF voltage on comparator U4A. R20 and R22 configure the comparator hysteresis. Output of comparator is configured through gate driver back to Q3 gate forming closed loop.
  • Frequency of the loop depends mainly on Vcc, coil impedance and comparator hystersis.

The left image show current through the LED. First the current is slowly rising as the magnetic field builds up, once the threshold is reached, Q3 is closed and current starts to drop. Upon reaching lower limit, the Q3 is opened and cycle repeats. The efficiency of such driver depends on difference between Vcc and forward LED voltage (therefore mainly on switching frequency, which is changing severely with this voltage difference). Lower difference, higher efficiency. Efficiency is low for low LED currents because the MCU and other components consumption is the same magnitude as the LED current. LED forward is not stable, it slowly rises with rising current, reducing the difference between VCC and LED, therefore increasing efficiency. The resistive losses counteract this increase causing slow drop of the efficiency in higher currents region.

I've also measured heating of the drive components and lamp body using FLIR thermal camera (set to maximum current - around 2 Amps per LED, ambient temperature around 25 degrees C). As you can see from the photos, highest temperature on driver board is 67 degrees. As the driver's schottky diode is in small SOD-323 package, it's heating considerably. Second significant heat source is the MOSFET. Some heat is also produced by the coil and current measuring resistor, but it's able to dissipate without any problem.

Most of the heat in the lamp is produced by LEDs. As you can see on the second image, LED temperature reached over 90 degrees C and the body (heatsink) was heated to 60 degrees. LEDs are soldered to aluminium star heatsink, which works well, but could be better. I was experimenting with soldering LEDs directly to the piece of cooper, it worked, but I overheated one of the LEDs in the process and it started to heat much more than before (maybe damaged thermal joint between the semiconductor and the LED package?).

Brain of the lamp is Attiny MCU. It generates reference voltages for two LED drivers (RC filtered PWM signal), processes button presses, etc. As the driver described is not able to work with currents below several dozens mA, I was forced to implement additional dimming to achieve lower light output (camping/tent mode). Additional 100 Hz pwm is turning off the whole driver (by grounding reference voltage of the driver) causing human eye to average the blinking into lower light level than before.

As this lamp was done as a part of my bachelor thesis, I've also designed simple Li-Ion USB charger and protection circuit for Li-Ion battery packs (more details in the links section below)


The software was written in C using avr-gcc compiler and avr-libgc library. I've separated the control logic from lower level functions. Lamp control algorithm can be very simple as lower layers provide functions like counting button clicks and click length, light output control, blinking, etc. This way it's easy to write your very own control logic without much programming knowledge. In the repo I provided simple control algorithm (just browsing the power output levels with two buttons) and more advanced caving version. In the caving version, power levels of both LEDs are programmable and user can cycle through these levels by up and down buttons. By holding up button, it's possible to reprogram the selected mode. By holding up button in power-off state, lamp blinks out remaining battery charge. It's also possible to lock lamp controls by holding down button in off state. To unlock the controls, it's necessary to press up and down buttons several times.


The body is machined on a lathe from 6063 aluminium alloy. No fancy expensive tools except lathe and drill press are required to make the lamp. Top cover is made from polycarbonate sheet, cable and control rods bushings are made from brass. The whole thing is sealed with O-rings.

The battery box was 3D printed from ABS and waterproofed by ABS dissolved in acetone.



As the bare aluminium is not very scratch-proof and I wanted a good looking lamp, I've decided to try hard anodizing at home. Don't try to repeat unless you know what you are doing, hazardous chemicals are used during the process, you can get injured. And always use protection (gloves, glasses/shield) and work in well vented area. So what will you need:

  • 20 % H2SO4
  • 20 % NaOH
  • Easter egg paint in powder form
  • Current source

First find a aluminium wire, cut threads into it and screw into one of the holes on the lamp body. Remove all grease from the aluminium surface and put the lamp into NaOH (use gloves and glasses!) for about 30 seconds. NaOH smooths the surface and removes remaining impurities. Clean in deionised water. Hang the lamp on something and submerge it into the H2SO4. Use aluminium vessel for the acid (old mess tin works well), it will serve as negative electrode. Connect the wire on which the lamp is hanging to positive terminal of your current supply, clamp the negative terminal to the vessel with H2SO4 and set current to about 2 A per square dm of the surface being anodized. Take the lamp out of bath after 45 minutes, wash in deionised water and put into water with egg pain. Heat to 50 degrees C for around 60 minutes and then boil the water for like 15 minutes. That's it. The oxid layer created on surface is scratch resistant.


The whole process of making a new lamp in video below:

Previous Post Next Post