Showing posts with label LED. Show all posts
Showing posts with label LED. Show all posts

Sunday, July 6, 2025

Another dimmable LED controller - hacking a switch mode mains power supply

In this blog post, I modified a cheap buck converter module to add a brightness control, and used it to drive a relatively low power strip of cool white LEDs.

I was never a big fan of the cool white LEDs I had ordered the first time round, and Chinese LED strip tech had also come some way since I did that first installation, so I thought it would be a good opportunity to upgrade to some 24V Chip-on-Board (COB) LED tape in a warmer colour temperature.

The new COB tape is a lot denser than the old surface mount LED tape and has a much higher maximum brightness, but the power requirements have also gone up dramatically if you want to use the full brightness. About 100 watts in fact, from a fixed 24 volt supply, for 20 metres of LED tape.

For this one, I decided that due to those requirements, it would be more efficient to adjust the switch mode power supply directly instead of adding an extra output stage like last time. The candidate for the mod was this chunky 120W power supply:

Large power supply brick with cover removed

Sadly, this power supply didn’t have an internal trimmer pot, so it wasn’t a simple case of replacing that with an off-board pot. On the upside, the low voltage and mains sections were well separated, but of course extreme caution should always be used when working on a device like this and you should avoid carrying out any work on it while it is plugged in.

Like with the buck module from part 1, the objective was to add some control over the feedback circuit. I examined the PCB and determined that the core of the feedback circuit in this power supply is the 8-pin IC in the photo below, which is a TSM103WAIDT dual op-amp with built in 2.5V reference. Just like with the buck modules, there is a resistive potential divider and the circuit tries to make the output of the potential divider equal the reference voltage of 2.5V in this case.

This area of the circuit looks quite complex; I believe it also implements overcurrent protection and overvoltage protection, but I didn't take the trouble to trace it all out.

Low voltage section of the power supply PCB viewed from the solder side

Original feedback circuit resistors:
24.9k high side
2.87k low side
2.50V output from 24V input

I played around with the values in the same spreadsheet from before…

Resistor calculation spreadsheet

…and eventually arrived at the following configuration: I changed the high side to 10K + 7.5k in series, and retained the original 2.87k on low side, but added a 6.8k fixed resistor and 22k pot series combination in parallel with the 2.87k. New output range 19.26V to 24.17V.

Here’s a short video of the modified power supply in operation:

I somehow damaged the op-amp during my experimentation and had to replace it. Fortunately it was still made after all this time, but the op-amp is end of life now.

With a hole drilled in the case for the pot and a knob fitted, it looks very professional!

Photo of assembled power supply with brightness control knob

The dimming control works well with the LED light strips. This power supply doesn't seem to give a stable output voltage at very low loads, as it seems to have a discontinuous switching mode to save power when the original load (computer monitor) was in standby; this causes the LED strips to blink a few times a second when the brightness is turned all the way down. In the final installation, the large dot matrix clock is also powered from the power supply output (it has its own buck converter to generate its 5V power supply so adjusting the supply voltage doesn't affect it) and this additional load prevents the blinking from happening.

Demonstration of final installation

Tuesday, April 22, 2025

A very simple no-PWM LED lighting controller

In this blog post, I created an LED lighting controller for common 12V LED tape which was installed outdoors. I wanted to install some more LED tape but indoors, and this also needed its own controller but with different requirements to the first installation: there was no longer any need for the daylight sensor or the timer, but the ability to continuously adjust the brightness was required.

The lighting was installed as shown in the photo below.

As before, a PWM-free implementation was desired, and the idea of adding components to the feedback circuit of an LM2576 switching regulator module was chosen as the solution again.

The potentiometer was wired into the feedback circuit of the switching regulator circuit. However, it cannot simply be used as a direct replacement for the feedback potential divider, because only a limited portion of the potentiometer wiper will correspond to a useful range of voltages, and it will be possible to turn the voltage up above 12V and damage the LEDs. A combination of series and parallel resistors are added to achieve the desired voltage range.

The LEDs were powered from a bench power supply and the voltage range from nearly off to full brightness was determined to be 7V to 12V. The surrounding resistors would therefore need to be calculated so that the output voltage of the regulator is 7V when the potentiometer is turned to the left or 12V when turned to the right. It was also assumed that the potentiometer would be part of the low side of the resistor divider; this ensures that the voltage cannot jump up above the designed maximum in case the potentiometer gets dirty and goes high impedance.

