Yahoo Groups archive

AVR-Chat

Index last updated: 2026-04-28 22:41 UTC

Message

Re: [AVR-Chat] Space Vector PWM application

2005-08-29 by Thomas Keller

On Sun, 2005-08-28 at 21:31 -0300, Mark Jordan wrote:
>       I'm interested. Did they use fixed point math? Assembly?
>       Mark Jordan


  mark:  no, no fixed point math.  It is written with the same basic
apporach I had planned to use when I still thought I would be able to do
it myself, which is table driven (there is a 1020 byte lookup table
includedin the code!!)

  Written in AVR Assembly language, yes.

  An example:  there is a section of code which inputs a value from the
ADC, and manip[ulateds it with a whole raft of shifts, rotates, etc.  In
the final line of this program is an ROR instruction which is commented
as "sort of like a software low pass filter."   I spent about two days
trying to make sense of this code, trying to see how on earth it could
be anything even remotely akin to a low pass filter, before I had an
"aha!"  The comment applied ONLY to the ROR.  Having realized this, I
went back and looked at the code some more, and realized that they were
doing, in about 15 instructionsm, what coul d have been done in two.
Allthe programmer was doing was grabbing the two bytes of data from the
onboard ADC, and folding them into one byte, throwing away the two LSBs
of the low byte.    Worse yet, at least as *I* read the comments, he
never says *WHY* he is reading the ADC (e.g., what the value is used
for).

  There are a number of routeins that interface to the lookup table, but
I don't see in the main code where they get called.   Mysterious.  

  The file is in the avrfreaks.net projects area foir download.  You
might take a lpook at it.  There are a variety of excellent references
on SV PWM available on the WWW, if you Google you will find them.  One
particualrly good one, as I recall, is to be found at the TI Website,
among their applications notes for their DSPs.  It includes a coplete
listing for an implementation using a TI DSP, but that isn't terribly
useful for implementationon an AVR, given the "slightly" sdifferent
architectures and instruction sets.  *grin*

   Again, for those not familiar with such applications, I hjave
realzied that I left out a fairly important bit of description:  SV PWM
works by synthesizing (think power inverters) a three phase waveform for
the motor.   In the case of SV, it does so in 6 "vectors" rather than
360 degrees, and only switches current when necessary to maintain one of
the 6 (technically 8, but two of them are not "real") vecto5rs of
current flowing through the windings of the 3 phase motor.  By varying
the frequency and voltage of the waveform, it controls the speed of the
motor, while maintaining virtually 100% torque capabilitiers, make it
ideal for machine tool speed control (and far less expensive or complex
than using geared transmissions)  

   (Yes, I did the math.  I actually spent two years studying the
"Machinist's Handbook" and related texts, on gears and gearing, until I
understood enough to design a 32 speed sliding gear (similar in
principal to the transmission in most cars) transmission for a metal
lathe.  The thing required DOZENS of gears (all custom made, of course),
with hundreds of dollars worth of raw materials, and hundreds if not
thousands of hours of labor in machining them and assembling the thing
into a working transmission.    All for a lathe that, including the
brand new 5 HP three phase motor, won't cost more than $200 to build
(12" swing, 28" centers)  Overall, far too expensive an approach for
such a project)(though the learning process was in itself worthwhile and
fascinating)

Tom

Attachments

Move to quarantaine

This moves the raw source file on disk only. The archive index is not changed automatically, so you still need to run a manual refresh afterward.