You are on page 1of 89

UNIVERSITY OF SOUTHAMPTON

FACULTY OF ENGINEERING AND APPLIED SCIENCE

ELECTRICAL ENGINEERING DEPARTMENT

SENSORLESS CONTROL OF
BRUSHLESS DC MOTOR USING BACK
EMF COMMUTATION

By David BOMASSI

May 2000

A dissertation submitted in partial fulfilment of the requirement for the M.Phil,


in Electrical Engineering studies by instructional course.
Abstract

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 The brushless dc motor 3


1.1 INTRODUCTION 3

1.2 THE BRUSHLESS CONFIGURATION COMPARED TO THE COMMUTATOR MOTOR 3

1.3 TORQUE AND VOLTAGE EQUATIONS 4

1.4 COMMUTATION 6

1.5 SHAFT POSITION SENSING 9


1.5.1 Hall effect devices 9
1.5.2 Resolver 10
1.5.3 Optical encoder 12
1.5.4 Sensorless control 13
1.5.4.1 The Back emf commutation method 13
1.5.4.2 Other sensorless methods 16

2 Review of existing systems using the back emf commutation


principle 17
2.1 MICROCOMPUTER CONTROL FOR SENSORLESS CONTROL OF BRUSHLESS DC 17
2.1.1 Sensorless circuit 17
2.1.2 Starting procedure 18
2.1.3 Discussion 18

2.2 TEXAS INSTRUMENT SYSTEM 18


2.2.1 Sensorless circuit 19
2.2.2 Starting procedure 19
2.2.3 Discussion 19

2.3 FREE WHEELING DIODES METHOD 20


