SDG Electronics

SDG #016 Designing a Constant Current DC-DC LED Driver - Part 2

Part 2 of this LED driver series moves from hardware to firmware, and it is the part where most buck converter projects either come together or fall apart. The target chip is Microchip’s dsPIC33FJ16GS502, a device aimed squarely at digital power conversion thanks to its high speed PWM module and fast ADC, and the work here focuses on getting those two peripherals cooperating to hold a high power LED at a set current.

The practical value is in the configuration detail. Setting up the high speed PWM means understanding the auxiliary clock and PLL that feed it, choosing a switching frequency and duty resolution that suit the inductor and switch already chosen in Part 1, and making sure the ADC sample point is triggered at a sensible moment in the switching cycle rather than in the middle of switching noise. Sampling current at the wrong instant is one of the classic reasons a digitally controlled converter looks unstable on the bench when the power stage is actually fine.

From there the loop itself gets attention: reading the current sense feedback, comparing against a setpoint, and adjusting duty cycle in a way that settles quickly without oscillating or overshooting into the LED. Verification is done on real hardware with an MSO1074Z scope watching the switching node and current waveform, a bench supply feeding the converter, and a REAL ICE debugger attached so the code can be stepped and tuned in place using MPLAB X and XC16.

Anyone considering a digital approach over an off the shelf analogue LED driver IC will get a realistic sense here of the extra firmware effort involved, and what the payoff is in terms of programmable current, dimming and monitoring.