The final circuit with calculated resistor values is shown below.

The procedure for working out the correct resistors to add to the circuit is very much experimental but I made a spreadsheet to make this task much easier. The numbers for R2, R1-Par and R1-Ser were changed repeatedly until the desired output voltage range was achieved. Once the ideal value of 73k for the upper resistor was found, this number was simply stuck into one of the many E12/E24 resistor finders available online to get the 4.7k + 68k series combination which would be used on the real hardware.

A small project box was chosen to house the circuit. Holes were drilled for the potentiometer, DC jacks, switch and cable. It was swiftly discovered that the two large capacitors on the power supply module were too tall to fit in the case, so these were desoldered and new low profile capacitors were soldered to the back side of the module, where they fit well in the case either side of the potentiometer.

The whole assembly was mounted to a bookcase and a potentiometer knob added to finish it off.

Monday, May 2, 2022

Outdoor LED lighting controller

Introduction

This is a simple project which is a lighting controller for the inexpensive LED tape which is widely available from marketplace sites and is designed to be powered from 12V.

LED tape lights

The requirements for this project were:

  • Automatically turn the LEDs on at dusk and turn them off at dawn
  • Run the LEDs at a dim brightness during normal operation, or at high brightness when high brightness mode is enabled
  • Have a button for selecting high brightness mode. High brightness mode shall automatically be turned off after a time period
  • Have good efficiency

Preliminary testing

Prior to building the controller, the waterproof LED tape was installed as desired around the outside of my house. Around 8 metres of LED tape was installed in three separate lengths and mains flex was wired between each of the three runs and a central location where the controller will be installed along with its light sensor.

The LED tapes were all connected to a bench power supply in parallel for testing.

At the design voltage of 12V, the LEDs are at full brightness and consume around 2A of current for a total of 24W of power. The LEDs are quite bright at this power and the brightness is far too excessive to be used all night, not to mention the high operating costs over the long term.

The voltage was turned down until a sensible brightness for all-night operation was found. This was found to be in the range of 7.90V to 8.10V, with the current varying from 0.05A to 0.10A, and the power from 0.395W to 0.810W. With this in mind, a target voltage of 8.00V was chosen, which should result in a power consumption of only 0.6W (plus overheads from the mains power supply), resulting in low running costs.

Design

The power section of the design was be based around one of the inexpensive and widely available LM2576 buck converter boards. The board was modified to replace the trimmer potentiometer with fixed resistors to avoid future unreliability, and the Enable pin was carefully desoldered from the PCB so that it could be externally driven. A connection was also added to the feedback junction so that an extra resistor could be wired in parallel with the main resistor; this would form the basis of the brightness selection, where this resistor can be left floating or shorted to GND via a transistor to modify the lower resistance value in the feedback network and hence change the output voltage of the buck converter.

Originally I planned to use a comparator wired as a schmitt trigger to control the Enable pin and a 555 timer in monostable mode to control the high brightness mode, but I decided to change to a microcontroller to allow more flexibility and make it easy to implement multiple time-out periods for the high brightness mode which can be stepped through by pressing the button repeatedly. I used a PICAXE-08M (educational microcontroller) since I already had a few, but a bare PIC or ATtiny would also work well.

Schematic

Hardware

I built most of the circuit on stripboard and placed all the components to allow it to fit inside a plastic case.

Some extra resistors have been used in the feedback network compared to the schematic to trim the output voltage more accurately. Polyfuses were also added to each of the three outputs to provide independent short-circuit protection for each channel, which I thought would be a good idea given that the lights are outside.

Assembled project
Interior of the project

The case was screwed to the wall and the LDR was positioned where it could be illuminated by light from outside without being illuminated by very much from the lighting it controls, and it works very well.

Sunday, July 11, 2021

Animated dot matrix display radio-controlled clock

First completed: May 2013

Small dot matrix display hardware

Introduction

This project was my first attempt at driving a dot-matrix LED display from a microcontroller without using any dedicated driver chips. It was also, at the time, my most advanced PCB design. Prior to this project, the most complex LED multiplexing I had done directly from a microcontroller was a 6-digit 7-segment display, which in terms of complexity is equivalent to a single 8x6 LED dot matrix.