2.3.1 Sensorless circuit 20
2.3.2 Starting procedure 21
2.3.3 Discussion 21
( 'oillcll/s IV

3 Theory of the developed control system 22


3.1 SENSORLESS CONTROL CIRCUIT 22

3.2 STARTING PROCEDURE 23

3.3 SPEED CONTROL 23

3.4 CURRENT LIMITER 24

3.5 DIRECTION OF ROTATION 25

4 Implementation 26
4.1 INTRODUCTION 26

4.2 THE MOTOR 26

4.3 THE ANALOG CIRCUIT 26


4.3.1 The open loop mode 27
4.3.1.1 Principle 27
4.3.1.2 The circuit 27
4.3.2 Switching circuit 30
4.3.3 Sensorless circuit 32
4.3.3.1 Principle 32
4.3.3.2 Theory of the circuit 32
4.3.4 The allegro chip 33
4.3.4.1 Description 33
4.3.4.2 The circuit 33
4.3.5 Test results of the analog control circuit 34

4.4 THE DIGITAL CIRCUIT 34


4.4.1 Introduction 34
4.4.2 The control hardware 34
4.4.3 The power electronic hardware 36
4.4.3.1 Inverter 36
4.4.3.2 Sensorless circuit 36
4.4.4 The control algorithm 40
4.4.4.1 Speed measurement 40
4.4.4.2 The open loop mode 40
4.4.4.3 The switching procedure 40
4.4.4.4 The closed loop mode 42
4.4.4.5 The current limiting algorithm 42
4.4.5 Software organisation 43
4.4.5.1 DSP controller setup 43
4.4.5.2 Software constants 44
4.4.5.3 Software variables 44
4.4.5.4 Global structure 45
4.4.5.5 Open loop mode 46
4.4.5.6 Current limiter in open loop mode 48
4.4.5.7 Switching procedure 48
4.4.5.8 Closed loop mode 50
4.4.6 Results 51
( 'on/cms V

4.4.6.1 Open loop mode 52


4.4.6.2 Closed loop mode 52
4.4.6.3 Current limiter 54
4.4.7 Problems and solutions 54
4.4.7.1 Change from open loop to closed loop mode 54
4.4.7.2 Low speed torque in closed loop mode 55

Conclusion 58

References 59

Appendix A Guide to run the program with the DMCD Pro


Debugger 61

Appendix B Sensorless BLDC control assembly code 62


( 'iill/Cllfs VI

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.

The objectives of this project were the following ;


- The drive should use no position sensors, which should be replaced with a
sensorless control using the back emf commutation.
- The circuit should be based on a TMS320F240 DSP and a program should be
written for it.
- An open loop procedure should be used to start the motor.
- The drive should allow a reliable reversal and contain a speed control even at low
speed.
- The current should be limited in the circuit.
The hi'iLshli'ssnioh/r 3

1 The brushless dc motor

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.

1.2 The brushless configuration compared to the commutator motor

The most obvious advantage of the brushless configuration is the removal of


brushes : no more maintenance, no more sparking and no more brush debris or dust which
could get into bearings. It also allows reducing the radio frequency interference. The
conduction of heat through the frame is improved and the motor length is smaller.
However, the brushless configuration requires a shaft position sensing, a three-
phase power bridge, and commutation logic, which increases the complexity in the
electronic controller.

Therefore, compared with commutator motors, brushless dc motors are smaller,


easier to maintain and more reliable but they are more expensive and need a more
complicated drive.

1.3 Torque and voltage equations

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 - ^

where the no-load speed is defined by


Vs
coo = —

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

* -ia -ib -ic e


1

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

Position sensing |ea %|E


circuit ^ •/-

V.
Motor

Figure 1-3 System diagram

H2

60°
m
{
••BO"

Figure 1-4 Position of the Hall effect devices


8

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

1.5 Shaft position sensing

A brushless dc output performance depends largely on the accuracy of the power


bridge's switching (not switching the power transistors with the best timing would indeed
produce a low torque or could even make the motor lose its synchronism). This is why we
need an accurate and reliable position measurement system. Four types of systems are
commonly used ; Hall effect devices, the resolver, the optical encoder and the sensorless
measurement. The brushless dc commutation logic normally only requires the
determination of three points within 360 electrical degrees (see fig. 1-5 and 1-6).

1.5.1 Hall effect devices

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

Figure 1-7 Hall effect device

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.

Hall effect device

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

Figure 1-9 Picture of a resolver

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 :

Figure 1-10 Resolver diagram

If the input of the resolver is VIN = A. sin at


then the two outputs will respectively be : Vout\ = Ah.sin 9. sin(<Bf + d)
Voui2 = Akz. COS 0. sm{a)t + a)
where ki,k2 is the transformation ratio and a is the phase shift.

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.

1.5.3 Optical encoder

An optical encoder consists of a set of pairs of phototransistors and collimated light


sources, used in conjunction with a glass or metal encoder disc. Like the resolver, it can be
///i' A / ( / { . ' ///N/fV 12

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

1.5.4 Sensorless control

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 THE BACK EMF COMMUTATION METHOD

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-

Figure 1-12 Stator terminal electrical model

For each terminal voltage, for example for A, we can write


VA = {R + LS)JA + EA + VN
///I' / ) / / / , < / ( . ///U/U/ 14

Assume that switches 1 and 4 (see fig. 1-3) are on. Fig. 1-13 shows the equivalent
circuit at this time.

Figure 1-13 Equivalent circuit of the motor if switches 1 and 4 are on

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.

1.5.4.1.2 Starting procedure


The main problem of the back emf commutation method is that the back emf
approaches zero at low speed. Therefore, sensorless operation using this principle finds
difficulties in starting and low speed range.

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.

A possible method is to set a predetermined initial rotor position by arbitrarily


energising two motor coils. The motor will align itself with the magnetic field created, and
once the known initial position is set, the motor can be started by giving the next
commutation pulse. This method is interesting but the start can be accompanied by a
temporary reverse rotation, and in worst cases, not even be achieved.

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

1.5.4.2 OTHER SENSORLESS METHODS

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].

Another possible technique uses the variable winding inductance as a method of


rotor position detection. It is obviously effective only when there is a large variation in
phase inductance with position. This technique has been successfully tested with stepping
motors and switched reluctance motors but also with salient-pole brushless dc motors,
which have the characteristic that the winding inductance is a function of rotor position [6],
/<"(. 1/(11 ///(.' /'c/i A (. //// ( 17

2 Review of existing systems using the back emf


commutation principle

2.1 Microcomputer control for sensorless control of brushless dc


This paragraph deals with a sensorless control method developed by K. IIZUKA et
A1 [7].

2.1.1 Sensorless circuit

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

Figure 2-1 Sensorless circuit


2.1.2 Starting procedure

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.

At start up, the microcontroller generates synchronous commutation signals whose


frequency is accelerated by degree, and the motor is switched to a self controlled brushless
one when the microcontroller detects that it can be done. Not only the motor speed must be
sufficient to allow the determination of the rotor position using the back emf, but the phase
angle difference between the synchronous signal and the voltage sensing signal must also
be small enough to prevent the motor from stepping out. This phase angle depends on the
motor voltage, the load and the starting current.

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.

2.2 Texas instrument system


This paragraph deals with a sensorless method developed by Texas Instrument (TI)
[8].
Ri'ViCM' oj svMcms ///<• htn k ciiil cuiniiiiiiiifioi) /'-//Av/Vi' 19

2.2.1 Sensorless circuit

The control hardware used in this system is based on a TMS320F240 evaluation


board by Texas Instrument, which contains a TMS320F240 DSP. Like the precedent
method, it uses the back emf commutation principle.

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

2.2.2 Starting procedure

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.

2.3 Free wheeling diodes method


This paragraph deals with a method developed by S. OGASAWARA and H. AKAGI
[9].

2.3.1 Sensorless circuit

This solution is based on the detection of the conducting interval of free-wheeling


diodes cormected in parallel with the power transistors. It actually uses the free-wheeling
diodes to indirectly detect the back emfs, hence this is another application of the back emf
commutation principle.

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.

Figure 2-3 Detection circuit for conduction offree-wheeling diodes

2.3.2 Starting procedure

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

3 Theory of the developed control system

The next section describes the theory of the developed system.

3.1 Sensorless control circuit


The sensorless control system that has been used is based on the principle of back
emf commutation. The three terminal voltages Vr, Vy, Vb are measured and processed to
produce the three signals Hr, Hy, Hb, that would be obtained from three Hall effect devices
separated by 60 electrical degrees (see fig. 3-1).

Back emf of motor (i=0)

Vr

Vy

Vb

Wr

Wy

Wb

Hr

Hy

Hb

0 60 120 180 240 300 360 420 480 540 600 660

Rotor position in electrical degrees

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

3.2 Starting procedure


It has been chosen to start the motor as a synchronous one. This method is indeed
simple to implement in a DSP and also allows having an algorithm to control the motor at
low speed without using the back emf commutation principle, which, we know, suffers
from poor resolution at low speed.

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.

3.3 Speed control


The motor speed is simply controlled by varying the dc link voltage, which is
achieved by pulse width modulation (PWM).

Vmax

Figure 3-2 PWM principle


///iV'/T 'V ///i' (/('I (. 24

Then dc hnk voltage can be adjusted by varying the on-duty cycle y j , of the PWM

signal (see fig. 3-2).

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

Figure 3-3 Speed control system

The speed feedback is provided by a speed measurement system. It is subtracted


from the speed demand to produce the speed error (see fig. 3-3) which is amplified by a
controller and then used to modify the on-duty cycle of the PWM signal.

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.

3.4 Current limiter

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

3.5 Direction of rotation

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.

4.2 The motor

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.

4.3 The analog circuit

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.

The circuit is supplied using a dc to dc converter (NMH2505D chip) to ensure


isolation of control circuit supply (contains Allegro chip) from commutation circuit supply.

4.3.1 The open loop mode

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.

4.3.1.2 THE CIRCUIT

Fig. 4-1 shows the open loop circuit.

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

U3 compares PI and S with a hysteresis. The comparator U4 only aims at


improving the output of U3 so as the switch of the relay RL2 can be as clear as possible.
The output of U4 is actually equal to the output of U3. U7 is an integrator which ramps up
the switching frequency. At start and as long as S is smaller than Pl+el, the output of U3
is equal to zero. Then the circuit works in open loop and the relay connects the input of U5
to P2 (the speed demand). The output of the ramp generator U7 will increase until P2 (as
long as S<Pl+el) and then will be maintained to P2 thanks to the comparator U6. The rate
of the ramp generator can be adjusted by using RV3. If P2 is modified but remains smaller
than PI+e, the output of U7 will increase (or decrease) until it is equal to P2 (see fig. 4-2).

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).

