Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
ryanrs
Jul 12, 2011

Well as long as we're ranting, LEDs have a nice linear relationship between brightness and current. Incandescent bulbs, on the other hand, are very non-linear in every possible way and you'll need a photodiode in the loop if you want precision dimming.

Adbot
ADBOT LOVES YOU

ryanrs
Jul 12, 2011

Programming languages are a wholly human construct that are intentionally designed to be easy to understand. A program is basically a linear list of instructions, so of course it's a lot easier to talk about them. Once you get into more complex topics, like concurrency, compilers, networks, or even just floating point, a lot of people throw up their hands and go "it's complicated!". You have to understand TCP really loving well to coherently explain a packet trace from first principles.


So take this circuit:



The AP5726 regulates the LED current such that FB = 0.31 V (from the datasheet). You pick the value of Rset based on your desired LED current.

FB = led_current * Rset
algebra...
Rset = FB / led_current
Rset = 0.31 V / 20 mA
Rset = 15.5 ohms



Now modify the circuit by adding R2 and R3.



So instead of seeing the voltage on Rset, FB now sees a blend of Vdc and the voltage on Rset. The blending ratio is set by R2 and R3.

For the case of Vdc = FB = V_Rset = 0.31 V, all the voltages are the same, and so no current flows through R2 and R3. This means that when Vdc = 0.31V, the LED current is 20 mA regardless of R2 and R3. This makes the math simpler, so we'll just say max brightness is when Vdc = 0.31V.


For the other extreme, you want the LED current to go to zero when Vdc = 3.3V.
Given:
LED current = 0mA
Vdc = 3.3V

calculate:
FB = (Vdc - V_Rset) / (R2+R3) * R2 + V_Rset

V_Rset = LED current * Rset = 0V

FB = Vdc / (R2+R3) * R2

0.31V = 3.3V * R2 / (R2+R3)

0.31V * R2 + 0.31 * R3 = 3.3V * R2

0.31 V * R3 = (3.3V - 0.31V) * R2
R3 / R2 = (3.3V - 0.31V) / 0.31 V
R3 / R2 = 9.65

So that's the approximately 10:1 ratio people have been talking about.


BTW, the Diodes datasheet is wrong about the values of R2 and R3 for their example.
Vdc = 2.0 V
0.31 V * R3 = (2.0V - 0.31V) * R2
R3 / R2 = (2.0V - 0.31V) / 0.31 V
R3 / R2 = 5.45
So you could use R3=27k and R2=5k. Then LED current will vary from 20 mA to 0 mA as Vdc goes from 0.31 V to 2.0 V.



How to calculate the absolute value of R2

FB pin bias current = 100 nA max (datasheet pg 4)
feedback voltage tolerance = +/- 10% (datasheet pg 4, feedback voltage min and max)

The FB tolerance gives us the rough accuracy of the circuit. As you can see from the chip tolerances, this is not a precision circuit. So we will pick a value of R2 such that the FB bias current contributes less than 2% additional error.

FB bias voltage = FB bias current * R2
FB bias voltage / FB <= 2%
FB bias voltage / 0.31 V <= 0.02
FB bias voltage = 0.0062 V

this gets the following relation:
FB bias current * R2 <= 0.0062 V

R2 <= 0.0062V / FB bias current
R2 <= 0.0062V / 100nA
R2 <= 62k ohms

So given worst-case chip specs, you'll have 10% error even is everything outside the chip is ideal and R2 is small. But as R2 increases, it adds additional error, on top of the 10%. At 62k, the additional error is 2%, bringing the total error is around 12%.

So you could use:
R2 = 63k
R3 = 9.65 * R2 = 608k
to get 0-20mA LED current as Vdc varies from 3.3 to 0.31.

Using very large resistors such as these makes the circuit very slightly more efficient, by minimizing power in the feedback path.



...but then you realize the datasheet has only specced FB bias current at 25 C. There are no limits or graphs for other temperatures, but we know that leakage current is generally exponential with temperature. At high chip temps, I would not be surprised if FB bias current is over 10 times the max value at 25 C. To ensure correct behavior over temperature, we reduce the value of R2 by a lot, perhaps 10x. This brings us back to the original value of R2=5k, as shown in this circuit from the datasheet:

ryanrs
Jul 12, 2011

I’m phone posting, but I think the above explanation goes off the rails when you define Vdc to be very different from the Vdc signal in the data sheet. Vdc definitely is not the supply voltage.

e: ok I see what you are doing with the pot

ryanrs fucked around with this message at 00:56 on Aug 27, 2023

ryanrs
Jul 12, 2011

Why the digipot and not a DAC like in the data sheet? I've always been wary of putting a digipot in the feedback path, because of their limited frequency response. That said, I haven't done any math to know if it matters in this application.

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply