Driving LED with PWM, Beginner's Question



Hi all!

True beginner here, but was very excited to find this site. I would
greatly appreciate if someone could shed some light on whether or not I am
going about a project correctly. Here are the facts:

Using -

PIC16F690 with an external 20Mhz crystal oscillator, powered by 5V (at
300mA? at least that's what the wall wart says - seems to be about 1 amp
when I measure it).

I am trying to drive an LED with PWM on the CCP1 pin. I have written an
app that uses 10 bit resolution for the duty cycle, and varies it between 0
and 100%. This appears to be working correctly - the LED fades from
completely off to rather bright.

I am, however, trying to figure out whether I should have a resistor in
series with the LED or not.

I am powering a blue LED. Its voltage rating is 4V, the current test is
20mA.

My best measurements with an oscilloscope and multimeter seem to indicate
that at 100% duty cycle, the PWM pin is outputting 5V at 32.6mA. I don't
know if this is correct, and would love to even know where in the datasheet
I could look to know what the pins can potentially output - is this called
sourcing, or sinking, a voltage?

Anyway, it seems to me that if:

R = (Vsource - Vled)/I

Then I should have a resistor of size:

R = (5-4)/.02
R = 1/.02
R = 50ohms (nearest greater = 56ohms)

So, my final questions are:

1. Do the readings I've taken for the PWM pin at 100% duty cycle make any
sense? How could I find in the data sheet for the PIC16F690 what the pin
can "output"?

2. I'm trying to get the most brightness possible out of the LED. If my
readings are all right, it seems like this resistor in series with the LED
is correct for 100% duty cycle. Do I need it when I'm doing PWM? What
about at the smaller duty cycles, will this make it very dim?

Any help would be much, much appreciated!

-Syr


.



Relevant Pages

  • Re: Confused about wiring of XR 2206
    ... some duty cycle trim, but it is not a wide range variable pulse generator. ... The resistors from pins 7 and 8 to ground set two choices of frequency, ... by changing the value of a loading resistor, ... Pin 11 is the square wave output. ...
    (sci.electronics.design)
  • Re: 555 - Adjustable duty cycle circuit questions
    ... discharges thru the resistor to pin 7 only. ... the duty cycle should be about 50% (duty cycle means % of total period ...
    (sci.electronics.basics)
  • Ultrasonic serial communication transmitter.
    ... If I connect the TX PIC serial output pin straight to the RX PIC ... the duty cycle for a transducer should be less than 60% for it to ... Perhaps a tone controller or are they not fast enough? ... I can't find any 24kHz crystals ...
    (sci.electronics.basics)
  • Re: Motorcycle flasher problem.
    ... You can get any duty cycle you want. ... resistor between pin 7 and pin 6. ... oscillations of the 555 are limited to 50% and then I wanted to convey ... misleading and did not intend to. ...
    (sci.electronics.basics)
  • Re: Motorcycle flasher problem.
    ... Hey, Steve, I've done something similar on my 2004 Honda Sabre. ... I use a LM555 timer chip ... You can get any duty cycle you want. ... resistor between pin 7 and pin 6. ...
    (sci.electronics.basics)