el and e2 can be adjusted by choosing R1 and R2.

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.

4.3.2 Switching circuit

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

I output of th« LM993 cWp (U4)


from th# open loop circuit

§
S
I MM74HCH175N
,3 Owl MV

To Allegro chip
(Pt4)
FROM -J
motok y- -J MC74HC4053N

Ottl #ov pwk ui ua M


#&*<&# OM ctl
24V *VN
i V
•OUT ton t«v 01*

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.

4.3.3.2 THEORY OF THE CIRCUIT

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 The allegro chip

4.3.4.1 DESCRIPTION

The UDN2936W Allegro chip is a three-phase brushless dc motor controller.


Combining logic and power, it provides commutation and drive for three-phase brushless
dc motors. It allows converting the Hall effect signals to signals, which can drive the
inverter's transistors.
The combination logic is programmed for Hall effect devices separated by 60 or
120 electrical degrees.
Current control is accomplished by sensing current through an external sense
resistor and pulse-width modulating the source drivers. It also includes braking and
direction control.
Internal protection circuitry prevents crossover current when braking or changing
direction.

4.3.4.2 THE CIRCUIT

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

From output comi3 y •-rfV 8

(see fig 4.3) g,» 10

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

4.3.5 Test results of the analog control circuit

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 The digital 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.

