Design, implementation and measurements of the control loop of a digitally controlled constant current boost LED driver

Design, implementation and measurements of the control loop of a digitally controlled constant current boost LED driver

I wanted to experiment with the Bode 100 and measure the control loop of a switched-mode power supply.

To do that, I decided to build a digitally controlled constant current boost LED driver.

The concept is simple, so is the implementation, or isn’t it?

Let’s see what the requirements are and then build it step by step and eventually do some measurements.


Requirements:

  • Battery powered device which can be used as flashlight or headlight for a bicycle
  • The minimum input voltage of the device should be 3.0V ±100mV
  • The maximum input voltage of the device should be 5.0V ±100mV
  • The minimum LED current should be 40mA ±10mA
  • The maximum LED current should be 190mA ±100mA
  • The LED strip must have at least 24 white LEDs of at least 3500mcd each
  • The device must maintain constant current at the LEDs regardless of the input voltage
  • The device should be able to support multiple LED brightness levels, selectable with a button press
  • The device should be able to detect over-voltage and over-current conditions to its output and report error by turning-on or blinking a status LED
  • The device should turn-off its output when the input voltage reaches a low threshold to protect the batteries from deep discharge
  • The device should be able to send all measured analog values to a PC over UART for logging
  • The device should support multiple functions like constant current or fade-in / fade-out sequence, selectable with a button press

So, now that we have the requirements it is time to make some decisions for the required circuits and then start building this device.

The first thing to decide, is what kind of constant current LED driver we have to use. The requirements for the device give us the input voltage range and also give us the minimum number of LEDs. So, I have decided to arrange the LEDs is 8 parallel strips of 3 LEDs in series per strip. That decision led me to the next decision, which is to use a boost converter, to boost the low input voltage to a higher one at the output, in order to maintain constant current at the LED strip.

The next decision to make is which boost driver to use.

I could have used an off-the-shelf LED driver IC, but some of the required functions would have been difficult or even impossible to implement without the use of a microcontroller (MCU). So, the big decision I made is to use an MCU to do everything!


Design and implementation:

Let’s start exploring how this is made and what circuits are needed.

First thing I did, was to calculate the values for the basic components of the boost converter, using the generic equations found on a very interesting application not from TI (SLVA372C). Next, I created a proof of concept simulation circuit for the boost converter with the priviuous calculated component values. The results were very promissing.

No alt text provided for this image

Screenshot of the simulation of the boost converter

The simulation was done using as input voltage 3.3V, which is a typical voltage of 3 AA battery cells connected in series just before their cut-off voltage which is at 3.0V. The simulation results were very good, I was getting an efficiency of 85% which for a self-made boost converter is in my opinion very good.

Next step, I had to decide which control scheme to use and what kind of inputs and outputs I would need for the boost converter.

No alt text provided for this image

Block diagram of the boost converter

Since we now know what kind of DC/DC converter we will use and we also know what kind of inputs and outputs we will need for the converter, it is time to start designing the real circuit.

First, we start off by selecting the MCU, which is the basic component of the device, and then add the peripherals, like status LEDs, buttons, decoupling capacitors etc. Note that I didn’t want to order new components for this project, I wanted to use components that I had in stock.

No alt text provided for this image

Schematic block of the MCU

Next, we need a voltage regulator which will supply the MCU with a stable voltage and also provide the reference voltage to the ADC.

No alt text provided for this image

Schematic block of the MCU supply voltage 

Next step is to design the boost converter and the analog peripherals required for the measurements in order to control it.

No alt text provided for this image

Schematic block of the boost converter and analog peripherals for measuring LED voltage and current

Finally, we need a peripheral circuit which will measure the input voltage of the device. This circuit will be useful to read the battery voltage to protect it from deep discharge.

No alt text provided for this image

Schematic block of the analog peripheral for measuring the input voltage

Now that we have all the schematic circuit blocks, it is time to design a PCB for the custom boost converter and the LED strip board.

et voilà, our PCBs are ready!

No alt text provided for this image

PCBs of the device and the LED strip


The firmware:

A few words for the firmware (FW) that is running on the MCU. It is a bare-metal implementation written in C language. I kept it as simple as possible. All it does is going through some tasks for measuring input and output parameters such as voltage and current and every 1msec it runs the controller task for regulating the LED current. As seen in the block diagram of the boost converter, the used controller is a P-type controller, which all it does is to calculate the error of the measured versus the set LED current and based on that error calculate a PWM value to fix the error. The PWM frequency is 93.8KHz and the resolution is 9-bits. The FW is also responsible for controlling the status LEDs, reading the button and sending to the UART all measured values every 1 second.


Measurements:

So far, we have seen the process of design and implementation of the device. Now, it is time to make some measurements to the boost converter section of the device and decide whether this boost converter is good or not and try to find if there is something that could be done better or in another way.

The first thing I wanted to see was the output current shape of the converter and also the PWM control signal. The output current is measured using an oscilloscope current probe connected to the output of the boost converter and the PWM signal is measured using a 10:1 passive oscilloscope probe attached to the gate of the MOSFET.

The current ripple is noticeable on the oscilloscope but of course not noticeable by the human eye when looking at the light coming out of the LED strip. There is no flickering whatsoever.

No alt text provided for this image

Output current measurement setup and result

The next two measurements were the output voltage shape of the boost converter and the duty cycle jitter. The output voltage is measured using a 10:1 passive oscilloscope probe directly attached to the positive terminal of the output of the converter and the duty cycle jitter is measured at the gate of the MOSFET with the same type of probe but with the persistence of vision setting of the oscilloscope set at 10sec.

