Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

control the brightness by PWM

Status
Not open for further replies.

kit_714

Member level 4
Joined
Jul 5, 2006
Messages
70
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
2,011
Dear All,

is it possible to control the brightness of a LED by PWM (for 8051 microcontroller)?

if yes, can anyone attach some source code to me? ('c' is more preferable)

Thanks....
 

It is practically possible to use pulse width modulation with any microcontroller if you know how to send one high level to a port pin for a given time. But usually there is a dedicated pins for PWM in microcontrollers where you can use specific commands for that.
I am not familiar with the microcontroller you are using.
But i think this should help.

PWM uses duty cycle method to give effective voltages.
e.g. if you can send logic high for 1ms and logic 0 for 1ms continuously that will be 50% of duty cycle. (%logic high/ total cycle time). that will give you half the applied voltage. e.g. 2.5v if source voltage is 5V

write two consecutive program loops.
loop1 should send logic high (1) to the specified port until loop1 ends
loop2 should send logic low (0) to the specified port until loop2 ends
write code to modify the length of loop1 or loop2 to modify PWM

this will give you PWM activity for any microcontroller.
But this is not the ideal way to do this.
 

Hi
to control the brighness you need to conrol current passing in the led. To do this you can either coontrol the current itself or to control the resistor through which the current is passing.

To control current itself, you will use a voltage controlled current source where the Voltage control signal is a low pass filtered version of the PWM output of the MC.

To control the resistor value, you will need also to have Voltage controlled resistor element and by the same way you can generate the control voltage.

Thanks
 

So what is the better approach to do this??

can anyone give some circuit diagrams of voltage control current source??

Thanks...
 

haytham made a correct analysis.

1-For low-pass PWM --> RC circuit
2-For resistor varying --> Digital potentiometer -DigiPot


For me 1 is the best choice, because the circuit with digital potentiometer you need a voltage source, and mcu only control resistor value in multiple of one fraction of 256 of resistor max value (8 bits). The PWM gives the possibility to change slightly the brightness.
 

There is no need to low pass filter the pwm in this application. A digipot is also unnecessary, and wasteful. All that is required is a PWM output, a transistor or FET if needed for max current required, and a resistor to set the maximum current through the LED.

To the OP, it is difficult to give more information without knowing your exact requirements, and which 8051 variant you intend to use.

Jim
 

PWM method is commonly used in dimming dc load such as LEDs ..
Here:
https://www.iguanalabs.com/pwm.htm
you will find 8051 application titelled:
"Controlling the Brightness of an LED - Pulse Width Modulation"

Regards,
IanP
 

teteamigo said:
JimW52 said:
There is no need to low pass filter

Jim

Depends on max frequency of PWM & Capacitance of diode

??

As long as you're well above the flicker frequency your eye will do all the low pass filtering you could ever think of, no components needed.. Straight PWM on percentage to variable brightness. Just a standard resistor to limit your max current at 100% on.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top