Professional Documents
Culture Documents
SENSORLESS CONTROL OF
BRUSHLESS DC MOTOR USING BACK
EMF COMMUTATION
By David BOMASSI
May 2000
Brushless dc motors require rotor position information for commutation and speed
control. Resolvers, encoders or Hall effect devices are often used but they increase cost and
size of the system. Therefore, a great deal of work on sensorless control of brushless dc
motor has been carried out for a few years. This report describes the principles and
implementation of a sensorless control system using the principle of Back Electromotive
Force (back emf) Commutation. As the proposed control scheme uses an open loop
procedure to start the motor, the open loop to closed loop transition has been investigated.
The system allows a rehable control and reversal of the motor, even at low speed. The
implementation of the control algorithm in a TMS320F240 DSP is described. The test
results on a 20 V, 10000 rpm, two-poles motor have been found satisfactory when run with
no load. The load tests, made by holding the shaft, showed that the motor sometimes
stopped at low speed.
11
Acknowledgements
I wish to thank Texas Instrument for giving me the DSP system to carry out the
work. I also thank Doctor Iain Hunter from Texas Instrument, and Liviu Kreindler and
Aurelian Sarca from Technosoft for having answered my numerous questions about the
DSP boards. Lastly, most importantly, I thank very much Doctor Suleiman Abu Sharkh,
my supervisor for this project, for his great support, his instructive comments, and for
helping me to settle at university in England.
( Oiucnl^ Hi
Contents
Abstract i
Acknowledgements ii
Contents in
Introduction 1
1.4 COMMUTATION 6
4 Implementation 26
4.1 INTRODUCTION 26
Conclusion 58
References 59
List of figures
Figure 1-1 Ideal Brushless do motor waveforms of flux density, emf, and current 5
Figure 1-2 Torque speed characteristic of ideal brushless dc motor 6
Figure 1-3 System diagram 7
Figure 1-4 Position of the Hall effect devices 7
Figure 1-5 Waveforms of the logic circuit for a clockwise rotation of the rotor 8
Figure 1-6 Waveforms of the logic circuit for a counterclockwise rotation of the rotor 8
Figure 1-7 Hall effect device 9
Figure 1-8 Schmidt trigger circuit for the Hall effect sensors 10
Figure 1-9 Picture of a resolver 10
Figure 1-10 Resolver diagram 11
Figure 1-11 Optical encoder disks, (a) Incremental, (b) Absolute 12
Figure 1-12 Stator terminal electrical model 13
Figure 1-13 Equivalent circuit of the motor if switches 1 and 4 are on 14
Figure 2-1 Sensorless circuit 17
Figure 2-2 Basic Sensorless Additional Hardware 19
Figure 2-3 Detection circuit for conduction of free-wheeling diodes 20
Figure 3-1 Terminal voltages (and their integral) and Hall effect waveforms for PM
brushless dc motor 22
Figure 3-2 PWM principle 23
Figure 3-3 Speed control system 24
Figure 4-1 The open loop circuit (Ptl) 28
Figure 4-2 Waveforms simulations 30
Figure 4-3 Diagram of the circuit (Pt2 and Pt3) 31
Figure 4-4 The circuit with the Allegro chip and the inverter (Pt4) 33
Figure 4-5 Top view of TMS320F240 Board 35
Figure 4-6 Top view of 1MMC240 Board 35
Figure 4-7 Top view of the DSP circuit 36
Figure 4-8 Top view of the circuit containing the sensorless circuit and the current
transducer 37
Figure 4-9 Top view of the box containing the circuits 37
Figure 4-10 The global system with the first inverter and the TMS320C24x Evaluation
boardfi-omTexas Instrument 38
Figure 4-11 The global system with the inverterfiromSeaeye Marine LTD and the
IMMC240 Evaluation boardfi-omTechnosoft (final prototype) 39
Figure 4-12 Speed measurement 40
Figure 4-13 Time of the speed test on the waveform of signal T3 41
Figure 4-14 Switching back to open loop mode 42
Figure 4-15 Global structure of the sensorless control 45
Figure 4-16 The open loop mode 46
Figure 4-17 Speed control in open loop mode 47
Figure 4-18 The current limiter 48
Figure 4-19 Switching from open loop to closed loop mode 49
Figure 4-20 Switchingfi-omclosed loop to open loop mode 49
Figure 4-21 The closed loop mode 50
Figure 4-22 Control of speed in closed loop mode 51
Figure 4-23 Terminal phase waveforms in open loop mode 52
Figure 4-24 Terminal phase waveforms in closed loop mode 53
Figure 4-25 Current waveform in a terminal phase 54
Figure 4-26 Theoretical and experimental phase shift angle due to the sensorless circuit.. 55
Figure 4-27 The output of the sensorless circuit compared to the output of the Hall effect
sensor 56
/////V'(///, //'"/
Introduction
Because of their high performances coupled with reliability and low maintenance cost,
brushless dc motor are increasingly used. For correct operation, the motor requires rotor
position information for commutation and speed control. Resolvers, encoders or Hall effect
devices are often used but they increase cost and size of the system. Furthermore, some
applications do not allow using such sensors. Therefore, a great deal of work on sensorless
control of brushless dc motor has been carried out for a few years (see references).
This project deals with a sensorless technique using the principle of Back
Electromotive Force (back emf) commutation. The terminal voltages of the motor are
manipulated to produce signals similar to those produced by Hall effect devices. The drive
was particularly developed for two applications : 1.) thrusters that need to be reversal and
to have a reliable starting (sensorless control reduces the cost of the expensive water tight
connectors), 2.) Downhole pumping and drilling where the motor has a 1-3 Km cable and
using sensors is not possible because the environment is hot (higher than 150°c) and the
cable is long. There are ICs in the market, which can do this back emf commutation, but
they have a poor starting and reversal performance, which can not be improved unless a
new system is developed.
Because the back emf is equal to zero at standstill, the motor can not be started using
this technique. Therefore, a special starting procedure had to be developed. It has been
chosen to accelerate the motor as a synchronous one, in open loop mode, until it reaches a
speed sufficient to be switched to a closed loop mode using the back emf commutation
principle. To enable the control at low speed, the algorithm allows going back to open loop
mode if the speed decreases below a certain value. The transition from one mode to
another is not easy and can lead the motor to lose synchronism, so investigations had been
made to try to improve this change. The control algorithm has been implemented in a
TMS320F240 DSP.
The developed circuit is novel and simpler than what has been produced before. A
reliable DSP program has been written for this circuit. The system runs a high speed, high
frequency motor, which a DSP on its own cannot do. It also has an open loop speed control
and a reliable reversal.
Before describing the developed system, this report will briefly present the general
theory of a brushless dc motor. It will also present a review of other sensorless control
techniques, which have already been studied, particularly those using the back emf
commutation principle.
1.1 Introduction
A brushless dc motor, as its name suggests, is a dc motor without brushes, slip rings
or mechanical commutator. Its configuration is equivalent to an inverted dc commutator
motor, i.e. the permanent magnet of the brushless dc motor rotates while the magnetic
windings remain stationary. For both configurations, the current flowing into the windings
must be commutated while the rotor moves in order to keep the torque unidirectional and
maximal. In the dc commutator motor, commutator and brushes perform the commutation.
In a brushless dc motor, it is performed by an inverter coupled with an electronic circuit.
The power transistors of the inverter must be switched in synchronism with rotor position,
which therefore needs to be known. Resolvers, encoders or Hall effect devices can be used
as position sensors but a sensorless system has less wires penetrating the enclosure which
reduces cost and size, increases reliability, and expands the application field of brushless
dc motor.
Although the winding distribution can also be sinusoidal, dc brushless motors are
taken to be motors with a trapezoidal winding distribution. Fig. 1-1 shows the waveforms
for an ideal brushless motor.
This section aims at briefly demonstrating that the speed of a brushless dc motor
can be easily controlled by varying the dc link voltage.
The basic torque and voltage equations of brushless dc motors closely resemble
those of dc commutator motors.
If the converter is supplied with an ideal direct voltage Vs, then at any instant the
following equation can be written for the dc terminal voltage :
Vs = E + R1 (a Ldi/dt term has been ignored for simplicity)
where R is the sum of two phase resistances in series and E is the sum of two phase emfs in
series.
Using this equation together with the emf and torque equation, we can derive the
torque-speed equation:
6) = 6)0 1 - ^
ky/
where is the flux linkage and k the armature constant.
///I' \ i/i ///I'/f/' 5
(a)
am
(b)
c 180° 360° ^
;
(C) V^i m
(d)
(e)
150°
(f) go = gal +
C
120°
1
(9) ib ia
ic 1 ib
Figure 1-1 Ideal Brushless dc motor waveforms of flux density, emf and current, (a) Motor
showing two coils of one phase, (b) Magnet flux density around the airgap. (c) Flux
linkage of coils 1 and 2. (d) emf waveform of coil 1. (e) emf waveform of coil 2. ( f ) emf
waveform of phase a. (g)Ideal phase current waveform.
The stall torque is given by
To = ky/Io
where
Vs
Io = -
R
The resultant torque-speed characteristics, shown in fig. 1-2, are similar to those for
a dc commutator motor. The motor speed can be easily controlled by varying the terminal
voltage, which can be achieved by chopping or pulse-width modulation (PWM).
Intermitent
V)pefation
ConUnuous
%eed
Figure 1-2 Torque speed characteristic of ideal hrushless dc motor
1.4 Commutation
The process of commutation is fundamental to the brushless dc and its control. The
commutation of the basic squarewave brushless dc motor is identical to the commutation
of a very simple dc commutator motor. Fig. 1-5 and 1-6 show the switching sequences that
must be applied to the power transistors of the inverter shown fig. 1-3. These sequences are
produced by an electronic circuit, which converts the signals from the position sensors or
the sensorless circuit to commutation pulses.
7
Inverter
3—|l~ 5—11"
DC link
voltage
Commutation logic
Vs
n l
6—,i-
D 1
[y
Ih
V.
Motor
H2
60°
m
{
••BO"
Hit
H.
(a)
(b)
Figure 1-5 Waveforms of the logic circuit for a clockwise rotation of the rotor, (a) Input
Hall effect devices signals, (b) Output: command of the inverter's transistors.
(a)
(b)
Figure 1-6 Waveforms of the logic circuit for a counterclockwise rotation of the rotor, (a)
Input : Hall effect devices signals, (b) Output : command of the inverter's transistors.
///u i/i' ///fV'/," P
Hall effect devices are low cost magnetic sensors. They are the most widely used
types of shaft position transducer for brushless dc motor and maybe the simplest shaft
position sensor used to generate commutation pulses.
semiconductor
t Hall voltage
A voltage proportional to the magnetic field applied to the device is generated when
the semiconductor is carrying constant current (supplied by an external source).
The hru^hL's.s (/c m-- 10
In a brashless dc motor, three Hall effect sensors are mounted on the stator frame
and are activated either by the rotor magnet or by a separate magnet. The mechanical
displacement between the three devices can be either 120° or 60°.
An additional Schmidt trigger (see fig. 1-8) is used to improve the quality of
waveform ; the switch opens or closes when the device is placed in magnetic field higher
than a certain threshold value, allowing the determination of the commutation instants.
Figure 1-8 Schmidt trigger circuit for the Hall effect sensors.
Hall effect sensors can operate at high frequency (higher than lOOkHz), are low
cost and highly reliable but they are also temperature sensitive and increase the size of the
system. They also need five wires, which is difficult in some applications like thruster or
downhole pump.
1.5.2 Resolver
Lead wire
Rotary transformer
Shaft
A resolver converts the displacement of the rotor into an analog signal. It can be
used when more information is needed than just commutation pulses. It is normally
The hrnsiilcs'^ iL iiiD/nr 1J
mounted on a shaft extension of the brashless dc motor at the non-drive end, without a
coupling. The operation is based on a transformer in which the coupling between the
primary and secondary coils is determined by the position of the primary coil, which
moves relative to the two secondary windings. The windings of the stator and the rotor are
distributed so that the magnetic flux is distributed in the form of a sinewave.
Sj 8,
Revolving transformer
:D c a i a :
The output from the resolver can be used either directly or after conversion to a
digital signal.
The resolver is attractive because of its ruggedness, resolution and its ability to
provide accurate absolute position and velocity signal from one sensor.
used when more information is needed than just commutation pulses. There are two types
of encoders : incremental encoders and absolute encoders.
Incremental encoders (see fig. 1-11 (a)) usually have two tracks, A and B, which
are in quadrature. Hence the direction of rotation can be known. As the wheel rotates, an
alternating signal is produced with a frequency, which is proportional to the speed of
rotation. An index pulse can also be provided as a simple absolute position reference
(semi-absolute encoder).
Absolute encoders (see fig. 1-11 (b)) are more complex. Their wheel is encoded
with a binary number, either in pure binary code or in Gray code, with one bit per track.
They can provide absolute position information with very fine resolution and high
accuracy.
Encoders allow a direct production of pulses that can be easily used in a digital
circuit. They have a fine resolution and a high accuracy but can not operate at such high
temperature as resolver and are not as rugged. Moreover, incremental encoders need a
start-up sequence to find the "home" position.
Index
(a) (b)
Figure 1-11 Optical encoder disks, (a) Incremental, (b) Absolute.
13
It is possible to perform the commutation without any extra sensors mounted on the
rotor. This is called sensorless control. Many systems use the back emf to determine the
rotor position, however, there are other methods.
1.5.4.1.1 Theory
The back emf sensing is based on the fact that for a three-phase brushless dc motor
with a trapezoidal flux distribution, only two phases are energised at a time and the current
in one phase is then off for 60 electrical degrees. The terminal voltage is therefore equal to
the back emf during that period. In a two-pole brushless dc motor, each of the back emfs
crosses zero twice per mechanical revolution and the zero crossing points depend only on
the rotor position. These points can then be used to generate commutation information. The
zero crossing points can be detected by either directly measuring the instantaneous voltage
across the nonconducting phase (if the current in the nonconducting phase reduces rapidly)
or by extracting the piece of information from the measurement of the three phase
voltages. We will see later that the developed system uses the last method.
i
1 —,f-
i
V.
1-
Assume that switches 1 and 4 (see fig. 1-3) are on. Fig. 1-13 shows the equivalent
circuit at this time.
Then
VA = VS = {R +LS).IA +EA + VN (1)
=o= (2)
Fb = & + (3)
adding (1) to (2) we have
Vs = EA + EB + 2.VN
= (4)
2 2
We know that Ea+Eb+Ec=0 (three-phase system)
If Ec=0 then EA = -Eg
Then from (4)
(5)
2
and from (3) and (5)
Vc — VN = — Vs
2
/'//(.' iviis/i/css , A • n!<ii< J5
We can therefore conclude that at the zero crossing point of Ec, we have
The way the terminal voltages are processed to detect the back emf zero crossing
points in the developed system is explained in paragraph 3.1.
A starting procedure must be implemented to start and accelerate the motor until it
reaches a speed sufficient for the back emf principle to be applied. The idea of using a low
cost auxiliary sensor to identify the initial rotor position can not be satisfactory, since the
interest of the sensorless control is precisely to avoid using such a sensor.
In another method, the motor is started as a synchronous one and is then reverted to
a brushless dc motor switching regime at speed. It could still result in temporary reversal
but avoiding the energising and aligning state gives a quicker start. This is the method,
which has been chosen in the developed system.
rhc hiiishlc\s (/V iUDinr 16
Even if the back emf commutation principle is probably the most popular method
used to replace the position sensors of a trapezoidal brushless dc motor, there are some
other techniques. These techniques are mainly used with sinusoidal brushless motor, to
which the back emf commutation principle can not be applied (because the three motor
windings are energised at a time, and the current does not fall to zero apart from instantly).
Both the motor's phase voltages and currents can be measured to estimate the flux
linkage or even the flux linkage space vector [1]. The rotor position can then be deduced
from the flux linkage space vector angle or from the flux linkage versus position
characteristic. However, this technique suffers from integrator drift and therefore needs an
additional technique to compensate for it, which complicates the system. For example, an
observer can be used to update the motor model and compensate for integrator drift. A
corrected flux linkage estimation scheme can be used for both sinusoidal and trapezoidal
brushless dc motors [2], [3],
Another approach uses the fact that the difference between the ideal applied voltage
(calculated by using the instantaneous voltage equation of the motor and the detected
current) and the actual one is proportional to the angular difference between the
hypothetical and actual rotor position. An algorithm can then be used to reduce this
difference to zero [4], The same method can also be used in measuring the difference
between the ideal and actual currents [5].
The terminal voltage sensing circuit (see fig. 2-1) converts the three terminal
voltages into three signals similar to these of Hall effect devices separated by 120 electrical
degrees. These signals are then logically converted by a microcontroller to produce the
switching pulses.
The terminal sensing voltage circuit simply consists of three low-pass filters, one
for each phase, providing a 90 electrical degrees delay of each terminal voltage. These
signals are then compared to the neutral point voltage VN, which is obtained from a resistor
star-connected circuit.
H h
rti
4 h
m hi
As seen earlier, the motor can not be accelerated from standstill using the back emf
principle. The motor is therefore started as a synchronous one and then reverted to a
brushless dc controlled motor when the speed reaches a certain value.
2.1.3 Discussion
This method is interesting because it really tackles the problem of the change from
open loop to closed loop mode, trying to avoid the motor stopping during the change.
The control system needs an additional analog hardware to replace the sensors but
this circuit is very simple.
It seems that nothing has been done to control the motor at very low speed. The
open loop mode only aims at starting the motor and can not be used to control the speed.
The TI circuit directly measures the terminal phase voltages with a resistance
bridge and the ADC inputs of the DSP (see fig. 2-2). The DSP numerically computes the
back emfs and detects the zero crossing points. Then these points are delayed of 30
electrical degrees, still thanks to the DSP, in order to obtain the instants of phase
commutation.
1 Stator
Bhase
- i C Cable ADCINxof
, yiePSP
,1-
1 ^
Figure 2-2 Basic Sensorless Additional Hardware
According to Texas Instrument, this solution does not need any open loop starting
strategy. The algorithm implemented in the DSP allows acknowledging the initial rotor
position. Then the 60 degrees sector adjacent to this position is fed with direct current and
the back emf zero crossing detection algorithm can immediately start.
2.2.3 Discussion
This method does not need any additional hardware to replace the shaft position
sensors, the DSP board handles everything. This makes this solution really cost effective
and reliable.
According to Texas Instrument, this solution does not need any additional starting
strategy, which eliminates the problem of the mode change when an open loop start up is
20
used to accelerate the motor from standstill. This also means that this solution could be
used in a wide range of speed control applications, including very low speed.
It can be shown that detecting the on/off state of these diodes can produce signals
that lead the commutation instants by 30 electrical degrees. Therefore the position
information can be obtained from these signals.
Fig. 2-3 shows the circuit used to detect the on/off state of the diodes.
According to the authors, this method allows the detection of rotor position even at
very low speed. Nevertheless, it is impossible to detect the position at standstill. Therefore
"/ ///c /kfi/ (V/// c/////;////,/^/vV/iv/Vu 27
a special starting procedure is still needed. To start the motor, two arbitrary phases are
excited, then the motor aligned itself with the magnetic field created by this two phases,
and next the commutation signal that advances the switching pattern 120 degrees is given.
Then the circuit is immediately switched to the sensorless drive. This starting procedure is
very close to the one used by Texas Instrument and described in the precedent paragraph.
2.3.3 Discussion
The main advantage of this method, on top of its originality, is that it allows
detecting the rotor position even at low speed, which not only simplifies the starting
procedure, but also allows controlling the motor in a wide range of speed.
The additional circuit required to detect the state of the free-wheeling diodes is very
simple.
///I'nrr u/ //ft' (/('I 22
Vr
Vy
Vb
Wr
Wy
Wb
Hr
Hy
Hb
0 60 120 180 240 300 360 420 480 540 600 660
Figure 3-1 Terminal voltages (and their integral) and Hall effect waveforms for PM
brushless dc motor (Waveforms do not include diode conduction spikes for simplicity).
/"//('u/y fV ///c (/(.'Vi'/n/x't/ c'v/mV \i Vi /// 23
The waveforms Wr, Wy, Wb are simply produced by integrating the signals Vr, Vy
and Vb. They are then compared to the neutral point voltage to produce the signals Hr, Hy
and Hb. (see paragraph 4.3.3 for a complete explanation of the process).
Wr = jVr.dt
Wy - jVy.dt
Wb = ^Vb.dt
and
Hr>0 when Wr >0
Hy>0 when Wb<0
Hb>0 when Wy>0
An open loop function must generate signals, which have the same pattern as the
Hall effect signals and increasing frequency. When the rotor speed is sufficient, the system
is switched to a closed loop function, which uses the principle of back emf commutation.
Vmax
Then dc hnk voltage can be adjusted by varying the on-duty cycle y j , of the PWM
The average voltage applied to the terminals of the motor is equal to Fmax
Speed
Speed
demand
error
Controller System
Measured speed
Speed measurement
system
For example, for a simple proportional controller, if Un is the value of the on-duty
cycle of the PWM signal at the instant n, then we can have : Un = Un-\-^ K x error.
To simplify the system, no full current control loop has been used in the drive.
However, an effective current limiter is necessary to protect the system from excessive
current. This current limiter will only operate when the maximum set current would
otherwise be exceeded.
The simplest way to limit the current is to chop the dc link voltage when the current
is about to exceed the maximum allowed.
riu'oi'v i>i ihc ilcwhipci! i omroj s\mc/i! 25
Unlike the usual dc motor, the method of changing the voltage polarity of two
terminals of the armatures to change the rotor direction can not be adapted to the brushless
dc motor. The change can only be realised by changing the conducting sequence of the
commutation logic, which will change the direction of torque and then (at least with no
load) the direction of rotation.
Fig. 1-5 and fig. 1-6 of paragraph 1.4 show the two different sequences for both
directions.
ImplcDtciiiiii loll 26
4 Implementation
4.1 Introduction
The first part of the project has been dedicated to the building of an analog control
circuit to test the principles in order to quickly know the main problems that can arise with
such a system. Next, a digital control circuit based on the TMS320F240 DSP from Texas
Instrument, and using the same principles, has been built.
Although the control system aims at being used with a wide range of motors, all the
tests have been made with the same motor. The brushless dc motor used is a three-phase
Y-connected motor. The stator phase inductance is 480 mH and the phase resistance is 7.5
ohm. The maximum continuous current is 850 mA and the peak current is 3 A. The
maximum recommended speed is 15000 rpm and the maximum continuous torque is 17
mN.m (up to 10000 rpm). It has a trapezoidal back emf waveform shape and is supplied
with direct current. The maximum dc bus voltage is 20V.
The aim of building an analog circuit was not to obtain an efficient system that
could have been eventually used as the control hardware, but to test the principles in order
to find out the main issues and then use it to build a better digital system.
The developed circuit can be divided into four parts. Part Ptl (see fig. 4-1) aims at
generating the switching signals of the open loop mode, which are needed to accelerate the
motor from standstill. Part Pt2 (see fig. 4-3) is the sensorless circuit, it converts the
terminal voltage signals to signals similar to Hall effect signals. Part Pt3 (see fig. 4-3)
switches the circuit to open loop or closed loop. Finally, part Pt4 (see fig. 4-4) includes the
Allegro chip whose function is to convert the Hall effect signals to signals driving the
inverter's transistors.
4.3.1.1 PRINCIPLE
Part Ptl produces synchronous signals (the switching signals) to accelerate the
motor from standstill. Their frequency is ramped up to increase speed to a speed sufficient
to switch to closed loop mode, or to the speed demand if it is lower. The circuit also
produces signals whose frequency decreases if the speed demand is lower than the actual
speed. It allows controlling the motor speed within very low speed in open loop mode,
which is not possible in closed loop mode because of the insufficient back emf at low
speed.
The potentiometer RVl determines the value PI of the switch from open loop to
closed loop and vice versa. U1 is a voltage follower whose output is PI.
U2 is a ¥/Y converter. Since its input is obtained from the output of the HC4053N
component, we can consider that its output S represents the motor speed. Actually, S can
be either quite exactly the motor speed (closed loop) or almost the motor speed (open
loop). During the open loop, S is indeed equal to the value of the output of the ramp
generator and we expect the motor speed to be as close to this value as possible but it will
not always be the same. The potentiometer RV2 has to be adjusted so as the rate of U2 is
the same as the one of the V/F circuit (in fact, as the frequency of the output of the
HC4053 component is three times as much as the one of the V/F circuit, the F/V circuit
rate must be three times as much as the V/F circuit rate).
4) HC40S3N
GND1
¥ GND1
LM2S17NS
I Relay 5
I GND1
RL2 Relay 24V
RL1
1N4148
f > to Pt3
3 - ^ LM311 _/YYY\
U6
—^ LM393
LM358 U3
GND1
GND1 9-10-11 GND1
74HC4053N
(Pt3) GND1
_ / LM393
U4
P2
Speed demand
0-5V signal
GND1
liuplcllicilhl! i')!! 29
If S becomes greater than Pl+el, the output of U4 will be equal to +5V. The
system will be switched to closed loop and the relay will connect the input of U5 to PI so
as the output of the ramp generator is maintained at PI. Hence we will be able to decrease
this value from PI when the system is switched again to open loop. The system works in
open loop as long as S is greater than Pl-e2 (see fig. 4-2).
fl-e2 =— ^ P\
R\ + R2
f l + gl = — fl+ ^
Rl^Rl R\ + R1
The output of this circuit drives a 4bits D-Latch counter (MM74HC175N chip) that
is designed to produce outputs similar to Hall effect signals.
hnplcnientation 30
voltage
motor speed
output of the
ramp generator
P1+e1
P1-e2
<2 time
w
Open loop mode Closed loop mode Open loop mode
voltage
P1+e1
P1-e2
Figure 4-2 Waveforms simulations, (a) Output of the ramp generator compared to the
motor speed, (b) Measured speed.
Switching from open loop to closed loop mode is achieved using a comparator (U4
of fig. 4-3) which compares the measured speed with the value determined by the
potentiometer RVl. Its output causes a 3-way two-pole analog switch (M74HC4053N) to
switch from open loop to closed loop signals Hr, Hy, Hb.
f
£ output of the LF411 chip
from th« op*n loop cireult
I LM331N
at 10 t
§
S
I MM74HCH175N
,3 Owl MV
To Allegro chip
(Pt4)
FROM -J
motok y- -J MC74HC4053N
suppt-r
NMH2405D
Uj
4.3.3 Sensorless circuit
4.3.3.1 PRINCIPLE
As seen earlier, the sensorless circuit converts the three terminal voltages to signals
similar to Hall effect signals.
This discussion refers to the principle explained in paragraph 3.1. Since access to
the neutral point of the motor may not be always possible, the direct measurement of line
to neutral voltages may be impossible. This problem is overcome by measuring the voltage
between each phase and the negative dc link, and then using a high pass filter to filter out
the dc component. The low pass filters for the three phases are simple RC circuits whose
cut off frequency must be below the frequency at which the circuit switches from open
loop to closed loop operation, in order to filter only the dc component of the signal. The
first experiments were made with a transition from open loop to closed loop at 3000 rpm,
and a cut offfi^equencyof 50 Hz (corresponding to a speed of 3000rpm) was found by
experiment to be satisfactory.
To derive the equivalent Hall effect signals from terminal voltage signals, an
integrator is required as discussed earlier. Simple RC integrator circuits are used because
of their low cost and small size. The value of Rs and Cs in the integrator circuits are
selected such that the cut off frequency is below the frequency at which the circuit
switches from open loop to closed loop operation, this time to filter all the components of
the signal (except the dc component). Again a cut off frequency of 50 Hz is selected for the
integrator circuits.
Additional resistors (R9, R13, R17) are also added to attenuate the terminal voltage
inputs, to ensure that the outputs of the combined high pass filter / integrator RC circuits
are within the range of specified outputs limits (LM339N comparator chip).
Inipleinentitiion 33
4.3.4.1 DESCRIPTION
Fig. 4-4 shows the commutation circuit with the Allegro chip and the inverter.
No speed feedback has been used. The motor speed was simply adjusted by varying
the value of a potentiometer. Vmotor
2N3804
T
1
28 2N3808 '|-
27
m 4
5
25
24 ^ To motor
23
0U033
7
22
18 IRFKZ
11
18 To other
17 —•channels
16
12
13
14 15
Figure 4-4 The circuit with the Allegro chip and the inverter (Pt4)
iiiiplcnh'iiliiiuui 34
The circuit successfully accelerated the motor to speeds of about 10000 rpm with
no load. The open loop not only allowed to accelerate the motor from standstill but also to
decelerate to speeds below the minimal speed of the closed loop, and to control the motor
at very low speed (about 60 rpm).
Nevertheless, the change of state from open loop to closed loop mode did not go
well. With no load, the motor sometimes stopped. With a load, it was even worse and the
motor stepped out almost every time. The same problem appeared for the change of stage
from closed loop to open loop mode. This showed the need to synchronise the two modes
to have a smooth change. This should be taken into account to build the program that is to
be implemented in the DSP for the digital control circuit.
4.4.1 Introduction
There are many advantages of using a DSP in the control circuit of a motor. First it
allows using the same circuit for a wide range of motors by just changing a few well
chosen parameters. Complex control functions and various types of controller can easily be
implemented. Moreover, adding a new function to the system by modifying the program is
much simpler than with an analog circuit.
Fig. 4-7,4-8, and 4-9 show pictures of the final prototype. Fig. 4-11 shows diagram
of the final circuits.
A first prototype has been made with the TMS320F240 Evaluation Module
introduced by Texas instrument. The board contains a DSP controller TMS320F240 and its
oscillator, a JTAG, a RS232 link and the necessary inputs and outputs connectors. Fig 4-5
depicts the EVM board.
Implementation 35
<r 200 mm
/\
©
a ^eem™'
'mmrnnr
UEicSS, 5 o a 110 mm
SS4^ 0
#32
I iNS
6 * It* iM^'KB* mm
9
L#W.= « M.gg
@A5$si;#isg&iK:
\/
After the software had been implemented and successftilly tested with the Texas
Instrument board, it has been decided to build another prototype using another evaluation
board : the IMMC240 board ft-om Technosoft. It contains the same DSP chipset as the TI
board but is smaller and cheaper. Of course it contains all the necessary peripherals as the
ADC unit, the oscillator and the required connectors. Since the DSP chipset is the same as
in the TI board, the program is almost the same for the two boards. There are just a few
changes to make on interrupts handling and memory allocation.
62 mm
C onnectm-to
the inverter
» #• •* •# •# # , « # * # *
>
i Conoectwto Ae
Serial conneaor sensorkss circuk
4.4.3.1 INVERTER
The first inverter used was built especially for this system (see fig. 4-10). Its power
switches were power MOSFETs IRFU014. Opto-diodes TIL 193 were also used to isolate
the DSP from the power circuit. The PWM outputs of the DSP were directly connected to
the inputs of the opto-diodes whose outputs drove the power MOSFETs. It could be used
with motor up to 40V, 3A.
It has then been replaced with another inverter from Seaeye Marine LTD, which
contains a more sophisticated opto-isolating circuit and allows to drive motor with higher
voltage (250V, lOA). It can also be directly confrolled by the DSP board.
The sensorless circuit (see fig. 4-8) is the same as the one used in the analog circuit
(see paragraph 4.3.3). Its three outputs are connected to three conventional inputs of the
DSP.
37
Implementation
TWagmnttnmmduc*
Connecby k r t h e
cmrco* kmmdoccr
transducer
r Motor
The opto-isolating circuit ^he inverter The sensorless circuit + current transducer
>
Figure 4-10 The global system with the first inverter and the TMS320C24x Evaluation
boardfrom Texas Instrument
I Speed demand
(0 to 5 V signal)
T
II\/1MC240 board
ADC2 ADC10
PWM2
! K)PA3
PWM3
+15V GND2
I
Opto-isolating circuit
PWM5 PWM6
I0PA113 14
lOPBO
GND1 CAP4
r
S' Direction
XINT2
I
switch
I
GND1
»^M339M
LM339N
Sena!
cabe LM339
8§
DSP CIRCUIT
A. Ve dc link
S-
% GND2
Motor
S E N S I N G CIRCUIT + C U R R E N T S E N S O R
^0
The system needs a reliable speed measurement algorithm to be able to control the
speed both in open and closed loop mode. This is achieved by measuring the period of one
of the six transistor's driving signals.
t f
start of the timer -Stop the timer
-Save the timer value as the
signal's period T
-Restart the timer
The first function that needs to be performed by the DSP is the start-up procedure.
The DSP must produce six synchronous signals, which can drive the inverter's transistors,
and which frequency can increase or decrease by step. The procedure must include a
current limiting function, and a speed control loop must also be implemented so as the
speed follows the speed demand even when it is not possible to run the system in closed
loop. This speed loop is very simple : the frequency is ramped up if the measured speed is
lower than the speed demand, in the other case, it is ramped down.
The DSP must be able to determine the right moment for switching from open loop
to closed loop and vice and versa. This is an important part of the algorithm since it has
been shown by the test on the analog circuit that changing the mode at an incorrect time
can make the motor step out. The idea to improve the change was to try to do it at a
41
particular point of the commutation sequence, like a rising edge of one of the signals Hr,
Hy or Hb (coming from the sensorless circuit).
Once the DSP has sensed that the motor speed is sufficient to switch the system to
closed loop mode, the switching procedure is launched. During this procedure, the DSP
waits for an interrupt corresponding to a rising edge of signal Hr from the sensorless
sensing circuit. As soon as the interrupt is acknowledged, the program is switched to
closed loop mode. This allows starting the closed loop mode at the beginning of a full
pulse sequence.
Experiments also showed that it was better to test the motor speed at the moment t
(corresponding to a rising edge of signal T3, see fig. 4-13) during the open loop.
T3 •
t
iV
Test if the speed is sufficient to switch to closed loop
mode
The same procedure is used to switch from closed to open loop mode. Once the
DSP has sensed that the speed is too low and that the program must be switched back to
open loop, it waits for the same interrupt before switching to open loop. This allows having
a smoother change since the beginning of the open loop procedure produces a rising edge
of T3 (see fig. 4-14). Experiments confirmed that it was the best time to change the mode.
^2
T3
Limiting the dc link current is very important, especially in the open loop mode
where high currents can flow in the motor windings if there is no current limiting function.
If the closed loop mode works properly, the current should be lower than in open loop, a
current limiter is used for more security. A current transducer senses the dc link current in
the circuit (see fig. 4-11).
liitplciiiciiiuiKin 43
In open loop, the current test procedure decreases the on-duty cycle of the PWM
signal if the measured current exceeds the current limit.
In closed loop, the current test procedure switches all the inverter's transistors off
if the current exceeds the limit. The transistors remain off until the current goes back below
the limit.
First of all, for the Texas Instrument evaluation board, the PLL unit is set so that the
CPUCLK runs at 20MHz based on the lOMHz quartz crystal provided on the EVM board.
For the development stage it is necessary to disable the watchdog unit: the two watchdog
dedicated registers must be set inactive. These two settings are automatically done by the
monitor (MON240) initialisation procedure in the Technosoft board.
The last thing to do to complete the DSP Controller core initialisation is to set the
core mask register correctly. In this application, interrupts xint2vec (hardware interrupt of
pin xint2), tpintSvec (timer 3 period completed), and capint4vec ( capture unit 4 interrupt)
are acknowledged.
The full compare unit is used to produce the commutation signals for the inverter. It
is set to generate symmetrical PWM signals at the frequency of 20 kHz with TIMER 1 as
time base and with the DEADBAND unit disabled.
The ADC unit is set to receive the speed demand voltage on channel 2 of ADCl
and the measured phase current on channel 10 of ADC2. We know that the ADC prescaler
value must satisfy the following formula :
SYSCLK clock period x prescaler value x5.5 > 5.5 jUs
This is required by the architecture of the ADC unit to ensure an accurate conversion. So
the prescaler value is set to 16, meaning that the sampling frequency is equal to 625 kHz.
Iiiiplciiicnuii inr, 44
Timer 1 is used as time base of the PWM signals and Timer 3 as a counter to
calculate the speed of the motor (by measuring the period of one of the six pulse signals
sent to the inverter).
Five constant parameters are used in the program. They are defined at the beginning
and can be easily modified to make the algorithm work with a different motor.
LIMIT is used to define the frequency at which the system switches from open loop
to closed loop mode and vice versa. The input prescaler clock of Timer 3 is set to 32, and
the CPU clock frequency is set to 20 MHz, so we can write the following equation :
Kp is used to define the proportional coefficient of the controller of the speed loop
in closed loop mode. The real coefficient is equal to A^/2048.
L HYST defines the value of the hysteresis value used to compare the measured
speed of the motor to LIMIT (to monitor whether the mode needs to be changed).
HYST defines the hysteresis value used to compare the actual speed to the speed
demand in open loop mode (to monitor whether the PWM signal frequency needs to be
modified).
CURRENT MAX is used to define the value of the maximal current allowed in the
motor (used in the current limiting procedure).
25 variables are used in this software, some of them need to be defined before the
control algorithm starts.
NUM is used as the length of the temporisation used to modify the frequency of the
PWM signals in open loop mode.
'///(// 45
FREQ is used as the measured motor frequency, its value is actually equal to the
period of the PWM signals.
DEMAND contains the speed demand value.
These three variables must all be initialised to #55000 at the beginning of the
program.
ERROR contains the difference between the speed demand and the actual speed.
Most of the other variables are used as binary words to test different situations in
the algorithm. Their meaning is explained in the program listing.
start
Init
Test direction
No
Yes
No-
Yes
Closed loop
Direction
No
inchanget
Yes
ieed<Spe(
No
limit ^
Yes
start
test_stop
test direction
produce synctironous
signal
Current test
S p e e d > S p e e d limit No
Yes
start switching
procedure
The first step of the open loop is a test to see if the motor has to be stopped (speed
demand = 0). This test allows stopping the motor very quickly, instead of waiting for the
/inpiciHi'iiliii/iiii 47
speed to be ramped down. Then the desired direction is acknowledged and the program is
restarted if the direction has to be changed. Then the six synchronous signals are produced
for 360 electrical degrees. Next, the frequency of these signals is modified in accordance
with the speed demand (see fig. 4-17). Lastly, the program goes back to the beginning of
the loop or is switched to closed loop.
start of ADJUST
Update speed
demand
Demand>mini k
Init DSP
emand >
Speed +
Hysteresis
Decrease period of
emand
synchronous signal
Speed
ysteresis
Increase period of
synchronous signal
End of ADJUST
The speed control of the open loop mode is very simple. If the measured speed of
the synchronous signals is higher than the speed demand, the frequency of the synchronous
signals is decreased by step. If it is lower, the frequency is increased.
////Vi/Z/L / ^8
The current limiter decreases the on-duty cycle of the PWM signals if the measured
current is higher than the maximal current chosen. Otherwise, the on-duty cycle is
increased.
start of
CURRENT_TEST
Current>Limit No
Yes
PMPRX+ERROR;
32>CMPRx LIMI No CMPRx-1<0 No
Yes Yes
End of
CURRENT_TEST
Return from Call
Before changing the mode, two speed tests must be made to avoid (as much as
possible) unexpected switching due to speed measurement errors. Once the two tests have
shown that the mode needs to be changed, the DSP just waits for the interrupts
corresponding to a rising edge of the signal T3 (INTl) before switching to the new mode.
first test
rrEsi=o)
open loop
TES1=0 TES1=0
closed loop
eed has be
Speed<limit —No > update
closed loop
TES1=0
open loop
-*
MonRof oulpuhofihe
sensorless circuit
Call CHANGE_DIRECTiON
TEST_ARRET
Call CURRENT_TEST
call TEST_TIME
In closed loop, the DSP monitors the outputs of the sensorless circuit to produce the
corresponding switching sequence driving the inverter's transistors. As for the open loop
mode, the DSP checks any change of the demanded direction of rotation. The procedure
also contains a current limiting function.
The TEST TIME procedure allows knowing if the measured speed has been
updated since the last PWM update. If it is the case, the PWM ratio can be updated again
by calling the ADJUST4 procedure, otherwise, no update has to be done.
51
The ADJUST4 procedure (see fig. 4-22) calculates the speed error by subtracting
the measured speed fi-om the speed demand. The DSP amplifies the speed error with a
controller and then calculate the new PWM ratio.
s t a r t of A D J U S T 4
Error=Demand-Freq
B u f f e r « C M P R 1 - K p x Error
Buffer<0
CMPRx=0
Buffer > C M P R x _ l i m i t
C M P R x = C M P R x LIMIT CMPRx»BUFFER
Endof ADJU6T4
Return f r o m Call
4.4.6 Results
The system successfully accelerated the motor to full speed (10000 rpm with a 20 V
supply) with no load. The current is well limited in open loop as well as in closed loop
mode. The speed can be easily controlled in both modes and, as expected, the algorithm
goes back to open loop mode when the speed is not sufficient to use the back emf
commutation principle. It is therefore possible to control the motor at very low speed
Implcmenialioii 52
(about 60 rpm). The reversal of direction goes very well in both modes. The transition
from open loop to closed loop mode is fine with no load or with a light load. However, the
motor sometimes steps out at the moment of the change if we increase the load. There is
also a problem with the motor torque, which seems to be lower than expected at low speed
in closed loop. These two problems will be discussed in paragraph 4.5.
10 VAliv 10 ms/div
Phase A
Phase B
Phase C
Figure 4-23 Terminal phase voltage waveforms in open loop mode (measurement with
respect to -Ve dc link)
Fig. 4-23 shows the terminal phase voltage waveforms of the open loop mode. The
PWM control allows limiting the current. The simple speed control, which has been used
worked very well, allowing to increase or decrease the speed quickly.
Fig. 4-24 shows the PWM control on the terminal phase voltage in closed loop
mode. The on-duty cycle of the PWM signals is equal to 1 at full speed (see fig.4-24 (c)).
55
lOV/dIv 2ms/div
Phase B
Phase C
1 0 V/div 2n>s'cJiv
10 V/div ans/div
f . Phase B
Phase C
Figure 4-24 Terminal phase voltage waveforms in closed loop mode, (a) 5500 rpm. (b)
9000 rpm. (c) full speed (10000 rpm).
finp/enienkirion 54
Fig. 4-25 shows that the current in open loop mode is also limited by PWM (the
current has been measured by using a 1 Ohm inductance in series with a terminal motor
phase).
The first problem which occurred is the change from open loop to closed loop
mode, which does not go well if the load is too heavy (the motor steps out). The way it has
been treated in the program has allowed improving this change, compared to the analog
system, but it does not seem to be sufficient. Therefore, more investigations should be
made and a possible solution could be the one proposed by K. IIZUKA et A1 [1]. This
solution consists in sensing the phase angle difference between the synchronous signal of
the open loop mode and the voltage sensing signal to be used by the closed loop mode. The
mode changes only if the speed is sufficient and if this angle is small enough. It allows
adapting the speed at which the mode changes to the motor load ; the higher the load, the
lower the speed.
55
With the values of the resistors and capacitors, which have been chosen, the
transfer function of the sensorless circuit is given by :
s
100. 1+ 1+
2&55 69 75
Fig. 4-26 shows the phase angle of the transfer function and the corresponding
unwanted phase shift a for different frequencies.
Phase angle -17 -47 -60 -64 -67 -72 -75 -77 -78 -78 -79 -80 -82 -83 -84
(degrees)
Shift angle a 73 43 30 26 23 18 15 13 12 12 11 10 8 7 5
(degrees)
Experunental 33 21 13 6 4
values
(degrees)
Figure 4-26 Theoretical and experimental phase shift angle due to the sensorless circuit
The experimental results (see fig. 4-26 and 4-27) show that the shift angle between
the signal from the sensorless circuit and the signal from the Hall effect sensor corresponds
to the theoretical shift angle of the transfer function.
In order to reduce this shift angle, we could choose to reduce the cut off frequency
of the circuit but we would then decrease the gain at high speed and would have to
compensate for it.
Implementation 56
Frequency = 35 Hz
Motor speed = 2140 rpm
Hall effect;
II SensorlesE
Frequency = 50 Hz
Motor speed = 3000 rpm
(b) - J Shift angle a = 21°
-T
Frequency = 150 Hz
Motor speed = 8800 rpm
(d) Shift angle a = 6°
5 V/div O 5 ms/div
1" fi Sen so Ft ess sensing c
Frequency = 170 Hz
Motor speed = 10000 rpm
Figure 4-27 The output of the sensorless circuit compared to the output of the Hall effect
sensor, (a) 2150 rpm. (b) SOOOrpm. (c) 5200 rpm. (d) 8800 rpm. (e) 10000 rpm.
Theoretical equations and experimental observations show that a cut off frequency
of 50 Hz is very close to be the best compromise to obtain a good signal for frequency
from 30 Hz to 170 Hz. This means that the problem can not be overcome only by
modifying the cut off frequency of the sensorless circuit.
The best way to do it may be to remove the sensorless circuit and to replace it with
a software algorithm implemented in the DSP, as it has been done in the solution proposed
by Texas Instrument [2], This would not only improve the sensorless signal but also reduce
the cost and size of the sensorless control system. However, it would need an additional
complex computation to calculate the neutral point voltages, sense the terminal voltages,
integrate them and compare them to the calculated neutral point voltage. The most
complicated part of the program would obviously be the test algorithm, which would have
to eliminate the errors due to high dV/dt and dl/dt glitches, which may occur at the instants
of phase commutation. These glitches can indeed generate Electro-Magnetic Interference
trouble and lead to a misreading of the neutral voltage. Furthermore, the program will take
longer to execute if we use the DSP to do the integration and find the zero crossing points,
and the sampling time could become too large for high frequencies and high speed motors.
A much simpler solution would be to keep the sensorless circuit and to add a
software algorithm to correct its output signals. For example, the DSP can be used to add a
phase delay to the signal only at low speed, and thus cancel the shift angle due to the
analog circuit. This solution has been tested at the end of the project but not long enough to
get valuable results.
( 'OUC/UMCI! 38
Conclusion
1. A sensorless drive using the back emf commutation principle has been designed
and built for brushless dc motors. The system is based on a TMS320F240 DSP
and uses an inverter made by Seaeye Marine LTD.
2. A sensorless control algorithm has been written for the DSP in assembly code.
3. The developed system is simple and novel. It runs a high speed, high frequency
motor. The developed algorithm contains an open loop speed control and a
reliable reversal. It has been especially designed to fulfil the requirements of
two applications ; underwater thrusters and oil well drilling and pumping
motors.
4. The experimental tests went well with no load. Problems occurred during the
load tests at the moment of mode change and at low speed in closed loop mode.
These problems have been explained and solutions have been proposed.
However, more investigations should be made to improve the change from open
loop to closed loop mode.
References
[1] R. Wu and G. R. Slemon, "A permanent magnet motor drive without a shaft
semoT,'" IEEE Trans. Ind. Applicat., vol. 27, no. 5, pp. 1005-1011, Sept./Oct. 1991.
[2] C. French and P. Acamley, "Control of permanent magnet motor drives using a
new position estimation technique," IEEE Trans. Ind. Applicat., vol. 32, no. 5, pp.
1089-1097, Sept /Oct. 1996.
[3] S. Grainger, M. Allan, T. Westwood, and R. Champaneri, "Sensorless control of a
trapezoidal brushless dc motor using the TMS320C25 DSP," Texas Instruments
Inc., 1996, Part#SPRA323.
[4] N. Matsui and M. Shigyo, "Brushless DC motor control without position and speed
sensors," lEEE-IAS Conf. Record, 1990, pp. 448-454.
[5] N. Matsui, "Sensorless PM brushless DC motor drives," IEEE Trans. Ind.
Electronics, vol. 43, no. 2, pp. 300-308, April 1996.
[6] M. Ichikawa, T. Takeshita, and N. Matsui, "Sensorless starting scheme of salient-
pole brushless DC motor," lEEE-IAS Japan Nat. Conv. Rec., no. 179, pp. 11-191-
194, 1995.
[7] K. lizuka, H. Uzuhashi, M. Kano, T. Endo, and K. Mohri, "Microcomputer control
for sensorless brushless motor," IEEE Trans. Ind. Applicat., vol. IA-21, pp. 595-
601, May/June 1985.
[8] "Implementation of a sensorless speed controlled brushless DC drive using
TMS320F240, " Texas Instruments Inc., 1997, Part #BPRA072.
[9] S. Ogasawara and H. Akagi, "An approach to position sensorless drive for
brushless dc motors," IEEE Trans. Ind. Applicat., vol. 27, pp. 928-933, 1991.
[10] N. Matsui and H. Ohashi, "DSP-based adaptive control of a brushless motor," IEEE
Trans. Ind. Applicat., vol. 28, no. 2, pp. 448-454, March/April 1992.
[11] S M Abu Sharkh and V. Baringer, "Design and performance of a new technique for
sensorless control of a downhole brushless PM motor, " IEEE Power Elect And
Var. Speed Drives, Conf. Pub. no 456, 21-23 Sept. 1998.
[12] P. Pillay and R. Krishnan, "Modeling, simulation and analysis of permanent magnet
motor drives-Part II: The brushless dc drive," IEEE Trans. Ind. Applicat., vol. 25,
no2, pp. 274-279, March/April 1989.
Ri'JcrciiL • 60
[13] M. Tomita, T. Senjyu, S. Doki, and S. Okuma, "New sensorless control for
brushless dc motors using disturbance observers and adaptative velocity
estimations," ," IEEE Trans. Ind. Electronics, vol. 45, no. 2, pp. 274-282, April
1998.
.!/)/v//(//.v. f f,///(/.' /v/// v / r / ) / i i //// ///(' / /('/^ /'/v; /
If a project has already been built, select Open in the Project menu and select your
project.
In the Project menu, select New and type the name of the project.
In the Add file to project window, find project.asm and select it.
In the Project Content window, select Settings.
In the Project Settings window, select Linker.
In the Linker window, select Memory.
Tick "Define an entry point" and type " main" in the white window.
Select OK.
In the Project Settings window, select OK
In the Project Content window, select OK.
"Done Updating dependencies for file project.asm" must appear in the output window.
In the Project menu, select Build.
You can now run the program by selecting Execute in the Project menu.
. /' /,/ / Y ' (.Y;////vV (/.wr/z/A/r rut/c 62
**$******************************************************************************
Description : sensorless control of brushless DC motor using the back emf commutation principle
Include files
•include f240regs.h
•include veots_a^h
•global rnain
•global retvalmon
Constant definitions
Variables definitions
•bss NUM.1
•bss OLFREQ,l
•bss FREQ,1
•bss TEST.l
•bss DEMAND,]
•bss MINUS,]
•bss INPUT, 1
l/Yiiv/f/Av /i' /if/./ 'I i u,/r 63
•bss PER.1
.bss TESI.l
.bss
.bss STACK.6
.bss SWITCHES,!
.bss ACTR2,1
.bss COMPT.l
.bss BUFFER,]
,bss ERROR,!
.bss KERROR,!
.bss NUL,1
.bss DACOVAL,!
.bss m.1
.bss DIR,1
.bss CALC.l
.bss CURENT,!
.bss LP.l
.text
Interrupt vectors
LDP #0
SPLK #TRIGGER,xint2vec
SPLK #PERIOD,tpmt3veo
SPLK #CALCUL,capint4vec
DSP settings
;Set up one Wait States for I/O space (DAC needs one wait state)
MAR *,AR1
LACC #000411
SACL »
OUT »,WSGR
linitiaUze values
LDP #NUM
SPLK #55000JvtUM ;the starting frequency
SPLK #0,PER
SPLK #OCFFFH,FREQ
SPLK #OCFFFH,DEMAND
SPLK #0,TES1
SPLK #0,TES
SPLK #0,NUL
SPLK #0,CURENT_MAX
SPLK #0,DIR
SPLK #55000,NUM
; timer 2 setting
LDPK #232
SPLK # 100100010100001 Ob.T2CON
SPLK #5000,T2PR
SPLK #500J2CMPR
SPLK #0FFFEh,T2CNT
SPLK #0H,T3CNT
SPLK #1001010100000010b,T3CON
SPLK #10001 lOOOOOOOOlOb.CAPCON
SPLK #1110000001 lOlOlOb.GPTCON
LDP #0
SPLK #OCH,IMR ;enable int3 and int2 only
^external interrupt 2
LDP #OEOh
SPLK #1,XINT2
open loop
OL3:
CALL CHANGE DIR ;test wether the direction of rotation needs to be changed
. /-I )( ' tv;////vV (Avsi'/y/A/r ( "</(.' (^6
LDP #0E8h
SPLK #002(%ACTR
CALL TEMP
LDP #0E8h
SPLK #020Ch,ACTR
CALL TEMP
LDP #0E8h
SPLK #02C0h,ACTR
CALL TEMP
LDP #0E8h
SPLK #0C2h.ACTR
CALL TEMP
LDP #0E8h
SPLK #00C02hACTR
CALL TEMP
OL3B:
CALL CHANGE DIR ;test wether the direction of rotation needs to be changed
LDP #0E8h
SPLK #020Ch,ACTR
CALL TEMP
LDP #0E8h
SPLK #02Ch.ACTR
67
CALL TEMP
LDP #0E8h
SPLK #0C20h,ACTR
CALL TEMP
LDP #0E8h
SPLK #0C02h,ACTR
CALL TEMP
LDP #0E8h
SPLK #OOC2h,ACTR
CALL TEMP
LDP #0E8h
CLRC INTM
CALL ADJUST ;call the speed adjustment procedure
CALL CURRENT TEST2 ;call the current limiting procedure
B TESTS ;test whether the system can be switched to closed loop mode
LDP #BUFFER
SACL BUFFER
B LIMITEUR
LDP #224
LACC ADCFIFOl
LDP ^DEMAND
SACL DEMAND
SUB #50000
BCND ARRET.GT
CLRC INTM
B WOL3
TEST ARRET2:
LDP #224
LACC ADCFIFOl
LDP #DEMAND
SACL DEMAND
SUB #50000
BCND ARRET,GT
CLRC INTM
B WCL3
BCND WOL2.GT ;between closed loop and open loop mode (+hysteresis)
CLRC SXM
LDP #TES
LACC TES
LDP #TES1
SACL TESl
B WOL2
TESTS:
SUB TES
BCND WOL2,EQ
SPLK #0,TES1
LACC FREQ
SUB #LIMIT
ADD #L_HYST
BCND WOL2.GT
B TESTSb
TEST5b:
LDP ^DEMAND
LACC DEMAND
SUB )?LIMIT
ADD #L_HYST
BCND WOL2,GT
LDP #0
SPLK #ODh,IMR
LDP #OEOh ;enable the X1NT2 interrupt if two consecutive speed test
SPLK #1^INT2 Jiave shown that the speed is sufficient
B WOL2
LDP mm
LACC DIR
BCND CL3.EQ
B CL3B
SFR
SFR
SACL MINUS
MPY MENUS
MPY MINUS
MPY MINUS
ADD NUM
SACL NUM
LDP #232
SPLK #OFFFFH,EVIFRB
circ INTM
RET
;start timer 3
START TIMER;
LDP #232
SPLK #0,T3CNT
SPLK #1001010101000010b,T3CON
SPLK #OFFFFH,EVIFRC
SUB #40000
BCND ARRBT,GT
LACC DEMAND
ADD #HYST
SUB FREQ
BCND FALL.LT
SUB #HYST
SUB #HYST
BCND RISE.GT
RET
; CLOSED LOOP
CL:
LDP UO
SPLK #OEh,IMR
CL2: CLRC SXM
B TEST_ARRET2
CL3:
CLRC SXM
LDP #NUM
SPLK #25000,NUM
SPLK #1J.P
LDP #OElh
LACC PADATDIR
LDP #INPUT
SACL INPUT
CALL T1
CALL T2
CALL T3
CALL T4
CALL T5
CALL T6
CALL CHANGE_DIR
LDP #ACTR2
LACC ACTR2
LDP #0E8h
SACL ACTR
CLRC INTM
CALL TEST_TIME
LDP #0
B TEST6
CLE:
74
LDP UO
SPLK #OEhJMR
CL2B:
CL3B:
CLRC SXM
LDP #NUM
SPLK #25000,NUM
SPLK #1,LP
LDP #OElh
LACC PADATDIR
LDP #INPUT
SACL INPUT
CALL TIB
CALL T2B
CALL T3B
CALL T4B
CALL T5B
CALL T6B
CALL CHANGE_DIR
LDP #ACTR2
LACC ACTR2
LDP #0E8h
SACL ACTR
CLRC INTM
CALL TEST_TIME
LDP #0
B TEST6
TEST6:
LDP #TES1
LACC TESl
BCND TEST7.EQ
B TESTS
TEST?:
LACC FREQ
SETC SXM
SUB #LIMIT
SUB #L_HYST
BCND WCL2.LT
CLRC SXM
LACC TES
SACL TESl
B WCL2
TESTS:
SUB TES
BCND WCL2^
SPLK #0,TES1
LACC FREQ
75
SUB #LIMIT
SUB #L HYST
BCND WCL2,LT
B TESTSb
TESTSb:
LDP #DEMAND
LACC DEMAND
SUB #LIMIT
SUB #L_HYST
BCND WCL2,LT
LDP #0
SPLK #OFh,IMR
LDP #OEOh
SPLK #1,XINT2
B WCL2
TIP:
LACC ACTR2
AND #OFFFCh
ADD #2
SACL ACTR2
RET
TIM:
LACC ACTR2
AND SOFFFCh
SACL ACTR2
RET
T2:
LDP #INPUT
LACC INPUT
AND #OCh
SUB #OCh
BCND T2P^Q
B T2M
T2P:
LACC ACTR2
AND #0FFF3h
ADD #OCh
76
SACL ACTR2
RET
T2M:
LACC ACTR2
AND #0FFF3h
SACL ACTR2
RET
T3:
LDP #INPUT
LACC INPUT
AND #06h
SUB #06h
BCND T3P,EQ
B T3M
T3P:
LACC ACTR2
AND iVOFFCFb
ADD #20h
SACL ACTR2
RET
T3M:
LACC ACTR2
AND #OFFCFh
SACL ACTR2
RET
T4:
LDP #INPUT
LACC INPUT
AND #06h
BCND T4P3Q
B T4M
T4P:
LACC ACTR2
AND #0FF3Fh
ADD #OCOh
SACL ACTR2
RET
T4M:
LACC ACTR2
AND #0FF3Fh
SACL ACTR2
RET
I'lipcihlix /' Si'iiMifU'ss lU.I' ci'iiinil iis.scnihiv onL' 77
T5:
LDP #INPUT
LACC INPUT
AND #OAh
SUB #8h
BCND T5P,EQ
B T5M
T5P:
LACC ACTR2
AND #OFCFFh
ADD #200h
SACL ACTR2
RET
T5M:
LACC ACTR2
AND #OFCFFh
SACL ACTR2
RET
T6:
LDP #INPUT
LACC INPUT
AND #OAh
SUB #2h
BCND T6P^Q
B T6M
T6P:
LACC ACTR2
AND #0F3FFh
ADD #OCOOh
SACL ACTR2
RET
T6M;
LACC ACTR2
AND #0F3FFh
SACL ACTR2
RET
T3B:
LDP #INPUT
LACC INPUT
AND #06h
SUB #06h
BCND T4P3Q
B T4M
T4B:
LDP #INPUT
LACC INPUT
AND #06h
BCND T3P,EQ
B T3M
T5B:
LDP #INPUT
LACC INPUT
AND #OAh
SUB #8h
BCND T6P,EQ
B T6M
T6B:
LDP #INPUT
LACC INPUT
AND #OAh
SUB #2h
BCND T5P,EQ
B T5M
;test if i>finax
PERIOD:
CLRC SXM
LDP #232
SPLK #1001010100000010b,T3CON
LDP #PER
SPLK #1,PER
LDP #232
79
SPLK #0FFFFH3VIFRB
LDP m
LACC IFR
SACL IFR
SACL BUFFER
B LIMITEUR
LIMITEUR:
BCND L1,LT
SUB #450
BCND L2.GT
LACC BUFFER
LDP #0E8h
SACL CMPRl
SACL CMPR2
SACL CMPR3
RET
LI:
LACC #0
LDP #0E8h
SACL CMPRl
SACL CMPR2
SACL CMPR3
RET
L2:
LACC #450
LDP #0E8h
SACL CMPRl
SACL CMPRl
SACL CMPR3
RET
LDP #232
LACC EVIFRB
AND #0001h
LDP #CALC
AND calc
cc ADJUST4.NEQ
RET
;switch to OL or CL when
TRIGGER:
LDP #0
SPLK mChJMR
LDP #LP
LACC LP
BCND INTER3Q
LDP #0E8h
LACC #300
sacl CMPRl
SACL CMPR2
SACL CMPR3
B WOL2
INTER:
LDP #0E8h
LACC #200
sacl CMPRl
SACL CMPR2
SACL CMPR3
B WCL