Electrical – Controlling DC voltage with Arduino

arduinovoltage-regulator

My projects consists of:

  • Arduino Nano
  • 1m 60Leds 12V LedStrip (white)
  • 1m 60Leds 5V controllable LedStrip (RGB)
  • 5V power supply
  • step up converter (from 5V to 12V)
  • potentiometer
  • some trigger buttons
  • some sensors

I'm making a "lamp" of sorts, that would be controlled through Arduino Nano.

I'm powering it with 5V power supply (phone charger); I have step up converter setup for 12V; potentiometer output 0V-5V to Arduino analog input.


One of the functions would be "dimmable LEDs", controlled by Arduino, according to audio and light sensors.

This is no problem for the RGB strip, as they have additional data pin and I can control them that way, but when it comes to 12V white LEDs…

Using lab bench power supply I found out, that white LED strip turns on at 8V and with voltage rising to 12V it gets brighter.

The natural thought was "put a potentiometer there", but I'm already using one potentiometer, as analog input for Arduino (so 5V).


I don't want to use another potentiometer, as it would be against DRY (Don't Repeat Yourself).


I've seen "solutions", as to use PWM together with MOSFET to run the 12V LEDs, but I don't want to introduce "flickering" (even though it might be insusceptible to humans, it may affect my kids falling asleep [they seem to not be able to fall asleep with LEDs connected to mains, while they can with old incandescent bulbs]).

I've also taken a look at "digital potentiometers" (like FM62429 or X9C104), but they all seem to be made for audio signals or lower voltage usages, not 12V.


Soo, my questions are:

  1. Is it possible to make "nice" 8-12V DC using MOSFET and PWM?

  2. Can I make some circuit that would use digital potentiometers and not overheat them?

  3. Is there a better way to make that project work?

Best Answer

I'll try concluding on the comments a bit, and add personal commentary.

  • The standard way is really PWM'ing LEDs. When using a high PWM frequency, humans can't detect that it's PWM. There's relatively solid statistics and theory behind that's the case.
  • If you don't want PWM, the appropriate way to dim an LED is to vary the current (illumination strength is pretty much proportional to current, which itself is pretty much exponential with voltage).
  • You can build a controlled current source using your MCU, and MOSFETs

Personal notes:

  • if your child can't sleep with a given light, but with another:
    • account for external control factors (sound emissions, light position, time of day, the fact that an incandescent bulb makes more infrared heat radiation than visible light and your child might just like the warming effect)
    • it's well-known that "bluer" lights tend to keep people awake more than warmish white tints. (and the latter is exactly what the incandescent light provides) You can buy "warm" white LEDs. What you're looking for is "color temperature", and that should be relatively low (2700 K - 2900 K).
  • You could use a step-down converter LED driver IC. That has the advantage of not being a linear solution and hence not getting as hot.
    • Many come with a current limit pin, which needs to be connected to a low-side shunt resistor. When the current is high, the voltage over that resistor is high. You can use an opamp voltage adder to add a voltage to that voltage so that you can adjust the current externally.
    • You could use the PWM followed by a simple RC low-pass filter to generate a voltage to add to that, giving you software. That's a voltage DAC!
  • Of course, you could also build a linear regulator:
    • PWM -> low pass for a voltage DAC
    • 12V -> high-side MOSFET configuration (that's nontrivial) driven by opamp -> LEDs -> Ground as the power chain
    • low side of MOSFET -> Voltage divider to a voltage range your DAC could also produce (e.g. 12 V maps to 3V)
    • connect divided voltage to non-inverting input of opamp from above. The opamp is now in a negative-feedback configuration, which means it will try to output exactly as much as necessary to make the voltage at its two inputs equal.
    • connect DAC to non-inverting input. This now allows your MCU to control the voltage at the voltage divider's output, and hence the voltage that the LEDs see.
    • pull down non-inverting input via 1 MΩ to ground. That way, when your MCU is off/malfunctions, the lights turn off.