`[<<][math][>>][..]`
Mon Oct 9 14:31:06 CEST 2006

## Dither, PWM, Sigma-Delta, Bresenham

```What is dither[3] used for? It makes a digital system behave more like
an analog system, in that it can be used to make it exhibit _graceful
resolution on average, but adds noise to the immediate values. For
phenomena where the average is more important than the immediate
value, this can be an interesting trick.

A simple example of this is a first order difference equation in
finite precision.  Suppose I'm using 16-bit values to represent
oscillator periods.  In order to make logarithmic increments, I could
use a difference equation

y[k+1] = (1+a)y[k]

where a is a small constant. However, if ay is below hex 0.00008000
the value of y remains constant. In this case, average behaviour is
important, so using 0.0000rrrr as rounding term, where rrrr is a
16-bit uniformly distributed random number, gives an approximation of
the correct behaviour.

Random number generation (RNG) for this application is most
efficiently done using a finite field primitive polynomial.  However,
care needs to be taken to check the statistical properties in case the
same RNG is used to drive several dithering filters, although I can't
see any pathological cases at first glance.

If clear patterns in the output are not really a problem, a simpler
solution is to just use a triangle wave as dithering function, which
gives effectively a PWM output. What I'm really intereseted in is a
dithering scheme where the ripple is smaller after integration of the
output. This requires a higher frequency quantization step.

For example, instead of using a 01 ramp, a 81 ramp can be used. What
exactly is the relation to S-D modulation and the Bresenham[2] line
drawing algorithm? Let's make a list.

* uniform dither: Dither is from a uniform noise source.

* PWM: Dither from a square wave. Same average as uniform dither, but
clear pattern. Large ripple after integration.

* nPWM: Like pwm, but using a triangle wave modulated to Nyquist
frequency. Smaller ripple.

* S-D: Minimizes ripple after integration.

* Bresenham: Uses higher state resolution to generate a proper
average. Ordinary rounding quantization.

The reason PWM is used over S-D in motor control (as I guess from PWM
modulators being part of uC hardware, but S-D not) could be switching
efficiency.  Larger ripple is tolerated if higher switching efficiency
(lower switch frequency) is attained. See Don Lancaster's magic
sinewaves[1] for explicit minimization of switching events for sine
wave generation as an alternative to PWM. When low ripple amplitude is
more important than efficiency, for example in audio applications, S-D
modulation can be used.

Question: can PWM hardware on uC be used to generate S-D signals?

[1] http://www.tinaja.com/glib/msinprop.pdf
[2] http://en.wikipedia.org/wiki/Bresenham's_line_algorithm
[3] http://en.wikipedia.org/wiki/Dither

```
`[Reply][About]`
`[<<][math][>>][..]`