|
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.
|
# ¿ Aug 26, 2023 08:00 |
|
|
# ¿ May 14, 2024 08:36 |
|
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:
|
# ¿ Aug 26, 2023 19:12 |
|
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 |
# ¿ Aug 27, 2023 00:48 |
|
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.
|
# ¿ Aug 27, 2023 02:45 |