Introduction: Dupin - an Ultra-low Cost Portable Multi-wavelength Light Source

Named after Auguste Dupin, considered to be the first fictional detective, this portable light source runs off any 5V USB phone charger or power pack. Each LED head clips on magnetically. Using low cost 3W star leds, actively cooled by a small fan, the unit is compact but offers a wide range of high intensity wavelengths. Of course, it also supports white LEDs for full-colour illumination.

The images here show output at 415nm, 460nm, 490nm, 525nm, 560nm and 605nm.

However the LEDs used are 365nm, 380nm, 415nm, 440nm, 460nm, 490nm, 500nm, 525nm, 560nm, 570nm, 590nm, 605nm, 630nm, 660nm and 740nm. Also shown are a 'daylight white' LED and a PAR full-spectrum LED which produces a pink light with no green component, intended primarily for horticultural applications.

Powered by a low dropout voltage precision constant current source, the unit offers 100 brightness settings via a rotary encoder and saves the last brightness setting when powered off, thus returning automatically to the last brightness setting when turned back on.

The unit does not use PWM to manage brightness so there is no flicker, facilitating its use in situations where you want to photograph or video images without artifacts.

The constant current source features a wide bandwidth amplifier and output stage, permitting linear or pulse modulation up to several hundred kilohertz or even for pulse modulation up to nearly one megahertz. This is useful for fluorescence measurement or for experimenting with light data communication etc.

You can also use the constant current source to drive multiple LEDs. For example, using a 24V power supply you could drive 10 red LEDs with a voltage drop of 2.2V per LED.

Note that you still power the main control circuit with 5V in this scenario, but connect the collector of the power transistor to a higher voltage. For more information see the last step in this instructable

Applications include forensics, microscopy, document examination, stamp collecting, entomology, mineral fluorescence, UV, IR and visual photography, colorimetry and light painting.


In almost all cases these are the suppliers I actually used, apart from the odd seller who no longer stocks that item or is not on eBay/Amazon any longer.

This list covers most of the items you need, excluding wire, 2.5mm male power plug, and machine screws.

20mm heatsinks for the LEDs

Most of the 3W LEDs are supplied by

FutureEden also supply the LED lenses which are available in a range of angles including 15, 45 and 90 degrees. I used 15 degree lenses in the prototype.

560nm and 570nm LEDs

490nm LEDS

365nm LEDs

D44H11 power transistor

5mm shelf pins

Fan and heatsink


Magnetic connectors

2.5mm female power socket

BAT43 Schottky diode

Small signal transistor kit (incl BC327/337 used in this project)

Rotary encoder (the seller I used is no longer on eBay but this is the same unit)

X9C104P (this is from a different seller)


USB current monitor (optional)

Step 1: Case Assembly

The main unit case and LED head are 3D printed. A small flat backplate attaches to the rear of the case to support the encoder. Power is supplied via a standard 2.5mm power socket. A standard USB lead is cut up to make the power lead.

All items are printed in PLA with 100% infill and a layer height of 0.2mm. The STL files are included as attachments.

Print the case assembly vertically with the rear of the case on the baseplate. No supports are required.

Step 2: LED Head Assembly

Each LED head assembly comprises two 3D printed parts, the upper head assembly and the back fastener plate. Print these in PLA at 100% infill and 0.2mm layer height. No supports are required. The back fastener plate should be printed with the flat rear surface touching the baseplate.

Note that the stl images shown previously have the backplate oriented 180 degrees out - the flat side is the outer surface of the backplate when you bolt things together.

Each head assembly then has a 20mm x 10mm heatsink with the LED attached press fitted into the upper assembly. The photographs show how to assemble it. Start by peeling the paper off the adhesive pad and stick the LED on, taking care to keep the LED heatsink fully within the 20mm heatsink outline.

Then solder two wires to the LED and then push the heatsink into the upper head assembly, taking care to ensure that the heatsink fins are oriented as shown in the photos. This is to maximise the airflow for cooling.

Once you have the heatsink fitted, pull the wires through and cut off as shown in the photo, leaving about 3/4 inch of wire. Strip and tin the ends of the wires.

The LED head connects to the case via two pins which are made from nickel plated steel shelf pins. These are perfect for the job as they have a flange that lets us lock them in place.

Using a larger diameter chisel soldering iron tip, tin the top of each pin. Hold the pins in a vice or ideally one of those little workbench gadgets as shown - they are very handy for making cables as well.

