Home - Search - Members
Full Version: pwm + shift register + tri-color LED
Miguelito
Apr 26 2012, 2:49 AM
Hi,
Can anybody give some hints on how I can achieve this?
I have a tri-color LED controlled by a shift register.
Without pwm I can make it lit, each color(R-G-B).
But no idea how should I do it using pwm in Keil C51 as I'll be controlling its duty cycle so I can create different color and dimming.

I'm confused here:
If I use 8-bit pwm mode. Where should I put my shift register CLOCK and shift register LATCH value?

Here is my code WITHOUT PWM.
void Illum(enum color col)
{
	U8 i, temp;
	if(col & MASKED_RED)
		temp = col & MASKED_RED;
	if(col & MASKED_GREEN)
		temp = col & MASKED_GREEN;
	if(col & MASKED_BLUE)
		temp = col & MASKED_BLUE;
       for(i=0;i<8;i++)
	{
		SER_IN = (temp & 0x80);
		SRCK_P = 1;
		SRCK_P = 0;
		temp = temp << 1;
	}

	temp = 0;	
	LATCH = 1;
}


I used Silabs 8051F387 mcu.


thanks in advance
miguelito

Ajay Bhargav
Apr 27 2012, 9:20 PM
I can only guess but I am not sure how you've connected your LEDs but i want to see your schematic only then i can give you any suggestions.

Miguelito
May 2 2012, 5:08 AM


I can only guess but I am not sure how you've connected your LEDs but i want to see your schematic only then i can give you any suggestions.

Ajay Bhargav



Thanks Ajay.
Attached is my schematic.



Ajay Bhargav
May 2 2012, 6:52 PM
as expected Its not possible this way to have three different PWMs for each LED.
Miguelito
May 7 2012, 6:34 AM
Thanks. Do you have any recommendation on this?
I have hard time figuring out on how I can modulate(lengthen/shorten) the pulse of the OUTPUT of the shift register so I can have a dimming effect.
Should I use Timer interrupt, software pwm?

thanks
Miguelito
Ajay Bhargav
May 7 2012, 8:43 PM
you will have no control when LEDs are connected to shift register.. all you can do is.. control them all together nothing else.
ExperimenterUK
May 7 2012, 9:31 PM
You have control lines for clock, data, reset and latch.
Why not drive the LEDs from these instead of using a shift register ?
Ajay Bhargav
May 7 2012, 9:34 PM
thats a nice question Phil he is already using 3 pins by the way.. why not connect LEDs directly?
Miguelito
May 8 2012, 1:08 AM
Thanks for your reply guys.
There are 3 tri-color LEDs actually ( I only show you one to simplify the situation) and needs 9 pins for them, and my mcu couldn't cater them all. And sooner, it will be 5 tri-color LEDS.

I think, i should use SPI protocol for this. What do you think?

thanks
Miguelito
Miguelito
May 8 2012, 7:00 AM
Please tell me if I can modulate the output of the shift register by using the G*/OE*(output enable) of the shift register?
I read some article, I forgot the address, that if handled correctly the OUTPUT ENABLE can be used to pwm the shift register output.

Let me know your thoughts about this.

thanks in advance
miguelito
majoka
May 8 2012, 8:27 AM
@ Miguelito
its looking like difficult to generating 3 different pwms using a shift registers
shift register output is controlled by the clock pin
if u change the clock frequency then it will change the frequency of all pwms
so it is not possible with shift registers
its better u change a micro controller that has sufficient pins
Miguelito
May 8 2012, 8:52 AM
Nop, there's no 3 pwm.
And not with hardware pwm.
PWMing the OE pin only of the shift register might achieved my desire.
ExperimenterUK
May 8 2012, 7:33 PM


There are 3 tri-color LEDs actually ( I only show you one to simplify the situation) and needs 9 pins for them, and my mcu couldn't cater them all. And sooner, it will be 5 tri-color LEDS.

I think, i should use SPI protocol for this. What do you think?

Miguelito


I think you should have mentioned the other LEDs in your first post.
What might work for one LED may not be expandable to five.

I think you should add another C8051F387 as a slave to drive the LEDs.
Miguelito
May 9 2012, 1:40 AM
Sorry for not mentioning that earlier in my post.

Anyway, thank you all for your time in answering my questions.
Ajay Bhargav
May 9 2012, 7:51 PM
you can use any small microcontroller to do this job.. not really a big controller.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Rickey's World © 2003 - 2007