"smart" Dimmable Constant Current Power Supply for Scrapped 18W LED Lamp

Introduction: "smart" Dimmable Constant Current Power Supply for Scrapped 18W LED Lamp

About: Retired Electronic Engineer, 'reborn' circuit designer after working life in Technical and General Management

Recently I decided to check the reason for the failure of an old outdoor LED lamp that I had set aside.

As I expected, the AC/DC power supply was faulty and, being sealed, not repairable. The data printed on the power supply module indicated that it was a converter from 100-230Vac to 30÷34Vdc at constant current 600mA. This is consistent with the specifications of the lamp that I remembered being 18W.

To provide stable brightness LED lamps need a constant current power supply. In fact, due to the NTC behavior of power LEDs, a fixed voltage source would provide an increasing current up to a potential breaking threshold. Therefore, to test if the LED assembly was still ok, I powered it with my benchtop power supply by setting the max current to about 700mA and then slowly increasing the voltage from 0V until an absorption of 600mA was reached. The lamp was at maximum brightness and the voltage at its heads 31V. After few minutes the current was increasing and I had to reduce the voltage to keep the current at the nominal value of 600mA, confirming the reduction of the load resistance.

Instead of looking for a spare power supply on the market, I decided to build one with cheap and easy-to-find (and probably already available to you) components. With the occasion, I made the lamp "smart", with the possibility of dimming it remotely via Wi-Fi

To explain my project, I divided this instructable into two parts:

  1. In the first one (Step 1) I show how to modify a cheap DC/DC-step up converter into a constant current regulator
  2. In the second part (Step 2 & Step 3) I show how to assemble the whole system, including the software for controlling the unit via Serial interface and Wi-Fi (a basic knowledge of programming an ESP8266 MCU with Arduino IDE is required)

Supplies

The components required for the first part are:

  • 1 x XL6009 DC/DC converter module, like this one
  • 1 x LM358 op amp, you can buy it here
  • 1 x Resistor 100k
  • 1 x 10k 1turn potentiometer, like this one
  • 1 x 0.1÷0.15Ω shunt resistor, you can build it yourself with a short strip of Nichelchromium wire 5.6 ohm/m

And for the second part

  • Digital potentiometer 10k/7 bit code/SPI interface. I used an MCP4132-103
  • an ESP8266 module, like a NodeMCU V3

In addition to this parts you will need a 24V/2A power suplly, usually available to everyone as scrap part from older laptops, PCs, printers, etc.

Step 1: Let's Build the Current Regulator