Then attach the wires to the pins, ensuring the wire points straight up, as shown. Allow to cool.

When the pins have cooled, attach the back fastener plate using 2 X M2 12mm machine screws and nuts. Ensure before you do this that the back plate mounting holes have been cleaned with a twist drill or taper reamer. The steel pins should be able to wobble slightly. This is important to ensure that the magnetic contacts are reliable.

Note: I used nylon screws and nuts for some units and then steel ones for the others. The steel ones probably need lock washers as well as they otherwise have a tendency to come unscrewed over time; nylon screws tend to have more friction and this is less of an issue.

Optionally, clip on a lens to the LED if you want to collimate the beam, which is otherwise pretty broad.

Step 3: Main PCB

The main circuit board is constructed using a 30 x 70mm matrix board. These are widely available, high quality fibreglass boards with a 0.1 inch matrix of through-plated holes.

The point-to-point wiring uses so-called 'pencil wire' which is approximately 0.2mm enamelled copper wire. The insulation melts with a normal soldering iron tip.

The rotary encoder is soldered directly to the end of the board. Note that the encoder pins are wired to the bottom of the board.

In the steps below you will build individual parts of the whole circuit and test them before continuing. This ensures that the finished circuit board should function correctly.

The photographs show the board during assembly. The pencil wire can be seen on the back side, connecting most components. Thicker wire is used where higher currents are involved. Some clipped off component leads are used to make a power and ground rail at the top and bottom of the board.

Note: space is tight. Mount resistors vertically to conserve space. The layout here 'evolved' as the board was assembled and I was a bit optimistic about the required space and should have mounted all the resistors vertically and not horizontally as shown.

Connections are made using 'veropins' but you can also use a loop of component wire, with the ends splayed underneath; however this does take two holes per connection rather than one with a pin.

Step 4: Encoder Circuit

I have drawn out the circuit as several separate schematics. This is so that you can clearly see what each part does. You should construct the circuit in steps, testing that each part operates correctly before adding the next part. This ensures that the whole thing will function correctly without a lot of tedious troubleshooting.

Before I start, a word about soldering. I use leaded solder, not unleaded. This is because unleaded solder is much harder to work with in hand soldering scenarios. It tins poorly and is just generally a pain. Leaded solder is quite safe and you will not be exposed to any dangerous fumes while working with it. Just use common sense and wash your hands after soldering and before eating, drinking or smoking. Amazon sell good quality rolls of fine-gauge leaded solder.

The encoder interface

This is quite simple. The encoder has three pins, A,B and C (common). As you can see, we ground the C pin and we pull up the A and B pins via 10K resistors. Then we add 10nF capacitors to ground to smooth out contact bounce, which can cause erratic operation.

The A and B pins then connect to the INC and U/D pins on the digital pot IC. (X9C104). Connect up this circuit and wire up the X9C104 power and ground pins as well. Add the 470uF and 0.1uF power decoupling capacitors at this time also.

The encoder pins should be soldered to the bottom of the circuit board; the hole in the backplate will then line up with the encoder shaft.

Temporarily wire the CS pin on the X9C104P to +5V. We will be connecting this up to another part of the circuit later on.

Now connect 5V to the circuit and using a meter, verify that the resistance between the H and W pins on X9C104P changes smoothly between almost 0 ohms and 100K ohms as you rotate the encoder.

Step 5: Constant-current Power Supply Circuit

Once you are confident that the encoder circuitry is working, it's time to build the constant-current power supply section. Connect the TLV2770 op-amp power and ground and then wire as shown, connecting up to the H,W and L pins of the X9C104P.

Ensure that you connect the 0.1 ohm current sensing resistor directly to the ground pin of the TLV2770 and then 'star' connect the remaining grounded components to this point (1N4148 cathode, 10K resistor, 0.1uF capacitor). Then connect this ground point to the ground rail on the circuit board. This ensures that small resistances between the ground rail and the current sensing resistor don't get seen by the opamp as erroneous sense voltages. Remember that at 750mA the voltage across the 0.1 ohm resistor is only 75mV.

Temporarily connect the SHDN line to +5V. We will be connecting this up to another part of the circuit later.

The cooling fan we are using is intended for a Raspberry Pi. It comes, conveniently, with a set of heatsinks, one of which we will use for the main power transistor.

The D44H11 power transistor should be mounted at right angles to the board, stuck to the largest heatsink that comes with the Raspberry Pi fan kit.

