Sine 50 table, compensated for 2nd harmonic caused by left-aligned PWM.
Sine amplitude goes from 14% to 86% (total amplitude 73%).
52
57
62
66
70
74
77
80
82
84
85
86
86
86
85
83
81
78
75
72
69
65
61
56
52
48
44
39
35
31
28
25
22
19
17
15
14
14
14
15
16
18
20
23
26
30
34
38
43
48
Attached is a technique first introduced by Ravas around 1967. Im not sure how good this works though because i've never tried it. My own patterns i generate based on the average signal level centered at the timing intervals, not two different signal levels.
hi Al,
For reference only.
This is the method I used in my earlier simulations.
ie: Sine wave period and Ramp switching Rate into a comparator.
Eric
Relative harmonic content of raw pattern:
1: +1.00000
2: +0.00045 3: +0.00068 4: +0.00213 5: +0.00329
6: +0.00469 7: +0.00012 8: +0.00365 9: +0.00428
10: +0.00247 11: +0.00272 12: +0.00050 13: +0.00272
14: +0.00165 15: +0.00130 16: +0.00148 17: +0.00290
18: +0.00075 19: +0.00095 20: +0.00077 21: +0.00113
22: +0.00140 23: +0.00058 24: +0.00321 25: +0.00059
26: +0.00136 27: +0.00342 28: +0.00098 29: +0.00116
30: +0.00102 31: +0.00058 32: +0.00239 33: +0.00262
34: +0.00006 35: +0.00273 36: +0.00111 37: +0.00031
38: +0.00002 39: +0.00120 40: +0.00124 41: +0.00168
42: +0.00287 43: +0.00486 44: +0.00679 45: +0.01370
46: +0.04278 47: +0.15417 48: +0.36025 49: +0.48139
50: +0.94769 51: +0.48140 52: +0.35892 53: +0.15541
54: +0.04627 55: +0.00777 56: +0.00256 57: +0.00438
58: +0.00391 59: +0.00121 60: +0.00190 61: +0.00512
62: +0.00095 63: +0.00407 64: +0.00041 65: +0.00248
66: +0.00096 67: +0.00016 68: +0.00062 69: +0.00123
70: +0.00212 71: +0.00013 72: +0.00216 73: +0.00186
74: +0.00071 75: +0.00177 76: +0.00036 77: +0.00048
78: +0.00407 79: +0.00079 80: +0.00233 81: +0.00210
82: +0.00211 83: +0.00029 84: +0.00149 85: +0.00170
86: +0.00147 87: +0.00104 88: +0.00011 89: +0.00019
90: +0.00062 91: +0.00011 92: +0.00541 93: +0.01386
94: +0.04308 95: +0.08099 96: +0.15709 97: +0.18864
98: +0.08922 99: +0.10514 100: +0.57989 101: +0.10446
102: +0.09064 103: +0.18487 104: +0.15737 105: +0.08864
106: +0.03630 107: +0.01046 108: +0.00707 109: +0.00358
110: +0.00485 111: +0.00217 112: +0.00109 113: +0.00419
114: +0.00194 115: +0.00286 116: +0.00249 117: +0.00063
118: +0.00013 119: +0.00031 120: +0.00020 121: +0.00347
122: +0.00054 123: +0.00157 124: +0.00101 125: +0.00137
126: +0.00192 127: +0.00171 128: +0.00197 129: +0.00008
130: +0.00453 131: +0.00059 132: +0.00133 133: +0.00053
134: +0.00110 135: +0.00123 136: +0.00016 137: +0.00115
138: +0.00210 139: +0.00120 140: +0.00581 141: +0.01532
142: +0.03429 143: +0.06141 144: +0.09410 145: +0.10492
146: +0.06739 147: +0.04026 148: +0.09124 149: +0.01875
150: +0.37819 151: +0.02072 152: +0.09021 153: +0.03550
154: +0.05976 155: +0.10649 156: +0.09940 157: +0.06011
Total harmonic distortion (up to Nth harmonic only):
1.551013016
Total Harmonic Distortion of Filtered Output:
0.0008551115269
...
Oh so you dont want to use manual pulse generation? It's been a while since i looked at the PIC built in PWM peripheral so i'd have to review that before i can comment. For manual generation i dont think it would be that hard with a lookup table. The other benefit would be the ability to generate possibly sine and cosine waves simultaneously.
In your new table i assume you are doing it the same way now? That is, for pulse 1 you go high at t=0 and stay high for 52 counts, then go low and stay low for 48 counts, so again it's always high for N counts and low for 100-N counts right? Have you done this using the PIC built in PWM too?
...
...
Attached is a technique first introduced by Ravas around 1967. Im not sure how good this works though because i've never tried it. My own patterns i generate based on the average signal level centered at the timing intervals, not two different signal levels.
Ericgibbs said:...
For reference only.
This is the method I used in my earlier simulations.
ie: Sine wave period and Ramp switching Rate into a comparator.
TheElectrician said:...
The red curve is for the 3 stage filter plus an 82 mH inductor. The inductor I used here came from Digikey, quite easy to obtain. It has a DC resistance of about 50 ohms, which was subtracted from the 330 ohm resistor.
...
Interesting. I would have expected the 2.3mH inductor to look better than that at 50kHz as it has XL=720 ohms at 50kHz and should have 1/3 the 50kHz component at the stage1 of the first RC filter. At least it did on the scope so that mathed the XL calc. I guess by the end of the filter stage3 there is plenty of overall 50kHz attenuation the first stage 50kHz attenuation is less critical.
I'm relucant to specify something like a 82mH inductor for the hobby guys but I will include your recommendation on the web page for the people that want to go the extra distance.
MrAl, your new table of THD values, I assume the initial 1.5% THD is caused by the granularity of only 50 table entries AND the integer rounding? If that is the case, the final 0.08% THD is practically all filter dependent?
I did comment! And i am very much appreciative!
"MrAl, your new table of THD values, I assume the initial 1.5% THD is caused by the granularity of only 50 table entries AND the integer rounding? If that is the case, the final 0.08% THD is practically all filter dependent?"
I'm happy the final THD looks so good now, for sure. And I'm a lot more confident the figures are accurate after everyone's continued work on all the figures and analysis of why the figures do what they do!
As I asked above, I'm assuming the THD now is because of the coarse 50:1 sample rate and integer rounding errors, which means IF that is so then all it really needs is more filtering to get a very low THD.
My filtering was always a "minimalist" way to get 2v amplitude out of a junkbox passive filter. And that will do fine for my own prototype.
Maybe if people wanted to suggest the next step up, ie; a common hobby-available opamp filter that is easy to attach to the PIC PWM and not much to go wrong I can include that at the end of the web page for people that want really low THD figures and/or better output drive? I've already included people's comments on making the RC and RLC filter more aggressive.
...
Are you saying you want better than 0.08 percent now? That makes me have to ask what you want to use this for?
...
...
I thought that you might also like to know that your original filter with the inductor means a filtered THD of 0.085 percent, but with the inductor shorted out the THD only rises to 0.096 percent, so that's just a little less than one tenth of one percent without the inductor. You may want to mention that for people who dont want to worry about finding an inductor.
Thanks for the addition suggestion, i will add that, along with TheElectrician's comment on the inductor and the level of the 50kHz component.
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?