Johan Bodin wrote:
I can't see that as a problem. Timer1 overflow flag works in PWM mode too
so it is possible to write an interrupt routine that is synchronized to the PWM
cycle. Every time the ISR is fired, it reads the 20-bit value from a global and
updates the 10-bit PWM control register with either N or N+1, according to
the "sub-PWM" algorithm.
you spared me compulsing the '8535 data sheet. It looks like it is
quite feasible and with a minimal
consumption of CPU time, thanks.
The DDA algorithm mentioned by Stewart is what sometimes is used to draw
lines on a display
with a finite number of pixels. If the line is quite close to be
horizontal (or vertical), you cannot
avoid some more pronounced jagginess. The example you give, a 1 in the
10 LSBs, is conceptually
similar to an almost horizontal line. It is a worst case situation and
it must be accepted as such
I like Stewart's idea of maximizing the dither frequency by spreading the N+1
corrections all over the main PWM cycles but I don't know enough math for
optimizing it. What if the value of the 10 LSBits is 1 for example? It cannot
be spread out and there will be some some Fpwm/1024 frequency component
(although very small).
(unless Stewart has some more clever suggestions...)
Good. You analysis shows that what remains as a concern is only the
noise. Anybody knows of
an op-amp (readily available) better than the OP27, as far as noise is
concerned ? TNX.
Assuming 8MHz clock on the '8535 (Yes, I know it :-), main PWM frequency
is 3910 Hz max in 10-bit mode. Adding a 10-bit sub-PWM brings the lowest
frequency component down to 3910/1024 = 3.8 Hz. A 3:rd order LPF with
0.3 Hz cut-off, or so, should be about 60 dB down at 4 Hz and still have a
reasonably fast response. With more filter poles you should be able to put the
cutoff "knee" closer to 3.8 Hz and get faster response without sacrificing
"sub-PWM" ripple rejection. Maybe a Bessel response is preferable to
avoid overshoot although Bessel has a very "lazy" roll-off compared to
Butterworth et. al.
73 Alberto I2PHD