The 680K resistor may need adjusting to ensure that the maximum current through the LEDs is no more than 750mA.

Connect +5V again and a power LED, mounted on a heatsink. Now verify that you can smoothly change the current through the LED by rotating the encoder. The minimum current is chosen to be approximately 30mA, which should be sufficient to ensure that most 5V mobile phone power packs will not automatically shut down at minimum brightness.

The optional USB current monitor is a useful accessory here, but if you use it you'll obviously have to make the power lead first, as discussed in the section later on.

Note: the shorter wavelength LEDs will get quite hot at high current as we aren't yet fan-cooling the heatsink, so keep run time fairly short (couple of minutes) during testing.

How it works: the voltage across the current sensing resistor is compared to the reference voltage. The opamp adjusts its output to ensure that the two inputs are at the same voltage (ignoring the input offset voltage of the opamp). The 0.1uF capacitor across the digital potentiometer serves two purposes; it filters out the 85KHz charge pump noise from the X9C104 device and it also ensures that at power up the demand current is zero. Once the opamp and feedback has stabilised, the voltage across the capacitor will rise to the demand voltage. This prevents turn-on current spikes through the load.

The D44H11 transistor was chosen because it has adequate current ratings and a high minimum gain of at least 60, which is good for a power transistor. It also has a high cutoff frequency which facilitates high-speed modulation of the current source if needed.

Step 6: Power Management Circuit

The power management circuit primarily turns the momentary action push switch on the rotary encoder into a toggling power switch.

BC327 and BC337 transistors are used because they have fairly high gain and a maximum collector current of 800mA which is handy for the fan switch where the fan draws around 100mA. I purchased a cheap kit of miscellaneous small signal transistors which include a wide range of useful devices. Note that in the prototype these transistors have the -40 suffix indicating the highest gain bin. While I doubt this matters much, and you should get similar devices if you purchase the same kit, just be aware of this.

Power is controlled by toggling the SHDN pin on the TLV2770 opamp. When the SHDN pin is low, the opamp is disabled and when it is high the opamp operates normally.

The power management circuit also controls the CS line on the X9C104 digital potentiometer. When power is turned off, the CS line goes high, ensuring that the current setting of the pot is written back to its non-volatile flash memory.

How it works: initially the junction of the 100K resistor and the 1uF capacitor is at +5V. When the momentary switch is pressed, the high level voltage is transferred via the 10nF capacitor to the base of Q1, which turns on. In so doing it then pulls the collector low and this causes Q2 to be turned on as well. The circuit then latches on via the 270K feedback resistor, ensuring that Q1 and Q2 both remain on and the SHDN output is high.

At this point the junction of the 100K resistor and 1uF cap is now pulled low by Q1. When the momentary switch is pressed again therefore, the base of Q1 is pulled low, turning it off. The collector rises to +5V turning off Q2 and the SHDN output now goes low. At this point the circuit is back to its initial state.

Assemble the power management circuit and connect the momentary switch on the encoder to it. Verify that SHDN toggles each time you press the switch and that when SHDN is low, CS is high and vice-versa.

Temporarily connect the cooling fan to the collector of Q3 and the +5V rail (which is the positive lead from the fan) and verify that when SHDN is high, the fan turns on.

Then wire the power management circuit into the constant current power supply and connect CS to the X9C104P digital potentiometer, removing the temporary ground link. Connect SHDN to the TLV2770 and also remove the temporary link to that pin.

You should now be able to confirm that the circuit powers up correctly and turns on and off when the encoder switch is pressed.

Step 7: Fault Protection Circuit

Like most constant current power supplies, there is a problem if the load is disconnected and then reconnected. When the load is disconnected, Q4 saturates as the opamp attempts to drive current through the load. When the load is reconnected, because Q4 is fully on, a high transient current can flow through it for several microseconds. While these 3W leds are fairly tolerant to transients, they still exceed the datasheet ratings (1A for 1ms) and if the load were a sensitive laser diode it could easily be destroyed.

The fault protection circuit monitors the base current through Q4. When the load is disconnected this rises to approximately 30mA, causing the voltage across the 27 ohm resistor to rise sufficiently to turn Q5 on and this in turn causes Q6 to turn on and its collector then drops to nearly ground. The schottky diode (chosen because its 0.4V forward voltage is less than the 0.7V required to turn a transistor on) then pulls the FLT line low, turning off Q1 and Q2 and thus shutting down power.

This ensures that the load can never be connected with power on, avoiding potentially damaging transients.