4.4.2 The control hardware

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:
\/

Figure 4-5 Top view ofTMS320F240 Board

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

Figure 4-6 Top view ofIMMC240 Board


Impleinenlation

IM^K?240 board Swikmto dia%eOn/ofT +5V siq^Iy


direction

C onnectm-to
the inverter

» #• •* •# •# # , « # * # *
>

i Conoectwto Ae
Serial conneaor sensorkss circuk

Conneck)r (or the 15V siqqily and the


qxed demand signal

Figure 4-7 Top view of the DSP circuit

4.4.3 The power electronic hardware

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.

4.4.3.2 SENSORLESS CIRCUIT

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*

Connector to the terminal „ Connector to the


phage voka^ - kifl* / D S P board

Connecby k r t h e
cmrco* kmmdoccr

Hgwg Top v/ew ^ ewor/e&a cfrcMif oW fAe c«rrg»f

transducer

The DSP circuit

r Motor

The opto-isolating circuit ^he inverter The sensorless circuit + current transducer

Figure 4-9 Top view of the box containing the circuits


® or

>

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

GND1 INVERTER CIRCUIT

I
GND1
»^M339M
LM339N
Sena!
cabe LM339


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

4.4.4 The control algorithm

4.4.4.1 SPEED MEASUREMENT

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

Figure 4-12 Speed measurement

4.4.4.2 THE OPEN LOOP MODE

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.

4.4.4.3 THE SWITCHING PROCEDURE

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

Figure 4-13 Time of the speed test on the waveform of signal T3

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

closed loop open loop


-»-4-
motor speed decreases

T3

say the speed is low enough to


t
interrupt
switch to open loop at this time

Figure 4-14 Switching back to open loop mode

4.4.4.4 THE CLOSED LOOP MODE


Once the system has been switched to closed loop, the DSP must convert the three
signals from the sensorless circuit to six signals to drive the six MOSFETs of the inverter.
Fig. 1-5 and fig. 1-6 of paragraph 1.4 show the corresponding sequences for both directions
of rotation. A feedback speed control must be introduced to adjust the rotor speed, and,
even if it is not as much a necessity as for the open mode, the algorithm must contain a
current limiter. We can notice in the description of the speed measurement procedure that
the motor speed is measured by calculating the length of the period of one of the transistor
driving signals. This means that a new speed measurement is done at each transistor signal
period : the frequency of the speed measurement is therefore equal to the frequency of the
motor. Moreover, we know that the sampling frequency of the speed loop must be lower
than the frequency of the speed measurement procedure. Therefore, the speed loop
sampling frequency can not be set to a predetermined value (it would have to be set to a
very low value, lower than the motor frequency at any time), it will then depend on the
motor frequency, but this did not cause any problem.

4.4.4.5 THE CURRENT LIMITING ALGORITHM

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.

4.4.5 Software organisation

4.4.5.1 DSP CONTROLLER SETUP


This part is dedicated to the handling of the different DSP Controller resources
(Core settings and peripherals settings).

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).

