PWM two banks of LED's Constant Current


I'm trying to run a project where I'm driving two banks of LED's using PWM. I want to run them at constant current. As one increases in brightness (the duty cycle increases) i want to decrease the other.

It's a pretty easy problem to run using the Analogue write function and just inverting the number, i.e. 255-original value. Doing this seems to work but as you get to the middle of the two brightness's the overall brightness decreases and so does the current draw.

Giving it a quick scope the PWM signals have zero phase difference, meaning there is a time where both banks are off, a dead time.

I was just wondering if anyone knows a way to run the second signals rising edge at the firsts falling edge therefore having truly constant current?

Any help would be greatly appreciated

Thanks Jon

Hi Jon,

Why not use a single pwm output. Use it to drive one bank of leds directly. Also connect that same pwm output to an inverter (a logic gate with an inverting output, or just a simple transistor inverter) and use the output from that to drive the second bank of leds. Then your two banks are guaranteed to be exactly out of phase.