Tek,
the PWM approach allows both Speed and Intensity control on the PWM duty cycles changing in time
(all the 120-degrees out of phase with other // as divided thirds of a complete modulation cycle)
you may want to check out Tom's work at Electric Druid
I would encourage you to take your own route of course ...
but Tom makes his code available for study
http://electricdruid.net/tap-tempo-lfo-taplfo-v2d/
there is another dude as well here:
http://www.sabrotone.com/?p=3992
worth looking at perhaps ...
---
what we want, to be clear, is a PWM ratio that changes near continuously in time
in small digital steps ...
I think the Electric Druid Tap Tempo uses 10bits (or 1024 steps) spread out over the
period of the modulation cycle ... meaning that the PWM variation has about a 0.1% duty cycle resolution per division over the full 0-100% scale
ie., how the 1024 PWM ratios are cycled thru in time sets the modulation "shape"
that's your design call ...(!)
to explain further ...
a PWM that goes from 0% to 100% proportionately with time (at full Depth)
and immediately reversed it's direction at the same rate, back and forth ...
that would then be called a triangle-wave modulated PWM
if the PWM got modulated the same way between 25% and 75% extremas
then we would have a triangle wave modulation of the PWM, set at half Depth or Intensity ...
at zero Intensity the PWM ratio would remain steady at 50% over time ...
for a sinewave modulation, the rate of PWM variation in time also changes in time between direction reversals ...
I think you need some kind of lookup table or something ... (actually I should check, maybe not ...)
it's very important you understand the goal for sure
don't want to send you in a random direction ...
also, I'd like to be able to make that 50% point variable ...
so for example, if the zero Depth were stuck at 27% PWM instead of 50%
then MAX intensity would give is a PWM modulation variation (either either sine or triangle in time)
that would go between 0% duty cycle and 54% duty cycle, without clipping in the modulation shape
consider that we will be driving LED's thru resistors ...
and that the PWM pulses will be 0-5vdc in height ...
each PWM output can drive 1mA on those PIC things I'm sure (gotta be)
so if I set the resistor for a maximum 1mA of current
a PWM going from 0% to 100% will then result in an "equivalent" DC current ranging proportionately from 0mA to 1mA
we want the brightness of the LED's to go up and down, in a sine or triangle manner
(I won't get into the math aspects too much now, but there's much more going on ...)
let me know if this is still not clear ...
now bear in mind that Tom is looking at this problem also ...
~jcm