4.4.5.2 SOFTWARE CONSTANTS

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 :

Frequency of the transition = — (in Hz)

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).

4.4.5.3 SOFTWARE VARIABLES

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.

4.4.5.4 GLOBAL STRUCTURE

start

Init

Test direction

No

Yes

No-

Yes

Closed loop

Direction
No
inchanget
Yes
ieed<Spe(
No
limit ^

Yes

Figure 4-15 Global structure of the sensorless control


As soon as the program is started, the DSP initialisation is performed. The program
then tests the demanded direction of rotation and runs the open loop procedure. If the
demanded direction changes, the program is restarted during the open loop start up. If the
speed reaches the value that has been chosen to switch to closed loop, the program starts
the switching procedure. Like in the open loop mode, the program is restarted if the
required direction changes. The program starts again the switching procedure if the speed
becomes too low.

4.4.5.5 OPEN LOOP MODE

start

test_stop

test direction

produce synctironous
signal

adjust signal frequency

Current test

S p e e d > S p e e d limit No

Yes

start switching
procedure

Figure 4-16 The open loop mode

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

Figure 4-17 Speed control in open loop mode

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

4.4.5.6 CURRENT LIMITER IN OPEN LOOP MODE

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

CMPRx=CMPRx LIM CMPRx=CMPRX +


CMPRx=0 CMPRx=CMPRx-1
ERROR/32

End of
CURRENT_TEST
Return from Call

Figure 4-18 The current limiter

4.4.5.7 SWITCHING PROCEDURE

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)

Speed>limit been update

TES1 =TES open loop


Speed>bmit
r

open loop
TES1=0 TES1=0

Wait for INT1


open loop

closed loop

Figure 4-19 Switching from open loop to closed loop mode

first test (TtS1=0)

eed has be
Speed<limit —No > update

TES1=TES closed loop


Speed<limit No •

closed loop

TES1=0

Walt for INT1


closed loop

open loop

Figure 4-20 Switching from closed loop to open loop mode


50

4.4.5.8 CLOSED LOOP MODE

Start of Closed Loop

-*

MonRof oulpuhofihe
sensorless circuit

Adjust inputs of the 6


transistors

Call CHANGE_DIRECTiON

TEST_ARRET

Call CURRENT_TEST

call TEST_TIME

Test the motor speed

Figure 4-21 The closed loop mode

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.

The controller chosen is a simple proportional controller. If Un is the PWM ratio at


the instant n, then Un = Un-i + Kpx error. Experimental tests showed that setting the gain
to 0.015 was satisfactory. However, further investigations need to be made.

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

Figure 4-22 Control of speed in closed loop mode

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.

4.4.6.1 Open LOOP MODE

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.

4.4.6.2 CLOSED LOOP MODE

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

4.4.6.3 CURRENT LIMITER

100 mV/div io ms/div

Figure 4-25 Current waveform in a terminal phase (voltage to current scale)

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).

4.4.7 Problems and solutions

4.4.7.1 CHANGE FROM OPEN LOOP TO CLOSED LOOP MODE

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

4.4.7.2 Low SPEED TORQUE IN CLOSED LOOP MODE


The second problem is the motor torque, which is lower than expected in closed
loop mode at low speed. This is likely to be due to the unwanted phase delay introduced by
the filters of the sensorless circuit.

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.

Frequency 10 20 30 35 40 50 60 70 80 86 90 100 120 150 170


(Hz)

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

