T
Tim Shoppa
- Jan 1, 1970
- 0
The thread about the D/A converter for a battery charger, and specifically
a comment by Spehro, reminded me of a trick I once used to get an extra bit
of resolution out of a software-based PWM D/A converter without boosting the
timebase frequency.
Let's say that we want to PWM with 5 bits of resolution. Normally we'd
go through a whole 32-count cycle and set the output to 1 for the fraction
we need. But say, due to timebase and LPF constraints we want the cycle
time to be less than 16 clock cycles. The trick is to vary the cycle
length to numbers other than 32. For example, we can generate all 1/32
increments from 2/32 to 30/32 with less than 1/64th error by using the
following fractions:
desired used error (1/32nd's)
---- ----- -------------
2/32 1/16 0
3/32 1/11 0.0909090909090908
4/32 1/8 0
5/32 2/13 0.0769230769230766
6/32 3/16 0
7/32 2/9 -0.111111111111111
8/32 1/4 0
9/32 2/7 -0.142857142857142
10/32 5/16 0
11/32 1/3 0.333333333333334
12/32 3/8 0
13/32 2/5 0.2
14/32 7/16 0
15/32 7/15 0.0666666666666664
16/32 1/2 0
17/32 8/15 -0.0666666666666664
18/32 9/16 0
19/32 3/5 -0.2
20/32 5/8 0
21/32 2/3 -0.333333333333332
22/32 11/16 0
23/32 5/7 0.142857142857142
24/32 3/4 0
25/32 7/9 0.111111111111111
26/32 13/16 0
27/32 11/13 0.0769230769230766
28/32 7/8 0
29/32 10/11 0.0909090909090899
30/32 15/16 0
The technique works for getting one extra bit out of any PWM converter.
The costs are:
1. You need to be able to vary the cycle length.
2. You need a lookup table or to do some math whenever you change the
output. The size of the lookup table or the math search goes up like
2^^(number of bits).
3. You cannot generate the one-from-the-extreme values on either end of the
scale with the extra bit of resolution. (The closest values to 31/32
are 15/16ths and 16/16ths.)
Is there a generic name for this technique?
Tim.
a comment by Spehro, reminded me of a trick I once used to get an extra bit
of resolution out of a software-based PWM D/A converter without boosting the
timebase frequency.
Let's say that we want to PWM with 5 bits of resolution. Normally we'd
go through a whole 32-count cycle and set the output to 1 for the fraction
we need. But say, due to timebase and LPF constraints we want the cycle
time to be less than 16 clock cycles. The trick is to vary the cycle
length to numbers other than 32. For example, we can generate all 1/32
increments from 2/32 to 30/32 with less than 1/64th error by using the
following fractions:
desired used error (1/32nd's)
---- ----- -------------
2/32 1/16 0
3/32 1/11 0.0909090909090908
4/32 1/8 0
5/32 2/13 0.0769230769230766
6/32 3/16 0
7/32 2/9 -0.111111111111111
8/32 1/4 0
9/32 2/7 -0.142857142857142
10/32 5/16 0
11/32 1/3 0.333333333333334
12/32 3/8 0
13/32 2/5 0.2
14/32 7/16 0
15/32 7/15 0.0666666666666664
16/32 1/2 0
17/32 8/15 -0.0666666666666664
18/32 9/16 0
19/32 3/5 -0.2
20/32 5/8 0
21/32 2/3 -0.333333333333332
22/32 11/16 0
23/32 5/7 0.142857142857142
24/32 3/4 0
25/32 7/9 0.111111111111111
26/32 13/16 0
27/32 11/13 0.0769230769230766
28/32 7/8 0
29/32 10/11 0.0909090909090899
30/32 15/16 0
The technique works for getting one extra bit out of any PWM converter.
The costs are:
1. You need to be able to vary the cycle length.
2. You need a lookup table or to do some math whenever you change the
output. The size of the lookup table or the math search goes up like
2^^(number of bits).
3. You cannot generate the one-from-the-extreme values on either end of the
scale with the extra bit of resolution. (The closest values to 31/32
are 15/16ths and 16/16ths.)
Is there a generic name for this technique?
Tim.