Discussion in "8051 Discussion Forum" started by    Miguelito    Apr 26, 2012.
Thu Apr 26 2012, 08:19 am
#1
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
Sat Apr 28 2012, 02:50 am
#2
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.
Wed May 02 2012, 10:38 am
#3


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.

Thu May 03 2012, 12:22 am
#4
as expected Its not possible this way to have three different PWMs for each LED.
Mon May 07 2012, 12:04 pm
#5
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
Tue May 08 2012, 02:13 am
#6
you will have no control when LEDs are connected to shift register.. all you can do is.. control them all together nothing else.
Tue May 08 2012, 03:01 am
#7
You have control lines for clock, data, reset and latch.
Why not drive the LEDs from these instead of using a shift register ?
Tue May 08 2012, 03:04 am
#8
thats a nice question Phil he is already using 3 pins by the way.. why not connect LEDs directly?
Tue May 08 2012, 06:38 am
#9
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
Tue May 08 2012, 12:30 pm
#10
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

Get Social

Information

Powered by e107 Forum System

Downloads

Comments

Bobbyerilar
Thu Mar 28 2024, 08:08 am
pb58
Thu Mar 28 2024, 05:54 am
Clarazkafup
Thu Mar 28 2024, 02:24 am
Walterkic
Thu Mar 28 2024, 01:19 am
Davidusawn
Wed Mar 27 2024, 08:30 pm
Richardsop
Tue Mar 26 2024, 10:33 pm
Stevencog
Tue Mar 26 2024, 04:26 pm
Bernardwarge
Tue Mar 26 2024, 11:15 am