(a) Shift angle a = 33°

Hall effect;
II SensorlesE
Frequency = 50 Hz
Motor speed = 3000 rpm
(b) - J Shift angle a = 21°

' Sensortess aansing c


Frequency = 86 Hz
Motor speed = 5200 rpm
(c) Shift angle a = 13°

-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

(e) Shift angle a = 4°

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; /

Appendix A Guide to run the program with the DMCD


Pro Debugger

Run the DMCD Pro software from the Start menu.

If a project has already been built, select Open in the Project menu and select your
project.

If the project has not been build yet:

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

Appendix B Sensorless BLDC control assembly code

**$******************************************************************************

File Name : project.asm

Target System : IMMC24 EVM

Description : sensorless control of brushless DC motor using the back emf commutation principle

Inputs : ADC2 = Speed Demand (0 V to 5 V)

ADC 10 = Output of the current sensor


IOPAl,IOPA2,IOPA3 = Hr, Hy, Hb (outputs of the sensorless circuit)
Outputs : PWMl-2-3-4-5-6 = Inputs of the Inverter

CAP4 connected to PWM2


XINT2 connected to lOPAl
*******************************************************************************

Include files

•include f240regs.h
•include veots_a^h

•global rnain
•global retvalmon

Constant definitions

LIMIT •set 18000


Kp .set 30 ;Kp*2048
L_HYST •set 500
HYST •set 300
CURRENT MAX •set

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

START SETC INTM ;disable interrupts


SETC SXM ;suppress sign extension

;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

;ADC unit setting


LDP #224
SPLK #1111110010100101b,ADCTRLl
SPLK #0000000000000101b,ADCTRL2

;MUX control registers


LDP #OElh
SPLK #0801h,OCRA
SPLK #11110000b,OCRB

;EV interrupt mask registers


LDP #0E8h
SPLK #OFFFh,EVIMRA disable interrupts of timer 1
SPLK #10H,EVIMRB enable only the period interrupt of timer 2
SPLK #08h,EVIMRC and the capture 1 interrupt

;timer 1 setting ;timer 1 is used to control the PWM outputs


SPLK #0500,T1PR
SPLK #300,CMPR1
SPLK #300,CMPR2
SPLK #300,CMPR3
SPLK #020h,TlCMPR
SPLK #01001011010101 llb,COMCON
SPLK #11001011010101 llb,COMCON
SPLK #1110100000000010b,TlCON
SPLK #1110100001000010b,TlCON
SPLK #0508h,DBTCON

; timer 2 setting
LDPK #232
SPLK # 100100010100001 Ob.T2CON
SPLK #5000,T2PR
SPLK #500J2CMPR
SPLK #0FFFEh,T2CNT

;timer 3 setting ;timer 3 is used as a counter to calculate the rotor speed


SPLK #0FFF0H,T3PR
SPLK #0FFF0H,T3CMPR
65

SPLK #0H,T3CNT
SPLK #1001010100000010b,T3CON
SPLK #10001 lOOOOOOOOlOb.CAPCON
SPLK #1110000001 lOlOlOb.GPTCON

LDP #0
SPLK #OCH,IMR ;enable int3 and int2 only

.vector and flag reset


LACC IFR
SACL FR
LDP #0E8h
LACC EVTFRA
SACL EVIFRA
LACC EVIFRB
SACL EVIFRB
LACC EVIFRC
SACL EVIFRC

^external interrupt 2
LDP #OEOh
SPLK #1,XINT2

open loop

;control the demanded direction of rotation


DIRECTION:
LDP #OElh
LACC PBDATDIR
LDP #DIR ;test DIR : DIR=0;clockwise(OL2) DIR=l:counterclockwise(OL2B)
SACL DIR
BCND OL2,EQ
B OL2B

;start of the open loop in clockwise direction


OL2:
SETC DSTTM
LDP #LP ;set LP to 0 to indicate that the motor runs in open loop mode
SPLK #0,LP
CLRC SXM
B TEST ARRET ;test if the speed demand is sufficient to start the motor

