Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

Fading in and out leds using just a pic

Status
Not open for further replies.

trevelyn

Newbie level 5
Joined
Jan 2, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
74
is it possible to 'fade' a led in and out using just a pic and some software?
i am experimenting with a timer (interrupt) routine that turns the led on and off quickly. the leds don't 'fade' very well though.
 

Bat

Member level 1
Joined
Dec 15, 2002
Messages
35
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
348
Yes, it's possible.

Try with a timer, the goal is to make a PWM generator (ie : one one period for example 10µs, put led on x µs and off 10-xµs)

If it should have 10 step, a timer that run at 1kHz is good. (10µs timebase)
Some PIC should already have PWM generator, so the interupt frequency can be reduced.

After that, if it should decrease really smothly, the interrupt frequency shoulf be high (10kHz, 100 kHz) or it's necessary to use some tricks (multiple pins, variable timebase, and so no)
 

stefk

Member level 2
Joined
Jul 15, 2001
Messages
42
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Activity points
293
Good idea is to use a PIC with hardware implementation of PWM - 16F87X for example. In this case you will have 256 steps of brightness. The problem is , if you need to controll more then 2 LEDs because these MCU have only 2 PWM outputs.
 

trevelyn

Newbie level 5
Joined
Jan 2, 2003
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
74
Thanks. I'll try to come up with a software controlled PWM scheme
 

HMX

Member level 2
Joined
May 7, 2001
Messages
43
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
Czech rep.
Activity points
273
Just one hint. The problem in pwm controll of LED's brightness is in nonlinear brightness response to pwm ratio. So, incremenents should be corrected if you want smooth characteristic.
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top