RGB driver with microcontroller.

Do you have a question? Post it now! No Registration Necessary

Translate This Thread From English to

Threaded View
Hi,

I would like to send a RGB LED strip with four potentiometers:
3 potentiometers for the colors red, green, blue.
With the fourth potentiometer I want to adjust the brightness.
Now, most microcontrollers have 4 A/D inputs,
but I would also have 3 ports with a PWM output for the colors.
Can anyone give me some advice which microcontroller (type)
I can use?
Where can I find some examples like this?
I don't want to buy a driver but maked it by myself

Thanks
Christophe



Re: RGB driver with microcontroller.

Quoted text here. Click to load it


IIRC Elektor magazine has in the past published uC controlled RGB projects.



Re: RGB driver with microcontroller.

Quoted text here. Click to load it

Pretty much any microcontroller could be programmed to do this task - the
solution would be to do the PWM in software, rather than using the on-chip
PWM hardware (which, as you noticed, may not exist).

The easiest way I find to do this is by running the PWM in the main loop.
The frequency may vary somewhat as other events happen, but on average this
will provide adequately fast PWM for visible LED color applications. As an
example:

/* Physical outputs to LEDs (syntax is processor/compiler dependent) */
sbit RedLed P1^1;
sbit GrnLed P1^2;
sbit BluLed P1^3;

void main(void)
{
  unsigned char Red, Grn, Blu, Pwm;

  while(TRUE)
  {
/* Do something to acquire values for Red, Grn, and Blu (0..255) */
      Red = GetPotentiometer(1);
      Grn = GetPotentiometer(2);
      Blu = GetPotentiometer(3);

/* Do PWM processing */
    Pwm += 1;     /* wraps back to 0 after 255 */
    RedLed = (Pwm > Red) ? FALSE : TRUE;
    GrnLed = (Pwm > Grn) ? FALSE : TRUE;
    BluLed = (Pwm > Blu) ? FALSE : TRUE;

  } // End of main loop
}

Note that this method can have a problem.  If something happens in the main
loop (such as processing a received command) that takes significant
processor time (even a few milliseconds), there will be a noticeable
perturbation in the brightness of the LEDs.  The most reliable way around
this is to place the PWM logic in a timer service routine, rather than in
the main loop.

The downside of using the timer method is that the timer must trigger fairly
rapidly in order to keep the PWM frequency high enough to prevent visible
strobing of the LEDs (10 kHz or so), and the additional overhead required by
the interrupt service may use up too many processor cycles.  This can be
mitigated by decreasing the resolution of the PWM from 1/256 to, perhaps,
1/16 (0..0x0F).  This reduces the number of distinct colors available, but
in many cases (most, in my experience) still provides adequate color
rendition.
--
Mark Moulding



Re: RGB driver with microcontroller.
On Sat, 13 Nov 2010 14:42:28 +0100, Christophe wrote:

Quoted text here. Click to load it

if you are controlling all 3 colours then a global brightness control is  
an unnecessary complication (and probably wont work as expected)


something like an attiny24/44/84 should suffice for both pwm & analog  
inputs

--  
Never trust an operating system you don't have sources for. ;-)
    -- Unknown source

Site Timeline