Module 18
Module 18
Introduction
In this module, we will look into an application that is not usually considered to be the
domain of Digital Signal Processors: real-time control of electrical motors. In the old days,
the control of speed and torque of electrical motors was performed using purely analog
technology. Since the appearance of microprocessors, more and more control units have been
designed digitally, using the advantages of digital systems. This improves the degree of
efficiency and allows the implementation of more advanced control schemes, thanks to
increased real-time computing power. It is a natural progression to use the internal hardware
computing units of a DSP to transfer the calculation from a standard microprocessor to a
DSP. This way, we can implement more advanced algorithms in a given time period.
However, to use a digital controller for motor control, the system needs a little more than
computing power. The output signals of the digital controller to the power electronic are
usually generated as pulse width modulated signals (PWM). It would be most cost-effective
if the controller could be equipped with an internal PWM-unit. To control the operation of
the motor we need to do some measurements for currents and voltages – analogue to digital
converters (ADC) will be helpful as well. A typical unit to perform a position/speed
measurement is an optical encoder; quite often, we build in a Quadrature Encoder (QEP).
Recalling all parts of the F2833x we discussed in this Teaching - CD, you can imagine that
the F2833 is an ideal device for Digital Motor Control (DMC).
The chapter will not go into the fine details of electrical motors and drives. Instead, it will
give you a sense of what needs to be done to use the F2833x to control the motor of a
vacuum cleaner or the motor of an electrical vehicle. To fully understand these principles, it
requires many more classes at university. If you are on a course of electrical engineering that
focuses on drives and power engineering, you might be familiar with most of the technical
terms. If not, see this chapter as a challenge for you to open up another application field for a
Digital Signal Controller.
Chapter 18 is based on a Texas Instruments Presentation “TIs C2000 Real-Time MCU for
Digital Motor Control“(August 2009). Depending on the laboratory equipment at your
university, you might be offered the chance to attend a laboratory session to build a working
solution for such a motor control.
Module Topics
F2833x Digital Motor Control ........................................................................................................ 18-1
Introduction ................................................................................................................................... 18-1
Module Topics ............................................................................................................................... 18-2
Basics of Electrical Motors ........................................................................................................... 18-3
Motor Categories ...................................................................................................................... 18-3
Asynchronuous Motor .............................................................................................................. 18-4
Synchronuous Motors: BLDC and PMSM ............................................................................... 18-5
Motor Control Principles .............................................................................................................. 18-6
Trapezoidal Control .................................................................................................................. 18-6
Scalar Control (“V/f”) ............................................................................................................... 18-6
Field Oriented Control (FOC) ................................................................................................... 18-7
FOC Coordinate Transform (Clarke / Park).............................................................................. 18-9
FOC Measurement of Motor Position and Speed ..................................................................... 18-9
Advantages of Vector Control ................................................................................................ 18-10
FOC Step By Step ................................................................................................................... 18-10
3-Phase Power Switches ............................................................................................................. 18-11
Sine PWM VSI Control .......................................................................................................... 18-12
Space Vector PWM VSI Control ............................................................................................ 18-13
FOC Control Schematics ............................................................................................................ 18-14
Field Oriented ACI control ..................................................................................................... 18-14
Field Oriented Brushless DC control ...................................................................................... 18-15
Field Oriented PMSM control................................................................................................. 18-16
F2833x Features for Motor Control ........................................................................................... 18-17
Software .................................................................................................................................. 18-17
IQ – Math Functions ............................................................................................................... 18-18
Real-time Debug (RTDX)....................................................................................................... 18-19
Texas Instruments Digital Motor Control Library ...................................................................... 18-20
Software Modules ................................................................................................................... 18-20
The Application Framework ................................................................................................... 18-21
Texas Instruments DMC Solutions ......................................................................................... 18-22
Example: PMSM Framework ...................................................................................................... 18-23
Build Level 1 .......................................................................................................................... 18-23
Build Level 2 .......................................................................................................................... 18-24
Build Level 3 .......................................................................................................................... 18-25
Build Level 4 .......................................................................................................................... 18-25
Build Level 5 .......................................................................................................................... 18-26
Build Level 6 .......................................................................................................................... 18-26
Power Factor Correction (PFC) .............................................................................................. 18-27
C2000 Motor Control Hardware ................................................................................................ 18-28
Summary...................................................................................................................................... 18-30
Motor Control Development Kit.................................................................................................. 18-30
Asynchronuous Motor
Ω R = s.Ω
-0.50
C B -1.00
Im -1.50
Stator flux ~
ΩS ω I
c Current Phasors ωt
~
C 120o I
a
B` ` Re
A Aluminum bar
~
I
b
Theory of Operation:
– Rotor placed in a moving magnetic field (flux) will have current induced – which produces another magnetic field
– The interaction of these two magnetic fields produces the rotational torque
• Stator flux is variably controlled by feeding current
• Rotor flux is induced by the stator flux
• Rotor and Stator rotate at different speeds = Asynchronous
• Angle between rotor and stator flux can be regulated to determine torque
• Rotor position is never known
S
C` Stator field
S
B`
A BLDC Back EMF
PMSM Back EMF
Theory of Operation:
– Fixed rotor flux (magnetic field) and a produced stator flux
– The interaction between the two fields produces a torque which will cause the motor to rotate
• Stator flux is variably controlled by feeding current
• Rotor flux is constant by permanent magnets or current fed coils
• Rotor rotation is at same frequency as supplied excitation = Synchronous
• Angle between rotor and stator flux can be regulated to determine torque
• Rotor position can be measured or estimated
1 2 3 4 5 6 1 CONTINUOUS
• BLDC Motors • PMSM Motors
– Easier to control (6 Trapezoidal states) – More complex control (continuous 3Ph Sine Wave)
– Torque ripple at commutations – No torque ripple at commutation
– Better for lower speed – Higher max achievable speed
– Noisy – Low noise
– Doesn’t work with distributed winding – Work with low-cost distributed winding
– Not as efficient, lower Torque – Higher efficiency, higher Torque
– Lower cost – Higher cost
V Φm Lm R(s)
NOMINAL
TORQUE I m = (Vm / 2π f L m )
TORQUE Φ m = (Vm / 2π f)
Vo
At low speed: Rs is no longer
negligible: Vm < V
LOW SPEED NOM SPEED SPEED A large portion of energy is now
wasted.
The V/Hz regulation scheme is the simplest one that can be applied to an asynchronous mo-
tor. The goal is to work in an area where the rotor flux is constant (Volts proportional to
speed).
In practical solutions, the speed sensor is optional as the control is tuned to follow a prede-
fined “speed-profile versus load table”, assuming the load characteristics are known in ad-
vance.
Obviously, this type of control bases itself on the steady electrical characteristics of the ma-
chine and assumes that we are able to work with a constant flux in the complete speed range
the application targets. This is why this type of control does not deliver a good dynamic per-
formance and a good transient response time; the V/Hz profile is fixed and does not take into
account conditions other than those seen in a steady state. The second point is the problem at
startup of AC induction motors, which cannot deliver high torques at zero speed; in this case,
the system cannot maintain a fixed position. In practice for low speed, we need to increase
the delivered voltage to the stator compared to the theoretical V/Hz law.
A typical characteristic of FOC - PWM command strategy is that the envelope of the
generated signal is carrying the first and the third harmonics. We can interpret this as a
consequence of the special PWM sequence applied to the power inverters. Literature also
mentions the third harmonic injection to boost out the performance we get out of the DC bus
capacitor. This third-harmonic exists in the phase to neutral voltage but disappears in the
phase-to-phase voltage.
Is ωstator
Is Is D
Iq
π/2 Id
2π/3 Torque Component Flux Component
2π/3
β
b
c 2π/3
Ια t
Torque Component
IQ
ic ia ib t
t Flux Component
Ιβ t ID
t
ACI
– Measured
• Tachometer: Square wave output proportional to speed
– Estimations
• Angle estimated from Integral of Sinusoidal Back EMF Voltage with closed
loop voltage compensation
• Speed estimated from Estimated Flux, measured current, and motor model
PMSM
– Measured
• Encoder: 2 Square waves give position, speed calculated by change over time
• Resolver: SIN + COS waves give position, speed calculated by change over
time
– Estimations
• Angle estimated from Integral of Sinusoidal Back EMF Voltage with Sliding
Mode Observer technique
• Speed calculated from change in angle over time
FOC
• System responds faster to changes in set point or load change
• Minimum speed at full load is now essentially zero
• Starting torque is increased
• Very little torque ripple
• Reduces Cost
• Optimally size motor for the task at hand
• Current controlled, so the inverter can be optimized
DC bus
capacitor − Three phase
outputs which
go to the motor
terminals
Power
Switching
Devices
Inputs
Triangular Switching Frequency (5-25 kHz typically)
Sine wave = Carrier Trying to match (V or I Reference, 0-1000 Hz typically)
Image not to scale; Typically 100s of triangle periods in each Sine wave
Output
When they cross, you switch the PWM
θ S1
V180 (110) 0 (111) 0 (000)
0 d
S4 S6
Shunt Tacho
resistor Or
Resolver
ADCIN2
ADCIN3 Signal
Conditioning
ea
eb
MCU
+ DC Bus ec
Tx PWM1
Serial Timers PWM2
and PWM PWM3
Rx (UART) PWM4
Compare PWM5
Units PWM6
PWM1 PWM3 PWM5 Three-phase
SIMO SPI BLDC machine
Capture CAP1
SOMI (Synch CAP2
CLK Unit CAP3
Serial)
STE
CAP1
PWM2 PWM4 PWM6 CAP2
ADC ADCIN0 CAP3
DC Shunt
0 / 120 / 240 deg
position
information
(e.g., Hall
Signal sensors )
Conditioning
ea
MCU
DC Bus eb
+
Tx PWM1 ec
Serial coms Timers PWM2
and PWM PWM3
Rx (UART) PWM4
Compare PWM5
Units PWM6
PWM1 PWM3 PWM5 Three-phase
SIMO BLDC machine
SOMI SPI Capture
CLK Serial coms Unit
STE
ADCIN1
ADC
ADCIN2 PWM2 PWM4 PWM6 No
ADCIN3
ADCIN0
sensors !
DC Shunt
ADCIN1 Phase
Signal ADCIN2
ADCIN3 Voltage
Conditioning Meas
DC Bus 1.00 ea eb ec
+ 0.50
Tx PWM1 0.00
1 24 47 70 93 116 139 162 185 208 231 254 277 300 323 346
ωt
Timers PWM2 -0.50
Serial coms
and PWM PWM3 -1.00
Signal
Conditioning
10/28/2009 28
Methodology
- Highest precision & most numerically accurate
- Modular libraries (C source) for easiest re-use and customization
- Removal of fixed point scaling and saturation burden
- Easiest to tune for your custom motor
- Documentation: DMC theory, software, BOM, schematics
Achieved by
- IQMath
- Application Frameworks: DMC Library & Incremental Build
- Partner Tools for simulation, GUI programming, and auto code gen
IQ – Math Functions
IQMath
• Library and Compiler Intrinsic
– Move your decimal point to where you need it
– Write in floating point, compiler does all the work
Probably one of the most important advantages of programming in IQMaths is the ability to
switch from a fixed-point environment to the floating-point processor world. When the
programmer uses a conditional compilation technique, based on “#if – else – end if”
directives, the same C code can be used for fixed-point and floating-point translation.
Simulation
Or IQMath
Algorithm
Y = _IQmpy(M, X) + B;
Configure Math Type In IQmath Header File
#if MATH_TYPE == IQ_MATH #if MATH_TYPE == FLOAT_MATH
Automatically Converts To:
continue to be serviced
Debug
Texas Instruments Digital Motor Control (DMC) Library is available free of charge and
can be downloaded from the Texas Instruments website. It consists of a number of useful
functions for motor control applications. Among those functions, there are pure motor con-
trol modules (Park and Clark transforms, Space Vector PWM etc) as well as traditional
control modules (PID controller, ramp generator etc) and peripherals drivers (for PWM,
ADC and others).
Based on this DMC library, Texas Instruments has developed a number of application
notes for different types of electrical motors. All applications examples are specially de-
signed for the C2000 platform and come with a working example of the corresponding
software, background information and documentation.
One branch of this library is dedicated to the F2833x and takes advantage of the 32-bit IQ-
Math data format.
The following slide shows the software modules available for the C2000 family:
DMC Library
Blocks are Modular C functions
- Variables as Inputs, Variables as Outputs
- Library of Source Code
- Most are IQ based, tune to your stability needs!
Multi-page
Documentation
& Theory of
Operation for
each module
Application Frameworks
Connect Blocks In C:
// Connect SVGEN Block: This module abstracts all the PWM
svgen_dq1.Ualpha = ipark1.Alpha; registers. Does all the work for you –
svgen_dq1.Ubeta = ipark1.Beta; every period – based on the changing
// Execute SVGEN Block:
duty cycle calculations from SVGEN
svgen_dq1.calc(&svgen_dq1); and your system frequency. You don’t
even need to write to the peripheral
registers!
What the user has to do is simply to select the correct blocks, to define the variables for input
and output lines of the corresponding blocks and to connect these “lines” by passing
variables. All modules are supplied with a dedicated documentation file.
For example, the file “pid_reg3.pdf” explains the interface and the background of the PID-
controller:
All functions are coded for 32-bit variables in IQ-Math-format. The functions are used as
instances of a predefined object class, based on a structure definition in a header file.
These solutions follow a simple principle for testing the software, accessing the power drives
and closing the control loop: an incremental build methodology. The basic idea is to define a
macro and to use a conditional compilation (called: “Build Level”) to include more and more
modules into the final machine code. Such a technique is very helpful when the user tests a
motor drive system for the very first time.
The following slides explain this sequential method with the example of a PMSM Field
Oriented Control System.
An oscilloscope is used to monitor the shape of the PWM signals and the pulses series
generated by the SVGEN module.
Build Level 2
Build Level 3
Build Level 4
Build Level 5
Build Level 6
Why: In an AC-Rectifier, the 3-phase inverter stage and the motor act
as a non-linear load and will draw harmonic currents from the line.
These harmonics result in losses and such currents can distort the
line voltage.
Some countries and regulatory bodies limit the distortion to the line
a product can inject (see IEC 61000-3-2).
How: Generate an intermediate DC Bus from an AC source while
drawing a sine wave input current that is exactly in phase with the
line voltage
A PFC stage has become an integral part of most power supply
designs…usually done with a standalone PFC chip…why not have
the MCU control this digitally!
A set of base boards allows the user to go deeper into different application areas, such as
Digital Power Supply or Digital Motor Control.
For Digital Motor Control the following package includes all you need to experiment with
PMSM motors.
Summary
• Search for literature number “sprc922.zip” to obtain the board specific software
• Search for literature number “sprc675.zip” to get the software baseline for this kit
• Search for literature number “SPRUGQ1” to get the Quick Start Guide for the
board.