Inside the dotted frame in the upper part of the wiring diagram is represented the schematic of the XL6009 module (since many different versions are available on the WEB, I personally checked the components and the connections of my sample and I'm pretty sure this is the correct version). From the datasheet of the XL6009 regulator we know that :

VOUT = 1.25V * (1+Rtrim/R)

(Obviously the equation is valid only if VOUT>VIN, because for lower output values L1 and D1 build a direct DC path from the input to the output, which is ok beeing a boost converter).

1,25V is the feedback threshold voltage of the FB pin: in the standard configuration, FB senses the output voltage through the resistor network and regulates it. What we are going to do is simply replace the voltage of the resistive divider with a voltage proportional to the output current.

For this, we must eliminate the 10K trimmer and the 330Ω resistance (see picture) from the module.

To sense the output current delivered by the module we need a shunt, with a value between 0.1 and 0.15Ω. There are several Instructables that show how to build a shunt, I made it with 2cm of the Nickelchromium wire: 0.02m * 5.6 Ω/m = 0.112Ω. Unfortunately the Nickelchromium wire cannot be soldered and must connected mechanically (either crimped or screwed), this adds few mΩ and the final value of my sample is 0.135Ω which is fully acceptable. Given the max output current of 600mA the voltage over the Rsense shunt is:

Vsense = 0.6A * 0.135Ω = 81mV.

This voltage is amplified by the LM358 op amp (powered by 3.3V ext. voltage source), whose gain is:

G = (1 + R2/Rtrim1)

Remembering that the FB threshold voltage is 1.25V, if we connect the output of the op-amp to the FB pin (or better to the left pin of the removed trimmer, see picture) we can stabilze the output current according te equation:

Iout = 1.25/0.135(1+100/Rtrim1)

which is mathematically an hyperbolic function, but in the range of our interest is continuous and gives the following values:

Iout = 0.6A / Rtrim1 = 6.93kΩ

Iout = 0.3A / Rtrim1 = 3.35kΩ

or inversely:

Rtrim1 = 3.00kΩ / Iout = 0.27A

Rtrim1 = 7.00kΩ / Iout = 0.61A

With the breadboard prototype I've assembled (see picture) and an ammeter in series with the load I have measured

I = 0.6A with Rtrim = 7.32kΩ

I = 0.3A with Rtrim= 3.48kΩ

which, given the overall tolerances, wirings' resistances and offset of the op-amp, is consistent with the theory.

Once set, the current value remains very stable against load and input voltage variations

Step 2: Assembling and Testing the Whole System

Now that we know how to control the output current by varying a resistance we can make the system "smart" by replacing the Rtrim1 potentiometer with the digital potentiometer MCP4132 (U1). In the picture I have also raplaced the former screwed connector fixing of the shunt with a simpler crimped version. The digital potentiometer is controlled by the ESP8266 NodeMCU module via the SPI interface. The system is powered through the USB programming port, or in stand-alone mode by an external standard mobile phone power supply connected to Vin. The LM358 op-amp and the digital potentiometer are powered by the 3.3V on board regulator of the NodeMCU.

On the site "RANDOM NERD TUTORIALS" you can find a comprehensive collection of tutorials for ESP32 and ESP8266 based modules, which I used for the development of the code (thank you Rui Santos!).

To test the system I first developed the simple sketch "NodeMCU_MCP4132" that allows you to set the wiper of the potentiometer with a 7 bit code ("potVal") through the serial interface, according the equation:

R = 10KΩ* potVal/127

In accordance with the measures indicated in Step 1, I obtained (see pictures):

potVal = 94 ==> R = 7.3KΩ ==> Iout = 0.62A

potVal = 45 ==> R = 4.5KΩ ==> Iout = 0.31A

potVal = 1 ==> R = .08KΩ ==> Iou t= 0.01A

Step 3: Remote Control With a Slider

This last step shows how to build an ESP8266 NodeMCU web server with a slider to control the LED brightness.

The sketch I developed ("NodeMCU_Gropparello_AP") is based on the Random Nerd Tutorial "ESP8266 NodeMCU Web Server with Slider: Control LED Brightness (PWM)" with just a couple of changes I introduced to adapt it to my project:

  1. Since I intend to install the system and the LED lamp in a location not reached by any Wi-Fi network, the ESP8266 is set here in "access point" mode instead of "station". This means that the MCU will act as a web server that can be accessed by a client (e.g. a smartphone, tablet or PC) over Wi-Fi, however no internet connection is available
  2. The brightness control is done by setting the values of the digital potentiometer instead of the values of the PWM duty cycle
  3. For the same reason, the range of the slider is defined between 1 and 100 (remember, the max current of 0.6A in my protoype is reached with potVal=94) instead of 0 to 1023

The original tutorial explains in detail how the code works and how to access the server through the browser of the smartphone or PC. The slider will show up on your device, and moving it the you'll see the LED lamp increasing and decreasing its brightness (in the video this is poorly appreciable because of the automatic light adjustment of the camera, but you can clearly read in the ammeter the current variation).

Step 4: Conclusion

I hope this Instructable can be helpful to understand and apply cost-effectively some basic concepts such as constant current power supplies, current measurements and SPI interfacing for the ESP8266 (not many valid examples can be found on the WEB for the latter).

Of course, the project must be finalized with an appropriate PCB and an eclosure where the power supplies can also be inserted. In addition, other functions could be added, such as a twilight switch by connecting an LDR to the analog input of the ESP8266, and other sliders to control other lights, etc., but maybe all this will be the subject for a future Instructable...

That's all for now, thanks for reading my Instructable, comments and questions will be welcome.

Be the First to Share

    Recommendations

    • Meatless Challenge

      Meatless Challenge
    • Fabric Challenge

      Fabric Challenge
    • Remote Control Contest

      Remote Control Contest

    Comments

    0
    bobjames
    bobjames

    7 months ago

    That's a lot of messing around and cost for little gain . I power all my security lights ,I have about 20 , with 27 volt lithium battery packs . Lifepo4 if I can get them (8 cells) or Li-Ion (6 or 7 cells) . Fed with over 25 volts DC they work fine and a household standard solar panel and cheap charge controller keep the battery charged up so its off grid and independent too.

    Fit a 24v motion and daylight combined sensor and its movement activated only at night. They cost about $2 USD.