Hi all!
True beginner here, but was very excited to find this site. I woul greatly appreciate if someone could shed some light on whether or not I a going about a project correctly. Here are the facts:
Using -
PIC16F690 with an external 20Mhz crystal oscillator, powered by 5V (a
300mA? at least that's what the wall wart says - seems to be about 1 am when I measure it).I am trying to drive an LED with PWM on the CCP1 pin. I have written a app that uses 10 bit resolution for the duty cycle, and varies it between and 100%. This appears to be working correctly - the LED fades fro completely off to rather bright.
I am, however, trying to figure out whether I should have a resistor i series with the LED or not.
I am powering a blue LED. Its voltage rating is 4V, the current test i
20mA.My best measurements with an oscilloscope and multimeter seem to indicat that at 100% duty cycle, the PWM pin is outputting 5V at 32.6mA. I don' know if this is correct, and would love to even know where in the datashee I could look to know what the pins can potentially output - is this calle 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:
- Do the readings I've taken for the PWM pin at 100% duty cycle make an sense? How could I find in the data sheet for the PIC16F690 what the pi can "output"?
- I'm trying to get the most brightness possible out of the LED. If m readings are all right, it seems like this resistor in series with the LE is correct for 100% duty cycle. Do I need it when I'm doing PWM? Wha about at the smaller duty cycles, will this make it very dim?
Any help would be much, much appreciated!
-Syr