lm2596 + LED + Arduino PWM



  • Hi,

    this is more a generic question: I unsoldered the on/off pin of the lm2596 on a module I bought from China. This one then got connected to pin 6 (timer 0 PWM) of an Arduino nano.

    The brightness control (via analogWrite) is working, however, the apparent brightness does not change much for duty cycles higher than 50/255...So I set 0,1...16 and then it is basically already at max brightness.

    • Are there any tricks/formulas to put the apparent brightness between 0-100% for usage directly with a V_DIMMER?
    • Does the lm2596 have a startup time which might affect the PWM?
    • Could I use timer 1 to have a 16-bit PWM or do I scree up MySensors then?

    Cheers,
    pansen


  • Mod

    @pansen said in lm2596 + LED + Arduino PWM:

    • Are there any tricks/formulas to put the apparent brightness between 0-100% for usage directly with a V_DIMMER?

    Thr FastLED library has functions for creating linear apparent brightness for several types of leds. Maybe you can use the library directly, or take inspiration from how they do it?

    • Does the lm2596 have a startup time which might affect the PWM?

    It switches at 150kHz so I think you should be fine, but the output capacitor will definitely affect the output. What capacitor are you using for Cout? (check the lm2596 datasheet section 9.1.3 for more details)



  • @mfalkvidd Good idea with FastLED, I will use it directly since there is enough space left.

    I use this module, looks like it has a 220uF output cap. Doing some back of the envelope calculations, the time constant (i.e 67% charge point) is about 220us, Arduino PWM frequency is 62.5kHz which yields a resolution of 16us and a total period of 4080us...that's less than 20 times the time constant of the cap.

    So this might actually be the problem! I'll try to lower the PWM frequency and see what happens. In the datasheet they mention you should use a low ESR cap to for a low output ripple, but I don't really care about that in this application, so in the worst case I just switch the output cap with an off the shelf cap with lower capacitance.

    Thanks for your input.


  • Mod

    @pansen you've piqued my curiosity. I haven't seen a voltage regulator driven by PWM before. Would you mind sharing what you're building?



  • @mfalkvidd: I just finished version 2 of a prototype, when It is working like I want I will present it in the "Projects" subforum :+1:


Log in to reply
 

Looks like your connection to MySensors Forum was lost, please wait while we try to reconnect.