OL3:
CALL CHANGE DIR ;test wether the direction of rotation needs to be changed
. /-I )( ' tv;////vV (Avsi'/y/A/r ( "</(.' (^6

LDP #0E8h produce the synchronous signal


SPLK #0C20h,ACTR
CALL TEMP

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

CALL ADJUST ;call the speed adjustement procedure


CALL CURRENT_TEST2 ;oall the current limiting procedure
B TESTS ;test whether the system can be switched to closed loop mode

;start of the open loop in conterclockwise direction


OL2B:
LDP #LP
SPLK #0,LP ;set LP to 0 to indicate that the motor runs in open loop mode
CLRC SXM
B TEST ARRET ;test if the speed demand is sufficient to start the motor

OL3B:
CALL CHANGE DIR ;test wether the direction of rotation needs to be changed

LDP #0E8h produce the synchronous signals


SPLK #02C0h^CTR
CALL TEMP

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

;limit the current in open loop mode


CURRENT_TEST2:
LDP #224
LACC ADCFIF02
LDP #CURENT
SACL CURENT
SUB #34300
SACL ERROR
CC MOINS2,GT
CC PLUS2,LT

PLUS2: ; increase the on-duty cycle of the PWM signal


LDP #0E8h
LACC CMPRl
SUB #1

LDP #BUFFER
SACL BUFFER
B LIMITEUR

MOINS2: .decrease the on-duty cycle of the PWM signal


LDP #0E8h
LACC CMPRl
ADD U5
LDP #BUFFER
SACL BUFFER
B LIMITEUR

;test if the motor has to be stopped (speed demand not sufficient)


TEST ARRET:
. /; /if/ /)( (.'N/zZ/u/ i/,\,\\'/;/A/r

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

;stop the motor


ARRET:
LDP #0E8h
SPLK #00h,ACTR ;switch off all the transistors
B START ;restart the program

;change the direction of rotation if necessary


CHANGE DIR:
LDP #0Elh
LACC PBDATDIR ;monitor the demanded direction of rotation
LDP #DIR
SUB DIR ;compare it to the current one
BCND ARRET,NEQ ;stop the motor if they are different
RET

;test procedure to switch to closed loop


TEST3:
LDP #TES1
LACC TESl
BCND TEST4,EQ ;first speed test? Yes: branch to TEST4
B TESTS ; No: branch to TEST5
TEST4:
LACC FREQ
SETC 8XM
SUB #LIMIT
ADD #L HYST ;compare the motor speed to the value chosen as the limit
. /if/ / 'f' (/.wi'/y/A/r iv/t/i.' 69

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

;procedures to check the direction and branch either to cw or ccw loops


WOL2:
LDP #DIR
LACC DIR
BCND OL2,EQ
B OL2B
WOL3:
LDP #DIR
LACC DIR
BCND OL3,EQ
B OL3B
WCL2:
LDP #DIR
LACC DIR
BCND CL2.EQ
B CL2B
WCL:
LDP #DIR
LACC DIR
BCND CL^
B CLB
WCL3:
A /V / )i ' cn/y/zu/ (/.wt'/y/A/r ( 70

LDP mm
LACC DIR
BCND CL3.EQ
B CL3B

;delay used for the open loop


TEMP:
LDP #NUM
RPT NUM
NOP
RPT NUM
NOP
RPT NUM
NOP
RPT NUM
NOP
LDP #0E8h
RET

;deoreases the period of the open loop signal


FALL:
LDP #NUM
LACC NUM
SFR
SFR
SFR
SFR
SACL MINUS
MPY MINUS
MPY MINUS
MPY MINUS
SACL MINUS
LACC NUM
SUB MINUS
SACL NUM
LDP #232
SPLK #OFFFFH,EVIFRB
CLRC INTM
RET

^increases the period of the open loop signal


RISE:
LDP #NUM
LACC NUM
SFR
SFR
SFR
71

SFR
SFR
SACL MINUS
MPY MENUS
MPY MINUS
MPY MINUS
ADD NUM
SACL NUM
LDP #232
SPLK #OFFFFH,EVIFRB
circ INTM
RET

;caloulate the frequency of the output


CALCUL:
CLRC SXM
SETC INTM
LDP #232
LACC T3CON
AND #0000000001000000b
BOND START_TIMER,EQ ;start timer 3 if it is not already
LDP #TES
LACC TES
ADD #1 ;add 1 to TES to show that a new speed update is made
SACL TES
LACC PER
BCND RESTARTJvlEQ irestart timer 3 if
LDP #232
LACC T3CNT
SPLK #0,T3CNT
LDP #FREQ
SACL FREQ
SPLK #1,CALC
LDP
SPLK #OFFFFH,EVIFRC
LDP #0
LACC IFR
SACL IFR

;restore status registers


LARP ARl ARP=1
MAR *- ARl-
ZALS *- restore ACCL
ADDH *- restore ACCH
LST #0,*- restore STO
LST #1.*- restore STl
CLRC INTM enable interrupts
RET return
72

;restart timer 3 if its period has been reached


RESTART:
LDP #232
SPLK #0,T3CNT
SPLK #1001010101000010b.T3CON
LDP #PER
SPLK #0,PER
SPLK #OFFFFH,FREQ
CALL ADJUST
LDP #232
SPLK #0FFFFH3VIFRC

;restore status registers


LARP ARl ARP=1
MAR •- ARl-
ZALS *- restore ACCL
ADDH •- restore ACCH
LST m*- restore STO
LST #!,•- restore STl
CLRC INTM enable interrupts
RET return

;start timer 3
START TIMER;
LDP #232
SPLK #0,T3CNT
SPLK #1001010101000010b,T3CON
SPLK #OFFFFH,EVIFRC

;restore status registers


LARP ARl ;ARP=1
MAR •. ;AR1-
ZALS *. ; restore ACCL
ADDH *. ; restore ACCH
LST #0,*- ; restore STO
LST #1.*- ; restore STl
CLRC INTM ; enable interrupts
RET ; return

;monitor the demand and adjust the frequency of the output


ADJUST:
LDP #224
LACC ADCFIFOl
LDP #DEMAND
SACL DEMAND
. .s'lV/.sfWi'w )( ' ( I . Hc/L' 73

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

;logical control of the inverter (clockwise rotation)


Tl:
LDP #INPUT
LACC INPUT
AND #OCh
BCND T1P,EQ
B TIM

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

;Iogical control of the inverter (CCW)


TIB:
LDP #INPUT
LACC INPUT
AND #OCh
BCND T2P,EQ
B T2M
T2B.-
LDP #INPUT
LACC INPUT
AND #OCh
SUB #OCh
BCND T1P.EQ
B TIM

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

;restore status registers


LARP ARl ;ARP=1
MAR *- ;AR1-
ZALS *- ; restore ACCL
ADDH *- ; restore ACCH
LSI m*- ; restore STO
LST #1.*- ; restore STl
CLRC INTM ; enable interrupts
RET ; return

;speed adjustement procedure in closed loop mode


ADJUST4:
LDP #232
SPLK #OFFFFh,EVrFRB
LDP #CALC
SPLK #O.CALC
LDP #224
LACC ADCFIFOI
LDP #DEMAND
SACL DEMAND
LACC DEMAND
SUB FREQ
sacl ERROR
BCND MOINS,LT
BCND PLUS.GT
B PLUS

.increase the speed in closed loop mode


MOINS;
CLRC SXM
NEG
SACL ERROR
LT ERROR
MPY
PAC
RPT #10
SFR
SACL KERROR
LDP #0E8h
LACC CMPRl
LDP #KERROR
SUB KERROR
80

SACL BUFFER
B LIMITEUR

;decrease the speed in closed loop mode


PLUS:
CLRC SXM
LT ERROR
MPY
PAC
RPT #10
SFR
SACL KERROR
LDP #0E8h
LACC CMPRl
LDP #KERROR
ADD KERROR
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

;test if it is time to update the speed in closed loop mode


TEST TIME:
/:» .V/Avn/Vi .\,s )( ( i V'c/i' 81

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

You might also like