Mr RB
Well-Known Member
MrAl, I owe you and The Electrician an apology I was wrong on the second harmonic issue (as I'm sure you both knew). I'm still a bit thrown as to why the voltages created in the RC seem to be inverse to the 2nd harmonic but that's irrelevent to finding as solution which you have been doing while I've been wasting time and annoying people.
I've just been reading some white papers on PWM and distortion in high fidelity and at least that has raised an option of generating a compensated sine table.
What the white paper said is basically if the sine table entries are generated from "natural sampling" there is no harmonic distortion. "Uniform sampling" as I used to generate the table makes a sample at a uniform periof (20uS). Natural sampling is to generate the PWM width by a ramp at the point where the ramp coincides with the signal. This is reasonably easy done in hardware but in a sine table it needs the sine interpolated between each two samples, which is not really hard just a little bit more effort. It should still be do-able in Excel.
Other non-distortion options are centre-aligned PWM (as The Electrician originally suggested) or the option I believe you are suggesting of inverting the lower half of the sine table using the same 25 entries as the first half of the table.
The problem I have with both of those options is that it is hard to do on the minimum level PIC which only has a simple PWM module!
So both would require manual PWM generation, and in that case there are some better options like a 2pin push-pull system that gives double the amplitude as well (as you said very early on), or a high freq manual PWM that uses many HI LO cycles per 20uS PWM "step". Actually both of those could be high frequency systems as it's as just easy to generate manual 2pin or 1pin PWM.
I kind of feel like this is going DejaVu as I did a PIC manual-generated high-freq sine PWM back in dec 2009...
Before i jump into generating code for messy manual high-freq PWM, or makign a compensated sine table, do you have a suggestion for balancing the PWM generated by the simple PIC pwm module?
I've just been reading some white papers on PWM and distortion in high fidelity and at least that has raised an option of generating a compensated sine table.
What the white paper said is basically if the sine table entries are generated from "natural sampling" there is no harmonic distortion. "Uniform sampling" as I used to generate the table makes a sample at a uniform periof (20uS). Natural sampling is to generate the PWM width by a ramp at the point where the ramp coincides with the signal. This is reasonably easy done in hardware but in a sine table it needs the sine interpolated between each two samples, which is not really hard just a little bit more effort. It should still be do-able in Excel.
Other non-distortion options are centre-aligned PWM (as The Electrician originally suggested) or the option I believe you are suggesting of inverting the lower half of the sine table using the same 25 entries as the first half of the table.
The problem I have with both of those options is that it is hard to do on the minimum level PIC which only has a simple PWM module!
So both would require manual PWM generation, and in that case there are some better options like a 2pin push-pull system that gives double the amplitude as well (as you said very early on), or a high freq manual PWM that uses many HI LO cycles per 20uS PWM "step". Actually both of those could be high frequency systems as it's as just easy to generate manual 2pin or 1pin PWM.
I kind of feel like this is going DejaVu as I did a PIC manual-generated high-freq sine PWM back in dec 2009...
Before i jump into generating code for messy manual high-freq PWM, or makign a compensated sine table, do you have a suggestion for balancing the PWM generated by the simple PIC pwm module?