Hi again,
..... i have to wonder if the non linearity of the inductor might actually introduce more distortion in real life than it takes away in theory. This really should be looked into because it's a big waste if it doesnt help or actually makes it worse, and we can not do that kind of analysis in theory because we dont know the characteristics of the inductor.
...
These inductors are rather small, about the size of a 2 watt resistor, stocked by Digikey and Mouser here in the U.S.
Using physically larger inductors, the generated distortion is much smaller, essentially undetectable.
TheElectrician, thanks for the info!
I deliberately avoided using any of those tiny resistor-shaped inductors for that reason. That is part of what limits the "hobbyist" inductor choice, as the better performing inductors like toroids etc are hard to find in 10's of mH range! The ones I used in the prototype are two 1/2" toroids of 1.15mH each.
3. There's no easy way to get the RC filter values as the PWM freq will remain fixed and the output freq has varied. Also it is unrealistic to think of getting high frequencies using this method, even if Nyquist says you can get a sine from only a few sample points I wouldn't try to do it with PWM! Even with 10kHz output that is a sine table of only 4 entries (assuming you want sine and cosine) and 4 entries is NOT a sine wave.
Hi again, it's not at all suitable for 40kHz, even a fixed 40kHz as the PWM frequency is 50kHz.
If you wanted to generate a low freq signal say between 1kHz and 5kHz it can be ok, just use the filter values as shown as they will JUST remove the 50kHz pwm and leave you with the largest possible amplitude sinewave. Obviously at 5kHz your output sinewave will be smaller than 1kHz sine with the same filter.
As I said before, this was optimised for 1kHz and is a trade off of a number of factors including sine table entries, pwm frequency and filter values.
If you need higher output frequency than a couple of kHz then you should really look at a DAC output system not a pwm system.
Here is the spreadsheet data to make the "PWM compensated" sine table
using my simplified natural sampled PWM compensation system (see description
in this thread above).
Open source - RomanBlack 19th June 2011.
Columns Description Excel formula
B7 Step steps in table =B6+1
C7 Degrees sine degrees = C6 + (360 / 50)
D7 sine value sin =SIN( C7 *PI()/180)
E7 Table value scaled to 72 high =(72 / 2) + (D7 * (72 / 2)) + 14
F7 Comp adds PWM compensation = E7 + (((E7+E8)/200) * (E8-E7))
G7 Int rounded to integer =F7
-----------------------------------------------------------
Step Degrees Sine value Table Comp Int Int
0 0 0 50.0 52.4 52 52
1 7.2 0.125333234 54.5 57.1 57 57
2 14.4 0.248689887 59.0 61.6 62 62
3 21.6 0.368124553 63.3 66.0 66 66
4 28.8 0.481753674 67.4 70.0 70 70
5 36 0.587785252 71.2 73.8 74 74
6 43.2 0.684547106 74.7 77.1 77 77
7 50.4 0.770513243 77.8 79.9 80 80
8 57.6 0.844327926 80.5 82.3 82 82
9 64.8 0.904827052 82.7 84.1 84 84
10 72 0.951056516 84.3 85.3 85 85
11 79.2 0.982287251 85.5 85.9 86 86
12 86.4 0.998026728 86.0 86.0 86 86
13 93.6 0.998026728 86.0 85.5 86 86
14 100.8 0.982287251 85.5 84.5 85 85
15 108 0.951056516 84.3 82.9 83 83
16 115.2 0.904827052 82.7 80.9 81 81
17 122.4 0.844327926 80.5 78.4 78 78
18 129.6 0.770513243 77.8 75.4 75 75
19 136.8 0.684547106 74.7 72.2 72 72
20 144 0.587785252 71.2 68.6 69 69
21 151.2 0.481753674 67.4 64.7 65 65
22 158.4 0.368124553 63.3 60.7 61 61
23 165.6 0.248689887 59.0 56.5 56 56
24 172.8 0.125333234 54.5 52.2 52 52
25 180 0 50.0 47.8 48 48
26 187.2 -0.125333234 45.5 43.5 44 44
27 194.4 -0.248689887 41.0 39.3 39 39
28 201.6 -0.368124553 36.7 35.3 35 35
29 208.8 -0.481753674 32.6 31.4 31 31
30 216 -0.587785252 28.8 27.8 28 28
31 223.2 -0.684547106 25.3 24.6 25 25
32 230.4 -0.770513243 22.2 21.6 22 22
33 237.6 -0.844327926 19.5 19.1 19 19
34 244.8 -0.904827052 17.3 17.1 17 17
35 252 -0.951056516 15.7 15.5 15 15
36 259.2 -0.982287251 14.5 14.5 14 14
37 266.4 -0.998026728 14.0 14.0 14 14
38 273.6 -0.998026728 14.0 14.1 14 14
39 280.8 -0.982287251 14.5 14.7 15 15
40 288 -0.951056516 15.7 15.9 16 16
41 295.2 -0.904827052 17.3 17.7 18 18
42 302.4 -0.844327926 19.5 20.1 20 20
43 309.6 -0.770513243 22.2 22.9 23 23
44 316.8 -0.684547106 25.3 26.2 26 26
45 324 -0.587785252 28.8 30.0 30 30
46 331.2 -0.481753674 32.6 34.0 34 34
47 338.4 -0.368124553 36.7 38.4 38 38
48 345.6 -0.248689887 41.0 42.9 43 43
49 352.8 -0.125333234 45.5 47.6 48 48
50.0
The formulas used in the spreadsheet cells are included, it should all make sense and should be easy enough to adapt to other size tables than the 50 entry table I used. I have provided it in this form as it can be entered into any spreadsheet (not just excel).
Note! The last column "integer" relies on Excel's normal process to round numbers in it's cells up or down to get the right integer, and the fact that it keeps all cells in a (annoyingly hidden) floating point format.
2 14.4 0.248689887 59.0 61.6 62 62
13 93.6 0.998026728 86.0 85.5 86 86
14 100.8 0.982287251 85.5 84.5 85 85
23 165.6 0.248689887 59.0 56.5 56 56
35 252 -0.951056516 15.7 15.5 15 15
36 259.2 -0.982287251 14.5 14.5 14 14
23 165.6 0.248689887 59.0 56.5 56 56
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?