Yahoo Groups archive

AVR-Chat

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

Thread

Space Vector PWM application

Space Vector PWM application

2005-08-29 by Thomas Keller

For those pof you who may not know, Spave Vector Pulse Width
Modulation is the premiere means of controlling the speed of AC
induction motorts (specifically, three phase motors).  The primary
reason for this is that they switch the power waveforms 33% less often,
thereby inurring 33% fewer switching losses, which makes for a much more
efficient speed control system, with less expensive components (less
expensive, lower-spec switching devices, smaller or no heat sinks,
etc.).

  The alogorithm used for SVPWM is, quite naturally, complex and
difficult to understand, being based heavily on vector algebra.  I have
located an example of a Space vectro control package for the AVR, at
avrFreaks.net.  Unfortunately, in analyzing the code, it has become
obvious that whomoever wrote the code is not a very good programmer (at
least, with the AVR).  This brings into question the correctness of the
algorithm they have coded, as well as the correctnes of the code itself.

  All this having been said, my question:  Has anyone out there ever
coded and used SCPWM, and could either provide sample code, or would be
willing to work wiht me to further analyze and "certify" the code I have
found?  My math skills are not strong enough to code this myself (I
know, I know, but I am being honest here), and I have need of the
algorithm for a personal project (which I may turn into a D-I-Y article
for "Home Shop Machinist Magazine" if it works out well).

   This project is in persuit of my personal dream of building a machine
shop in which I can build a variety of different descriptions of steam
engines, including scale models of classic steam locomotives,as well as
usable modela of Tesla Boundary Layer Turbines, etc..  Please help me
persue my dream?


Tom Keller

Re: [AVR-Chat] Space Vector PWM application

2005-08-29 by Mark Jordan

I'm interested. Did they use fixed point math? Assembly?

	Mark Jordan
Show quoted textHide quoted text
On 28 Aug 2005 at 19:19, Thomas Keller wrote:

>   All this having been said, my question:  Has anyone out there ever
> coded and used SCPWM, and could either provide sample code, or would be
> willing to work wiht me to further analyze and "certify" the code I have
> found?

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

Re: [AVR-Chat] Space Vector PWM application

2005-08-29 by erikc

Can you provide a link to this file?

Thomas Keller wrote:
>   For those pof you who may not know, Spave Vector Pulse Width
> Modulation is the premiere means of controlling the speed of AC
> induction motorts (specifically, three phase motors).  The primary
> reason for this is that they switch the power waveforms 33% less often,
> thereby inurring 33% fewer switching losses, which makes for a much more
> efficient speed control system, with less expensive components (less
> expensive, lower-spec switching devices, smaller or no heat sinks,
> etc.).
> 
>   The alogorithm used for SVPWM is, quite naturally, complex and
> difficult to understand, being based heavily on vector algebra.  I have
> located an example of a Space vectro control package for the AVR, at
> avrFreaks.net.  Unfortunately, in analyzing the code, it has become
> obvious that whomoever wrote the code is not a very good programmer (at
> least, with the AVR).  This brings into question the correctness of the
> algorithm they have coded, as well as the correctnes of the code itself.
> 
>   All this having been said, my question:  Has anyone out there ever
> coded and used SCPWM, and could either provide sample code, or would be
> willing to work wiht me to further analyze and "certify" the code I have
> found?  My math skills are not strong enough to code this myself (I
> know, I know, but I am being honest here), and I have need of the
> algorithm for a personal project (which I may turn into a D-I-Y article
> for "Home Shop Machinist Magazine" if it works out well).
> 
>    This project is in persuit of my personal dream of building a machine
> shop in which I can build a variety of different descriptions of steam
> engines, including scale models of classic steam locomotives,as well as
> usable modela of Tesla Boundary Layer Turbines, etc..  Please help me
> persue my dream?
> 
> 
> Tom Keller



-- 
erikc
--
"The kind of man who wants the government to adopt and enforce his
ideas is always the kind of man whose ideas are idiotic."
    -- H. L. Mencken

Re: Space Vector PWM application

2005-08-29 by thormj

Are these "Space Vector" PWM signals similar to Don Lancaster's "Magic 
Sinewaves" (http://www.tinaja.com/magsn01.asp)?

-Thor Johnson

Re: [AVR-Chat] Space Vector PWM application

2005-08-29 by Thomas Keller

On Mon, 2005-08-29 at 15:29 -0600, erikc wrote:
> Can you provide a link to this file?
> http://www.avrfreaks.net/index.php?module=FreaksAcademy&func=viewItem&item_id=73&item_type=project
> 
> his is the project file on avrFreaks.net

Re: [AVR-Chat] Re: Space Vector PWM application

2005-08-30 by Thomas Keller

On Mon, 2005-08-29 at 23:44 +0000, thormj wrote:
> Are these "Space Vector" PWM signals similar to Don Lancaster's
> "Magic 
> Sinewaves" (http://www.tinaja.com/magsn01.asp)?
> -Thor Johnson

  No, not the same thing at all.   Space vectors involve complex vector
algebra, to computer 6 "vectros" around the circle of rotation, within
which current magnitudes can be preduicted with precision.  By using the
processor to compute these magnitudes, and the PWM capabilities to
produce them in the windings of the motor at the appropriate times, you
can control the speed of the motor while maintaining (relatively)
constant torque at the motor output shaft (by relaively, we mean that
while the torgque will or course, flutuate as the armature turns, as it
doesn in any electric motor, it will, if measured over a time
realtivelylong in comparison to the rotational speed of the shaft appear
"constant," as opposed to simple volatge/current amplitude control of
motor speeds, which results in much lower torque being available at the
output shaft at lower speeds.   All Don's "Magic Sines" really are is a
lookup-table based approach to generating sine values without having to
have the processor arithmetically compute them (there was a time, not so
long ago, when an 8 bit processor would have been very hard pressed
indeed to compute such values at all, much less to do so fast enough to
be useful in control applications).

  Magic sines are still an exellent approach, when one deosn't need
sinces for anything smaller than integral degree values.  A lookup table
of just 90 values (scaled appropriately, of course) is all one needs.  I
have computed sine tables for the first 90 degrees of a circle for 10
bit, 16 bit and 32 bit scaled sines.  10 and 16 bit tables, of course,
require 180 bytes of data, and 32 bit tables, of course, require 360-
bytes of data for storage, so you don't want to scale any higher than
you need to to achieve your purpose, as "data" space on small
controllers like AVRs (most of them, anyway) is at a premium.  not to
mention the tim e penalties involved in dealing with extra bytes of
data, especially if you don't need the resolution they provide.

   Remember, in microcontroller programming, we are constantly having to
keep in mind code size, and how it is affected by the resoltuon of what
we need to do, as a result of limited memory resources.  Often, we have
to trade off some resolution to achiecve needed code/data density.

Tom Keller

(apologies tothose who already know all this stuff.  Many here don't,
and it behooves all of us to educate each other)

Re: [AVR-Chat] Re: Space Vector PWM application

2005-08-30 by Don Ingram

> Tom Keller
> 
> (apologies tothose who already know all this stuff.  Many here don't,
> and it behooves all of us to educate each other)
> 

Behoove away Maestro ;-)

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.