I decided to use an ATmega328p pre-programmed with the Arduino bootloader for this project.

Hardware

The main elements of the design are the microcontroller with its supporting components, the displays with their shift registers (these are hidden behind the displays on the PCB), and a switching regulator.

The schematic below shows the design excluding the switching regulator.

Schematic

The shift registers are a serial-in-parallel-out type, and were needed because the ATmega328p does not have enough pins to drive the display directly. The shift registers are 74HC164, as with the Noughts and Crosses game.

The PCB layout was done by me, but the board itself was made by a third party. The PCB was made on a PCB router and the board is not through-hole plated - I learned a very important lesson here as to why through-hole plating is usually important. The design relied on through-hole connections being connected to both sides, so it was necessary to solder some of the pins on both sides to simulate through-hole plating.

Software

The LED displays are multiplexed. Only one row of the display is lit at a time; each row is switched on in turn very rapidly, and this technique relies on persistence of vision to make it look like the entire display is continuously lit.

The animation below shows the technique in action but for column scanning.

Multiplexing animation

Initially, the software was a simple design which just used delays in the main loop of the code to switch between the rows. This method works reasonably well on the ATmega328p at 16MHz because it can execute instructions fast enough to avoid functions in the main code from having a visible effect on the display, but it makes writing the code more difficult because delays and "slow" commands cannot be used. The software design was later enhanced by using a timer interrupt to run the display software, making its timing independent of what happens in the main code.

The display shows the time, and a scrolling effect is used whenever a digit changes. The time is synchronised using a "Time from NPL" receiver, the signal from which is decoded by the software. The use of the timer interrupt for driving the display, the author's extra experience with using the ATmega328p, and the removal of the external RTC allowed the time decoding to be done without the extra microcontroller that was used in the 6-inch jumbo radio-controlled LED clock/timer project.

Saturday, March 20, 2021

Noughts and Crosses Game

First completed: 2011

Introduction

This is a simple electronic game that I made as part of my Art & Design GCSE at school back in 2010/11. The Art & Design GCSE allows creations made from non-traditional materials, and they can even be electronic, as long as they are arty in some way. This project was inspired by Damien Hirst's spot paintings, and uses LEDs to illuminate each of the "spots" a different colour to represent each player.

Pressing the New Game button will start the game. The colour of the player who goes first is random. The game is purely multiplayer and has no AI. Each player takes it in turns to select their spots, and the game ends once the board is full or there are three spots of the same colour in a row.

Construction

The game is constructed on a single-layer board made on the school's simple PCB production facilities - the board was exposed to UV, etched in a tank, and hand-drilled by myself. The front panel is made out of thick card, and the filling is made from foam which has been cut to shape. The buttons are made from stack of different sized cardboard rings which have been glued together so that they can move enough to press the buttons on the PCB but are retained by the front panel. A sheet of tracing paper covers the front and enables the LEDs to produce evenly-coloured spots when lit.

Picture of the Noughts and Crosses Game
Front view of the buttons
Side view of the buttons

Electronics

The game uses a PICAXE-18M2 microcontroller, which is a PIC microcontroller pre-programmed with a BASIC interpreter specifically for the educational market. As a result, it's slow, but it's fine for this application. The 3.5mm jack is used to program the PICAXE microcontroller using a serial cable.

The other DIP ICs on the PCB are serial-to-parallel shift registers which are responsible for driving the LEDs. The only multiplexed part of the design is the matrix keypad. Note that with more programming skill (and probably a faster microcontroller than the PICAXE), the LEDs could have been multiplexed as well, eliminating the need for the external shift registers, but the PICAXE is missing more advanced microcontroller features like timer interrupts (except on larger devices), which would have made multiplexing the LEDs more complex.

A simple 5V linear regulator is used to supply power to the microcontroller from the user's choice of a 9V battery or external DC power supply.

The PCB was originally designed to use 4-pin buttons throughout, but the buttons needed to be substituted with 2-pin buttons so some jumper wires had to be added.

Front view of the PCB
Rear view of the PCB

Another dimmable LED controller - hacking a switch mode mains power supply

In this blog post, I modified a cheap buck converter module to add a brightness control, and used it to drive a relatively low power strip ...