The output voltage alike the output current of the converter has a noticeable ripple but again there is nothing noticeable by the human eye while looking at the light coming out of the LED strip. The duty cycle has some jitter, but I will analyze all of these measurements later on, after we will see a few more measurements.

No alt text provided for this image

Duty cycle jitter and output voltage measurements

Next step is to compare the real measurements with the results from the simulation. We are getting close enough values, so everything worked as expected so far. 

Measurements table

No alt text provided for this image

Next measurement, the control loop stability. The following photograph shows the setup used for this measurement. The injection point is on a 10Ω resistor (R10) placed at the output of the op-amp (U1).

No alt text provided for this image

Control loop stability measurement setup

Soon I realized that although I have picked a low impedance point for injecting the disturbance signal from the Bode 100, it was impossible to measure the feedback loop at this point, because the input of the ADC was very sensitive and the injected signal would always overdrive the loop. So, I made a few modifications and then I was able to continue with the loop measurement.

Before we continue further, I should say a few things about the current feedback circuit. It is a non-inverting amplifier which amplifies the low voltage drop across the shunt resistors R4 and R5 by 23 times. The purpose of the removed 470K resistor R7 was to add a positive offset voltage to the input of the op-amp, which of course the FW would remove. This way, having always a positive offset voltage we don’t have to worry about negative offset voltages often found in some op-amps. But for measuring the feedback loop we can remove this resistor and change our injection point without compromising the proper operation of the feedback circuit.

No alt text provided for this image

Modifications for correct loop measurement

After doing all the modifications to the circuit and fine tuning the levels of the injection signal at various frequency’s, I made some measurements at different working conditions of the device.

In the following screenshot of the Bode Analyzer Suite we can see all measurements plotted together. Something very obvious at first glance is that based on the input voltage and the output current we are getting different phase and gain margins, but this is something expected. There is also something like an oscillation around 1KHz, which does not look good.

No alt text provided for this image

Measurements for different working conditions of the device

Let’s have a closer look at one of the above plots and try to find out a few things about this boost converter.

No alt text provided for this image

Loop phase and gain plots for Vin=3.3V and Iout=180mA

The phase margin at this particular measurement is around 61° and the gain margin is at 23dB. The crossover frequency is at 52Hz and we also see some kind of oscillation around 1KHz.


Measurements analysis:

For a constant current LED driver these are not the best results. Although the phase margin is greater than 45° and the gain margin is 23dB meaning that the system is stable, the oscillation that is happening at around 1KHz indicates that the P-type controller implemented in the FW which is triggered every 1msec is obviously very slow in reaction and causes some problems in the loop. Also, the crossover frequency at 52Hz indicates a terribly slow response time. Another thing which is not good is the duty cycle jitter. What is happening is that the output current read task is not working as it should. In more detail, the cause of the problem for the duty cycle jitter is that I have not aligned the ADC measurements with the timer that produces the PWM. So, instead of measuring the output current when the MOSFET is switched-off, it is measured in random positions regardless of the MOSFET state. The result is an average current measurement which is changing every time the read task is running. This result is depending at the condition of the MOSFET at the time that the ADC was measuring the current. The following zoomed-in oscilloscope capture illustrates this problem with the 3 points marked as A, B and C. The ADC current measurements are taken in random positions and sometimes even on these marked points, so the duty cycle is constantly changing and this produces the jitter because the P-type controller is trying to eliminate the error on the read current and keeps increasing and decreasing the duty cycle.

No alt text provided for this image

Zoomed in output current capture

In a better DC/DC controller of this type the LED current should be measured and corrected cycle by cycle and not every 1msec, something that is impossible to achieve with this particular MCU that I have used. Another possible problem of the slow feedback loop is the op-amp that I have used. This op-amp has a gain bandwidth of 14KHz and a slew rate of 3V/ms.


Conclusion:

There are a few things that could be fixed in the FW that would certainly help to have a bit better response on the feedback loop and also to have less jitter in the duty cycle. A better and faster op-amp would also contribute to the overall improvement of the loop response. Also, the current feedback compensator could have been of different type and the MCU could have been a better one with special peripherals for SMPS applications. But nevertheless, the device that I have designed and built is working good enough for my needs and it will definitely serve its purpose as a flashlight. All I need now is a plastic housing for it.

For those interested to see this device in operation, please have a look at my YouTube channel. https://youtu.be/opRdmtkTVdg

Thank you for reading.

Jimmy Daniel

Managing Director @ Jimco Electronics | Power Electronics Engineer

3 年

Thomas Sakaros Thanks sir for this article. Very detailed, and excellent content

Ray Ridley

President Ridley Engineering, Owner POWER SUPPLY DESIGN CENTER GROUP on Linked In

3 年

For a more complete measurement system, try the RidleyBox 4 channel FRA 0.1 Hz to 20 MHz 0 to 4 V source 4 channel 200 MHz oscilloscope Built-in injection isolator 0.1 Hz to 30 MHz Built-in Intel computer Lifetime RidleyWorks license 1 year PSIM license Fully grounded metal case for outstanding noise rejection Support from the best in the industry at Ridley Engineering. www.ridleybox.com

Yusuf Korkmaz

Be your best self !

3 年

Great content Thomas Sakaros can you also share the code of the regulation?

Jimmy Daniel

Managing Director @ Jimco Electronics | Power Electronics Engineer

3 年

Nice Article.Thanks for sharing

要查看或添加评论,请登录

Thomas Sakaros的更多文章

其他会员也浏览了