1
\$\begingroup\$

I have an LED driver. The current limit is set by the resistor RIADJ. Now there is 3.24 kΩ, which is equal to the current ~ 1 A. enter image description here

Also, the current can be adjusted by supplying an external current IEXT.

enter image description here

To regulate the current, I collected the amount as in the figure below. I would like to regulate the current from 0 to 1 A with a microcontroller. From the microcontroller, I give a PWM signal of various duty cycles:

When the duty cycle is 0 %, then the current flows only through the resistor RIADJ and the current is set to ~1 A.

enter image description here

When the duty cycle is 50 %, then the external current IEXT is applied and the current on the LEDs will be ~ 0.5 A.

enter image description here

When the duty cycle is 100 %, then the external current IEXT is applied and the current on the LEDs will be ~ 0 A.

enter image description here

But in reality, I can’t choose the resistors so accurately to ensure that at 100 % filling of the PWM signal, the current is exactly 387.35 μA in order to get a current on the LEDs of 0 A. And the voltage to the microcontroller is not always ideal 3.3 V and can be from 3.2-3.4 V, which will also affect the current... Moreover, I noticed such a feature, if you change the 510 Ω resistor, say to 270 Ω, then the current will go in the opposite direction, which will still lead to the fact that the LEDs will glow.

enter image description here

How can I adjust the output current from 0 to 1 A with a microcontroller?

I understood what my mistake was and why, if you change the 510 Ohm resistor to 270 Ohm, the current will go in the opposite direction and the LEDs will still glow. I just don't have enough tension. The current monitor of this microcircuit is powered by an internal source of 5.4 V, and I have only 3.3 V from the microcontroller minus 0.7 V drop across the diode.

\$\endgroup\$
1
  • 2
    \$\begingroup\$ If the Microcontroller has an analogue input, you could get it to read the current output and automatically trim the PWM. \$\endgroup\$
    – HandyHowie
    Commented Dec 2, 2022 at 8:29

1 Answer 1

1
\$\begingroup\$

You are trying to implement a current source with "voltage source" (PWM from microcontroller pin) and "resistor" trick which leads to a number of drawbacks.

The output current depends on Microcontroller's pin output "Logic one" voltage which depends on 2 factors:

  1. MCU power supply voltage (depends on how accurate the power supply holds it)
  2. MCU "Logic one" (PWM voltage) level depends on temperature and hot much current is sourced from the pin. This approach leads to quite inaccurate and unstable performance of such PWM-ed "current source".

I would suggest to use any textbook "Current source" circuits where voltage is used to set current - just check The Art of Electronics Textbook by Paul Horowitz and Winfield Hill for inspiration. Typically accuracy of such current source will depend on setting resistor value (may depend on temperature a bit, but you can choose metal-film resistor) but would not depend on power voltage.

It is OK to to use PWM-generated voltage if accuracy of 3-5% is sufficient. Otherwise any DAC (even MCU built-in) would do a much better job.

Ideally, external DAC with reference, but that is an overkill for a typical LED driver. However, LED current accuracy requirement would be nice to know for a correct answer in this case.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.