Step 8: Assembly

Solder the magnetic couplers to a short length of reasonably stout wire (about 6 inches long), ensuring the wire will fit through the holes in the case.

Ensure the case holes are clean - use a twist drill to ensure this, and a smaller drill to ensure the wire holes at the back are also clean.

Now using a LED head, clip the couplers to the head pins and insert into the case. The LED head should fit so that when you look at the keyway, there's a tiny gap between the keyway and the case. Once you're confident that the couplers are fitting correctly, place a small drop of epoxy on the rear of each one, and insert with the LED head and place it somewhere out of the way while the glue hardens. I wired my LED head assemblies so that with the backplate of the head assembly facing towards you and the keyway pointing up, the positive connection is on your right side.

Once the glue has hardened, remove the head and then fit the fan, with the label visible, i.e airflow is pushing air over the head heatsink. I used two M2 X 19mm machine screws and a nutdriver to mount the fan, it's fiddly but slide it in from the case rear and then you should be able to get everything lined up and fastened.

Now you can mount the 2.5mm power socket, and connect all the wires to the PCB, leaving enough slack so that you can easily wire it up then slide it into the case on the rails printed into the case.

The rear plate assembly is fastened with four small self-tapping screws. Note that the encoder shaft position isn't quite centred on the plate so make sure you rotate it until the screw holes line up.

Step 9: USB Power Cable

The power cable is made from a cheap USB cable. Cut the cable about 1 inch away from the larger USB plug and strip it. The red and black wires are power and ground. Connect some thicker figure 8 cable to these, using heatshrink to insulate, and then at the other end solder a standard 2.5mm power plug.

We cut the USB cable short because the leads are too thin to carry the current and will drop too much voltage otherwise.

Step 10: Modulation Option and Fibre Coupling

To modulate the current source, disconnect the 0.1uF capacitor and W pin from the non-inverting input on the opamp and connect that input to ground via a 68 ohm resistor. Then connect a 390 ohm resistor to the non-inverting input. The other end of the resistor is then the modulation input, with 5V driving the LED to full current. You could fit a couple of jumpers to the board to facilitate changing over from the encoder to external modulation.

You can use the STL from the Angstrom project for the 3mm fibre couplers if you want to connect the LEDs to fibre e.g for microscopy etc.

Step 11: Powering Multiple LEDs

You can use the constant current driver to drive multiple LEDs. LEDs cannot be connected in parallel as one LED would take most of the current. Therefore you connect the LEDs in series and then connect the anode of the top LED to an appropriate power source, leaving the main control circuit still running on 5V.

It's easier in most cases just to use a separate power supply for the LEDs and leave everything else running off a standard phone charger.

To calculate the voltage, take the number of LEDs and multiple by the voltage drop for each LED. Then allow around 1.5V margin. For example, 10 LEDs with a voltage drop of 2.2V each require 22V so a 24V supply would work well.

You need to make sure the voltage across the power transistor isn't too high as otherwise it will get too hot - as designed here it drops nearly 3V in the worst case scenario (driving an infrared LED with a low forward voltage) so this is the maximum you should aim for unless you want to use a larger heatsink. At any event I would keep the voltage less than 10V because you're starting to get into current limitations based on the transistor safe operating area.

Note that the shorter wavelength emitters have higher forward voltages, with the 365nm LEDs dropping nearly 4V. Connecting 10 of these in series would drop 40V and a standard 48V power supply would require a larger heatsink on the power transistor. Alternatively you could use several 1A diodes in series with the LEDs to drop the extra voltage at 0.7V per diode, say 8 to drop 5.6V and then this leaves only 2.4V across the power transistor.

I would be wary of using higher voltages than this. You are starting to get into safety issues if you come into contact with the power supply. Ensure you fit an appropriate fuse in series with the LEDs; as designed here, the 5V power supply has safe current limiting and we don't need one but in this scenario we would certainly want protection against a short circuit. Note that shorting out a string of LEDs like this will probably result in a fairly spectacular meltdown of the power transistor, so be careful!. If you want to power more LEDs, you probably need a parallel set of current sources. You could use multiple copies of the constant current driver (along with its own fault protection circuit) and share a common encoder, power control circuit, and voltage reference between them, each copy will have its own power transistor and drive, say, 10 LEDs. The whole circuit can be paralleled because the constant current drivers are each handling one string of LEDs in that scenario.

Indoor Lighting Contest

Participated in the
Indoor Lighting Contest