# PID controller for current control by adjusting the PWM

• Hubert Tchio
R4.In summary, This circuit regulates LED current directly, not LED voltage. It is a free running PWM that maintains the LED current at 1 amp. The design is efficient, with efficiency greater than 60%.f

#### Hubert Tchio

Hi,
I'm a starter here!

I am trying to build a buck converter without the use of any IC. I want to drive a single LED. Here are some calculated data: Vin =5V, Vout =3.225V, Duty circle = 0.651, L=6.8micro Henri, Switching frequency = 1.4Mhz, Desired current is 1A, I also assume ripple current of 0.3+ desired Current. I am using 2 Mosfet to reduce power loss.

(Source of information: http://simonthenerd.com/files/smps/SMPSBuckDesign_031809.pdf [Broken])

I have built the circuit with some components from Texas Instruments (The design is done with Pspice), everything seems to be ok. But this brings me to my first question, how can I determine the minimum PWM frequency from my calculated switching frequency? Because I will have to design a PWM generator for powering the Mosfets.

I understand, since my load (LED’s resistance) is constant changing the voltage means changing the current (ohm’s law). I therefore want to control the current by adjusting the pulse width of the PWM. For this I want to use a PID controller. How can I do this? Can someone help me please?

Hint: Here attached is a block diagram of what supposed to be my desirer! (Please correct me if I am wrong). I don’t want to have anything to do with digital but complete analogue!

#### Attachments

• PID controller and PMW.pdf
96.9 KB · Views: 857
Last edited by a moderator:
Welcome to PF.
I am trying to build a buck converter without the use of any IC.
A power MOSFET is an IC.

I don’t want to have anything to do with digital but complete analogue!
Digital is analogue.

Why do you need a PID controller? Is the current always 1 amp? For a LED you need a constant current, not a constantly changing voltage. You could build a very simple switching current regulator. Attached is a circuit for a free-running PWM current regulator.

Hi Baluncore,

thanks for your reply, I know MOSFET is an IC, what I meant by no IC was that I didn't what an IC which has a buck converter in it like HV9910 or so. I want to have a good knowledge of what i am doing.

My current is always 1A eventhou I have it with some ripples. I believe changing the width of the pulse will change the current via the LED. To be more clear are there common controllers for PWM in this case?

Current regulations like the one you posted are easy but think about efficiency. I want a design with high efficiency.

Best regards
Hubert

To be more clear are there common controllers for PWM in this case?
This is a PWM, but it regulates LED current directly, not LED voltage. If you analyse the current flow when the mosfet is on and when off you will see that it is a current PWM. LED current will be 1amp +/- about 5%, the LED will not be turned on and off continuously.

I want a design with high efficiency.
The design I presented is an efficient design. It is NOT a linear regulator. It is a free running PWM that maintains the LED current at 1 amp. Increasing the supply voltage reduces supply current.

The LED current flows through a current sense resistor and one diode. That gives about 1.5V of wasted voltage compared to the LED voltage of maybe 3V. Efficiency will be better than 60%. That could be improved to better than 80% by using more components such as a synchronous mosfet instead of the fast recovery diode in the LED current loop.

For the inverting schmitt-trigger I would use a 555 timer chip without other components. Input to pins 2 and 6, output to mosfet gate from pin 3.

Hi Baluncore,
thanks for your explanation, Actually I have discussed your circuit with my client but he insisted on having a LED driver with a common controller which will be used for adjusting the pulse width of the PWM thereby changing the current to the LED. I really need help on this.

By the way I tested your design, but i don't understand why at the beginning the current is too large before remaining constant. Is there a way to avoid this?

Best regards
Hubert

#### Attachments

• free-running-pwm.pdf
87.7 KB · Views: 347
• free-running-pwm.jpg
92.2 KB · Views: 749
You have installed D2 where the LED1 should be.
You placed LED1 where D2 should be, with reversed polarity.

Current should always flow down through R1 and the LED. Current then flows either down through the mosfet to ground, or idles back round through D2 to the power rail at the top of R1.

You have the input to the 555 floating. Use 10k for R3 and R4. Ground the bottom of R4.
Connect pins 2 and 6 to the top of R3. Examine the ripple.

Move pin 2 only to the junction of R3 and R4 to get lower LED ripple current and higher PWM frequency.
Select L1 to keep PWM frequency below 100kHz for better switching efficiency.

Trim/adjust the LED current by selecting R1 value only, not R3, 4.

Thanks once more for your support, i have tried to follow all what you said instead i get worse results. current remains at 0A.
From the datasheet of 555, pin 7 should not be connected for the case of schmitt trigger. I don't understand when you said "input to the 555 floating"
Assuming for better switching efficiency PWM frequency should be kept at 100Khz, i calculated L from "Freq = [(vin-vout)*Duty circle] / L*Iripple"

Best regards

#### Attachments

• free-running-pwm.pdf
87.9 KB · Views: 286
"input to the 555 floating"
I meant the bottom of R4 was not connected to ground, but to pins 2&6. Circuit is OK now.

First raise the supply to 12V and see if that fixes the problem. If fixed it was a gate threshold problem.

Not sure from the diagram, but is X2 = N-channel mosfet with Logic level gate, 5V supply might not turn some power mosfets on. Go for a 2 or 3 volt gate threshold. Check the output voltage of the 555, it might need to be higher to meet the gate threshold specs. Maybe a 1k pull-up resistor on the 555 output if it is not going high enough.Running the circuit on 12V rather than on 5V might better meet the gate threshold.

To debug the circuit probe your simulation to find the state that is not working as expected. Find the break in this logic flow.
When initially turned on, LED current is zero. Q2 is off R3 pulls pins 2&6 down, output goes high, mosfet turns on, current through R1 – D1 – L1 – X2 rises until voltage drop across R1 passes 0.6? volt when Q2 turns on and pulls pins 2&6 high, output goes low, X2 turns off. LED current free-wheels through L1 – D2 – R1 – LED until it falls below threshold and X2 turns on again.

Hi Baluncore,

thanks for your reply, i was sick and could not do anything. I just tested the circuit but the LED current is always zero, I have increased the supply voltage but nothing happens. I was expecting some PWM at the output of the IC555 but I have a constant voltage! is that right?

Best regards
Hubert

I was expecting some PWM at the output of the IC555 but I have a constant voltage! is that right?
The output should be switching. Are you simulating this or have you built it out of real components?

If the 555 output stays low, the N'chan FET is off and there will be no LED current.
If there is no LED current then there will be no voltage across the 0R56 current sense resistor. So the PNP transistor will be off.
The voltager on the input pins 2&6 of the 555 will therefore be pulled low by the bottom resistor.
The 555 schmitt-trigger is inverting so the 555 output should go high and turn on the N'chan FET.
That is a contradiction. When you identify where the logic fails you will have found the problem.

Follow the signal around the circuit. What is the voltage on input pins 2&6 of the 555 ?

Your MOSFET appears to be P'chan. It should be N'chan. What part number have you used?

Your 555 pin numbers should be anticlockwise viewed from above chip. Have you reversed pins 5 to 8?
With the notch on the left, pin 1 and pin 8 should be on the LHS of the chip when you read the part number.

Attached is an LTspice simulation. I used 12V supply to suit any MOSFET gate threshold.
The plots are the MOSFET gate voltage and the current through the LED.

Hi Baluncore,
thank you very much, I am grateful. Sorry I have not replied earlier because of illness.
Permit me to contact you again if I still have problems. For the moment is okay. Thanks once more

To run on a 5V supply you must use a LED with a lower forward voltage. I changed to an LXK2-PW14 which is available in LTspice. It now works at 5v.

Permit me to contact you again if I still have problems.
That is what we are here for. Get well soon.