[McHUG] McHUGging at Vail - part last
Rich Mitchell
geobra at att.net
Fri Dec 11 10:48:38 EST 2009
This morning we're out of here. I have been playing a bit with PWM. I have a full color Radio Shack LED with the red, green and blue cathodes cycling at different steps. Looks kind of neat.
This brings me back to a workbench question. Can PWM be used as a varying voltage source? "Getting Started with Arduino" describes PWM as a "persistence of vision" phenomenon. You are always providing 5v, but for different lengths of time - pulse width modulation. Somewhere in the Arduino literature it says that the PWM pins run at 500 Hz. So if you run the pin at 128 (half of full brightness 255) you should have a rectified square wave with a frequency of 500 Hz. Now if you run it at a higher or lower number you still have a frequency of 500 Hz, but the on and off parts are not equal.
I would think you would try to smooth out the square wave with an RC circuit of some type. From EE 101 my guess is that an RC of 2 ms Would give you your 66.2%. To get to 98% you would use 8 ms? Now if you are using 10k pf capacitor, I would think a resistor around 20k would give you a starting point. When I tried that in my workbench I was getting a voltage number range of 28 to 130. 5v should have a number of 1023, I think.
Through trial and error I found two 4700 ohm resistors in parallel gave me a voltage number range of up to 282 with a reasonable percentage change at the voltage divider point. Obviously it is getting nowhere near 5v. Perhaps with a larger cap we could get a better voltage range. (This afternoon 'll be in Denver with bigger RadioShacks, or should I head toward Boulder and SparkFun?) Or is PWM a dead end in getting a variable voltage source?
73
Rich, N3III
--
McHUG - Physical Computing ;)
MicroController Ham User Group
More information about the McHUG
mailing list