magic sinewaves
Tracy Allen
Posts: 6,664
Hi Phil,
continued from Duty mode output to drive Power MosFET or IGBT
Here is one diagram from www.tinaja.com/glib/msinexec.pdf
which shows a 28 pulse waveform, 7 per quadrant. It is efficient for power drive, because there are very few transitions, and that means the driver spends most of its time either full on or full off and very little time in the power wasting transition zone.
Here is another figure from the same document, showing the harmonic content, showing the fundamental (at 60 hertz) and the first significant harmonics at the 29th and above. This is hard to reconcile inuitively with the ON OFF waveform above, but it makes sense that it is made up primarily of a component at roughly 28 times the fundamental. The accomplishment is the fine tuning of the pulse positions and widths to bring those middle harmonics to zero.
The fact that the analysis can be done without considering the filter parameters is why Don Lancaster chose to do it that way. The calculations are complicated, but Don has gone to all that trouble for us! What a great guy. I practically learned electronics from the TTL and CMOS Cookbooks. Don lays out the theory, but then he makes it easy with his Javascript calculators. I wish I could implement a calculator for it in Excel, but the underlying matrices of Chebyshev are daunting, and there are other steps he has taken too, like the Monte Carlo optimization procedure.
I think you are probably right, that it would be possible to acheive the result by running it through some sort of filter and using least squares measure of fit to a good sine wave. But the frequency domain analysis avoids that and gets right to the harmonic distortion without assuming anything about the filters. I don't see where Don talks much about filtering at all, except to say that the inductance and the intertia of a motor will make a great multipole filter when the lower harmonics are so much reduced.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 2/25/2007 5:05:46 AM GMT
continued from Duty mode output to drive Power MosFET or IGBT
Here is one diagram from www.tinaja.com/glib/msinexec.pdf
which shows a 28 pulse waveform, 7 per quadrant. It is efficient for power drive, because there are very few transitions, and that means the driver spends most of its time either full on or full off and very little time in the power wasting transition zone.
Here is another figure from the same document, showing the harmonic content, showing the fundamental (at 60 hertz) and the first significant harmonics at the 29th and above. This is hard to reconcile inuitively with the ON OFF waveform above, but it makes sense that it is made up primarily of a component at roughly 28 times the fundamental. The accomplishment is the fine tuning of the pulse positions and widths to bring those middle harmonics to zero.
Phil Pilgrim (PhiPi) said...
Regarding the "magic sinewaves" approach: I wonder if it's really necessary to analyze the goodness-of-fit in the frequency domain. It seems like it might be easier to model the lowpass filtering (first-order IIR, at least) in the time domain and use a sum-of-squares error function to determine fitness.
Modelling in the frequency domain does have the advantage of not having to consider the filtering until after the fact, but computing the error function for each candidate pulse stream is more computationally complex.
-Phil
The fact that the analysis can be done without considering the filter parameters is why Don Lancaster chose to do it that way. The calculations are complicated, but Don has gone to all that trouble for us! What a great guy. I practically learned electronics from the TTL and CMOS Cookbooks. Don lays out the theory, but then he makes it easy with his Javascript calculators. I wish I could implement a calculator for it in Excel, but the underlying matrices of Chebyshev are daunting, and there are other steps he has taken too, like the Monte Carlo optimization procedure.
I think you are probably right, that it would be possible to acheive the result by running it through some sort of filter and using least squares measure of fit to a good sine wave. But the frequency domain analysis avoids that and gets right to the harmonic distortion without assuming anything about the filters. I don't see where Don talks much about filtering at all, except to say that the inductance and the intertia of a motor will make a great multipole filter when the lower harmonics are so much reduced.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 2/25/2007 5:05:46 AM GMT
Comments
Wanted it for BLDC but never got around to using it and so forgot all about magic sin waves.
The prop maybe good enough to do it for BLDC, nice high freq clock and 32 bit counters.
Gavin
Attached is a demo object for a 28 pulse magic sine wave. A cog counter sets the frequency and provides the phase reference, and there is a table of 2*28 phase points where the pulses are to start and end. The values in the table come from one of Don Lancaster's Java calculators as linked above. The asm sequencer program reads through the table ias phase advances and sets or clears the two output pins that are supposed to drive the half bridges.
Here is an example table:
The start and stop points from the java calculator are phase in degrees, which have to be translated to Propeller counter phsa from zero to 2^32-1. Don emphasises that the transition timing has to be precise, within one microsecond, in order to achieve the best suppression of the low harmonics. The Prop clocked at 80mhz can achieve that easily.
The program that polls the counter phsa register. The latency is less than 8 clock cycles, 100 nanoseconds. Even greater time precision could be achieved by using a table of delta values with waitcnt, instead of the counter module. That could get the latency down to one clock cycle, but with that method it would be hard to adjust the sinus frequency. The method using the counter module makes it easy to adjust that on the fly.
I haven't looked at this on a scope with filtering. When slowed down of course it looks very course, DUTY mode or a higher frequency standard PWM can in contrast give a very smooth appearane because of the very rapid switching, at thousands or more events per cycle. This uses only 28 pulses per cycle which IK guess is what makes it attractive for efficient motor drive.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Paul Baker
Propeller Applications Engineer
Parallax, Inc.
Two close pulses can trivially be generated with 12.5ns resolution with a counter, so you can do the edges in pairs (for
the most part).
On the other hand, the nice thing about your assembly code routine is you can change FRQ on the fly and the code just
"magically" does the right thing.
Very sweet. Has Dan done anything like this for sigma-delta ADC, to reduce the edge count there?
Trying to digest your magsines2.spin.
1)Why both outputs are upside down?
2)I got odd output waveforms when I use afreq:=3221.
3)Why there are two :loop0?
4)what "rdlong clkf,0" does @ entry
5)Can you explain on "shl t0,#4"?
Thanks,
Ching
Post Edited (Ching Lin) : 2/27/2007 7:45:55 PM GMT
1) I'm not sure what you mean by both outputs being upside down. The way I see it, each one is like the picture from the first post in this thread.
2) I attached an o'scope picture (tek THS720) from the output. This is with output frequency 60hz, frqa=3221. The top trace is the output that comes directly from bit31 of phsa, in NCOmode. The bottom trace comes from the two output pins, with the scope probe bridged between the two pins. Do you see something different?
3) the Propeller syntax allows local labels that start with a colon. The scope of a local label lies between two normal labels. It is convenient for these short wait loops.
4) the rdlong clkf,0 is not used by this program. Sorry, remnant. If the program needs to specify a frequency in absoulte Hertz, that clkf value would be used to find the frqa value based on the desired hertz value.
5) The object of this code that follows the last pulse in the cycle of 28 is to detect when the phsa register rolls back to zero phase.
The phsa can advance by 8*frqa during time it takes to execute the polling in :loop0, that being because there are four clocks per instruction, times two instructions, while phsa advances on every clock. I made it 16*frqa just to be on the safe side. In retrospect, it should simply test phsa(31) and wait for it to go back to zero.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 2/28/2007 12:21:36 AM GMT
www.tinaja.com/demo28a.asp
Paul, thanks for the defination, "brushless DC motor" = BLDC. I'm clueless about which types of motors and what applicatons this would be used for. (I just like making waves!) It seems like a lot of these motors require overlapping phases around 120 degrees apart. The prop could do that too, I think.
The Art of Electronics has an example, the 61 inch sidereal telescope drive motor which needs to be operated by an accurately settable frequency from 55 to 65 hertz. In that case, the digitally synthesized sine wave goes through a linear amplifier to the motor. The prop could handle the synthesis with much less trouble, but not best via magic sines.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Everything looks great now.
I was confused by measuring the waveforms from the demo board headphone amp outputs.
Thank you so much for the help.
Ching Lin
Brushless motors get used a lot in model aircraft with awesome performance, they also work well in electric vehicles. Generally they are not driven sinusoidally but rather just with pulses which are turned into trapizoids by the motor inductance. Hall sensors or back emf is used to decide when to energize the specific windings. So most of the time they are just emulating DC motors really with the speed dictated by the load.
I'm interested in making a low speed high torque motor for an electric unicycle, I'd use a quad encoder for the feedback as it would allow commutation down to zero speed.
If you wanted to put some of these nice waves into practise you will find BLDC motors in every CD-ROM and HD.
I love TAOE, a cracking book but please don't insert the paperback version into the front wheel of your racing bike. Don't ask but lets just say I now have, two lumps of paper back and 5 less spokes on that particular wheel.
Graham