• No results found

Design and implementation of a servo system by Sensor Field Oriented Control of a BLDC motor

N/A
N/A
Protected

Academic year: 2022

Share "Design and implementation of a servo system by Sensor Field Oriented Control of a BLDC motor"

Copied!
46
0
0

Loading.... (view fulltext now)

Full text

(1)

UPTEC F 14051

Examensarbete 30 hp November 2014

Design and implementation of a servo system by Sensor Field

Oriented Control of a BLDC motor

Per Eriksson

(2)

Teknisk- naturvetenskaplig fakultet UTH-enheten

Besöksadress:

Ångströmlaboratoriet Lägerhyddsvägen 1 Hus 4, Plan 0

Postadress:

Box 536 751 21 Uppsala

Telefon:

018 – 471 30 03

Telefax:

018 – 471 30 00

Hemsida:

http://www.teknat.uu.se/student

Abstract

Design and implementation of a servo system by Sensor Field Oriented Control of a BLDC motor

Per Eriksson

A servo system intended to steer antennas on board ships is designed, built and tested. It uses a Brushless Direct Current (BLDC) motor with an encoder to keep track of its position, and Field Oriented Control (FOC) implemented on Toshibas microprocessor TMPM373 in order to control the current flowing to the motor. The servo system will be connected in cascade to another already existing servo system and controlled with two input signals. The first signal determines if the antenna axis should rotate clockwise or counter clockwise. The second signal is a stream of pulses, where each pulse means that the motor should move one encoder point.

A printed circuit board is designed and built to complete these tasks. A proportional -integral regulator is used to control the position of the motor, using the position error as the controller input. The servo system is tested. The performance of the resulting servo system is sufficient to satisfy the required position error limit of 0.5 degrees. In order to reduce the periodic disturbances presented in the system in experiments, Iterative Learning Control (ILC) is implemented. It is shown that using ILC further decreases the position error.

ISSN: 1401-5757, UPTEC F14 051 Examinator: Tomas Nyberg Ämnesgranskare: Ping Wu Handledare: Sven-Åke Eriksson

(3)

Sammanfattning

Ett servosystem tänkt att användas för att rikta antenner ombord på båtar är designat, byggt och testat.

Det använder en borstlös likströmsmotor (BLDC) med en encoder som håller reda på dess position, och Field Oriented Control (FOC) implementerad på Toshibas mikroprocessor TMPM373 för att kontrollera strömmen som går in i motorn. Servosystemet kaskadkopplas tillsammans med ett annat redan existe- rande servosystem och styrs med hjälp av två signaler. Den första signalen bestämmer om antennaxeln ska svänga medsol eller motsol. Den andra signalen är en ström av pulser, där varje puls betyder att motor ska ytta sig ett encodersteg.

Ett kretskort med all nödvändig hårdvara för detta är designat och byggt. För att styra positionen av motorn används en proportionell-integrerande regulator där styrsignalen är positionsfelet. Servosystemet testas och resultatet är ett servosystem vars positionsfel nästan alltid håller sig under kravet på 0.5 graders fel. För att minska de periodiska störningarna i positionsfelet som visat sig i systemet under experimenten så implementeras algoritmen Iterative Learning Control, som visar sig minska positionsfelet ytterligare.

(4)

Contents

1 Introduction 4

1.1 Background . . . . 4

1.2 Purposes and goals . . . . 5

1.3 Methodology . . . . 5

1.4 Thesis outline . . . . 5

2 Working principles and theories 7 2.1 Servo systems . . . . 7

2.2 Brushless Direct Current Motor . . . . 8

2.3 Field Oriented Control (FOC) . . . 10

2.4 Encoder . . . 12

2.5 Space Vector Pulse Width Modulation . . . 12

2.5.1 The three-phase inverter . . . 12

2.5.2 Space Vector Pulse Width Modulation . . . 13

2.6 Current Measurement . . . 15

2.7 Torque ripples . . . 16

2.8 Controllers . . . 17

2.8.1 PI controller . . . 17

2.8.2 Iterative learning control (ILC) . . . 17

3 Implementation 18 3.1 Project Specications . . . 18

3.2 Motor Specications . . . 18

3.3 Pulse-width modulation . . . 18

3.4 Computer Communication . . . 19

3.5 Current Measurement . . . 19

3.6 First design . . . 21

3.7 Second design . . . 21

3.8 Programming . . . 23

3.8.1 Main method . . . 23

3.8.2 Vector Engine . . . 25

3.8.3 Key press detection loop . . . 26

3.8.4 Field Oriented Control loop . . . 26

4 Experiments 29 4.1 Setup . . . 29

4.2 Testing the rst design . . . 29

4.3 Testing the second design . . . 31

4.3.1 Determination of current PI controller settings . . . 31

4.3.2 Determination of speed PI controller settings . . . 32

4.3.3 Iterative Learning Control in order to reduce periodic disturbances . . . 33

(5)

5 Results and Discussion 36 5.1 Dead-time aecting the performance . . . 36

6 Conclusions and suggestions for future work 38

6.1 Conclusions . . . 38 6.2 Suggestions for future work . . . 38

(6)

Chapter 1

Introduction

1.1 Background

Research Electronics is a company that delivers electronics tailored to customer requirements. These include control and regulation devices that require high speed and precision, or measuring equipment used in extreme environments. The company has developed a two-way satellite communication system in order to provide broadband for ships out in the sea. The motion of the ships' decks makes this quite a dicult task, and most existing antenna system solutions are driven from the center of rotation of the antenna dish. The solution presented by Research Electronics is not following this norm, and the servo motors are instead placed as far as possible from the center of rotation. This improves the pointing accuracy but requires the servo system to be able to achieve a very low positioning error. There are solutions available today on the market, that are able to meet the requirements. Unfortunately they are quite expensive and often comes with extra features not needed for this purpose, such as various lter types used to modify the behaivour of the system and analog inputs to control the speed and torque. As an example, the hardware required for KVHs 4 Mbps maritime broadband solution TracPhone V11 costs 75000 USD. Therefore, Research Electronics has decided to build this system itself. This could reduce the cost of the servo system by 90% or more by using cheap but ecient components and creating the control systems.

The servo system that the present thesis project is concerned with is schematically shown in Figure 1.1.

The system consists of two servo systems connected in cascade in a closed feedback loop. Both systems have a similar setup, with encoders that keep track of positions. The inner encoder is connected directly to the motor while the outer encoder is connected to the antenna axis. For a satellite dish control system, each cascaded servo system needs to be connected to an antenna axis.

A basic component in any servo system is a variable speed drive, which consists of a motor and a controller. Vector control of AC motors was rst developed by K. Hasse and F. Blaschke in the early 1970s. Vector control is a variable speed drive control system where the stator currents of three-phase AC motors are identied as two orthogonal components which can be visualized as a vector. Two dierent branches of vector control emerged during the 1980s, Field-Oriented Control (FOC) and Direct Torque Control (DTC). In DTC the speed is controlled by estimating the magnetic ux and torque of the motor based on the measured voltage and current. The drawbacks of DTC are that it is dicult to use at low speeds, and produces high torque and current ripples [1]. You also need a very good current sensor if DTC is to be used in a high performance application, which increases the cost of the required hardware.

FOC can be used in many dierent ways. It is possible to implement FOC using either synchronous (brushless) or induction (brushed) motors. In both of these cases, you can also make the choice of using sensors or not. Sensorless control requires derivation of rotor speed by measured stator voltage and currents. In this project a brushless DC motor and sensor FOC are used.

(7)

Figure 1.1: The complete servo system, in which the inner servo system for controlling the motor (inside the dashed rectangle) is the focus of this project.

1.2 Purposes and goals

The purpose of this project is to develop a servo system, which is the inner part of the bigger system shown in Figure 1.1. The maximum position error of the servo system in this project needs to be at most 0.5 degrees, and the system operates at up to ve revolutions per second. The goal of this thesis project is to develop a prototype of such a servo system, which can be further developed into a nal system that can be used in the above mentioned communication system to control the antenna rotation with the requirements fullled.

1.3 Methodology

The components used in this project were carefully chosen based on the requirements. The microprocessor TMPM373 from Toshiba was chosen because it has specic on-chip hardware designed for the purpose of Field Oriented Control. A BLDC motor was chosen because of it's high power to weigth and torque to current ratios. Sensor FOC was chosen above sensorless FOC because of the unreliability of sensorless FOC at low speeds if you do not use expensive and heavy current measurement components.

The goal when designing the printed circuit board was to reduce electromagnetic interference and current uctuations as much as possible. This was done by creating return paths for the currents used in the motor in a satisfactory way, by linking the upper and lower layers of the board with multiple holes.

Several capacitors were also placed on the board with the sole reason of acting as buers for the spiky current consumption of integrated circuits. Finally, separate channels provided current to the CPU, the integrated circuits and the motor current so that any disturbances in one part would not disturb the other parts.

The servo system is built upon a brushless direct current motor with an encoder that keeps track of the rotor position with a resolution of 8192 points per revolution. The motor current is controlled by an algorithm called Field Oriented Control, which is implemented on Toshibas TMPM373 microprocessor that has specic on-chip hardware designed for the purpose of Field Oriented Control.

All tests and experiments were conducted using the components that will be used in the complete servo system, so the results are relevant to a real world application.

1.4 Thesis outline

This thesis is divided into six chapters. Chapter one gives a brief introduction and overview of the project. Chapter two provides the necessary theoretical background to understand how the servo system works. Chapter three describes how the project is implemented both physically and digitally. Chapter

(8)

four describes the experiments conducted on the servo system and how the dierent controlled settings were obtained. Chapter ve presents the results and the discussion. Chapter six summarizes the main conclusions and presents some ideas for future work.

(9)

Chapter 2

Working principles and theories

2.1 Servo systems

A servo system is a system made for the automatic control of motion by means of feedback. A servo loop generally refers to the feedback control of a single variable, often position, speed or acceleration. The purpose of a servo system is generally one or more of the following objectives: (1) precise control of motion without any human interaction; (2) precise control of motion even with mechanical load variations, power supply uctuations or changes in the environment; (3) be able to control a high power load from a low power reference signal.

An example of a general motion control system can be described as in Figure 2.1. The application software (or some other input device) sends a reference position to the motion controller, which utilizes this signal and the feedback position to create an input voltage to the amplier. The amplier transforms this voltage into a current for the actuator. The position of the output motion can then be measured and sent back to the motion controller via a feedback device of some sort. This is a simple servo loop. More complex servo systems may have several servo loops connected in cascade or in some other connection.

Let's look at the dierent components in a little bit more detail. A motion controller is commonly implemented using digital computers, but can also be implemented using only analog components. It is the unit which receives the feedback from the feedback device and calculates the input to the amplier.

A motion controller can be everything from a simple PI-regulator to an advanced digital device with movement prediction, synchronisation with other parts of the system or other high level features.

A ampliers job is to translate the low energy reference signal from the controller into a high energy power signal for the motor. Generally this is a device with some kind of pulse-width modulation circuit which is controlled by the reference signal. The ampliers nowadays often have protective circuits such as thermal shutdown circuits, undervoltage and overvoltage protection circuits.

An actuator is a type of motor responsible for moving or controlling a system. They can be single, two or three phase motors. The motor can be an induction motor or permanent magnet motor, with DC or AC. There are many dierent types of electrical motors out there and most of them can be used in a motion control system. The term servomotor is dened as a motor that provides the power for a servomechanism.

The mechanical connection can be something like a shaft, a chain, a gearbox, cogwheels or some other connection between the motor and the target.

The feedback device is used to ensure that the target reaches the commanded position or velocity.

This will typically be an position encoder and/or a current measurement sensor like a hall sensor.

(10)

Figure 2.1: A general motion control system.

2.2 Brushless Direct Current Motor

Brushless direct current (BLDC) motors are a type of permanent magnet synchronous motor (PMSM).

The rotor in a BLDC motor consists of a permanent magnet with a varying amounts of pole pairs. These poles are alternating south and north evenly across the rotor, which is usually circular. Furthermore, a BLDC motor also consists of windings which are evenly spread around the stator as shown in gure 2.2.

In a BLDC motor a magnetic eld is created when current is owing through the windings in the stator.

If these currents are manipulated in a correct way this magnetic eld will rotate. The static magnetic

eld of the rotor will rotate at the same speed as the magnetic eld of the stator, causing the rotor to move. An example of how the magnetic eld in the windings can change is shown in gure 2.3. BLDC motors do not experience the slip commonly seen in induction motors when the load on the rotor is increased. Instead, the rotor in a BLDC will either rotate in perfect synchronisation with the magnetic

eld or not at all.

Figure 2.2: The interior of a BLDC motor. A,B and C mark the three windings.

The brushless synchronous motor has been very popular over the past years due to some big ad- vantages compared to brushed DC motors, for instance, high torque to current ratio, higher eciency, noiseless operation, better robustness and large power to weight ratios[2].

The motor equations can be viewed from the phase reference frame with individual currents and voltages for each phase. Another way to look at it is to look at the motor equations from the rotor reference frame. In this reference frame, two perpendicular axes called the direct (d-axis) and quadrature (q-axis) exists, as illustrated in Figure 2.4. The motor model in the rotor reference (d − q) frame is

(11)

Figure 2.3: An inverter or a three-phase power supply provides a rotating magnetic eld inside a motor.

expressed in the following manner [3][4],

Figure 2.4: A vector representation of (a) the three phase currents(iA,iB and iC), their vector sum is as well as (b) the direct and quadrature axis.

Vd(t) Vq(t)



=Ra+ pLd ωeLq

−ωeLd Ra+ pLq

 id(t) iq(t)

 +

 0

Keωe(t)



(2.1)

Te(t) = 3

2P (ψFiq(t) + (Ld− Lq)id(t)iq(t)) (2.2) Te(t) = J

Pe(t) +Bm

P ωe+ TL (2.3)

where

Vd(t), Vq(t) d-axis and q-axis stator voltages;

id(t), iq(t) d-axis and q-axis stator currents;

(12)

Ld, Lq d-axis and q-axis stator inductances;

La phase inductance;

Ra stator winding resistance;

J moment of inertia;

p dierential operator (dtd);

P number of poles in the motor;

ωe electric speed;

ψF rotor permanent magnetic ux linkage;

Ke back EMF constant;

Te(t) generated electromagnetic torque;

TL load torque;

Bm Damping coecient (assumed to be zero from now on);

By ignoring the mutual inductance between the phase windings and assuming symmetry in the inductances, Lq = Ld= La[5]. By assuming that control is good enough to keep id = 0Equation (2.1), (2.2) and (2.3) can be simplied to,

Vq(t) = La

diq(t)

dt + Raiq(t) + Keωe(t) (2.4) Ktiq(t) − TL= J

P e(t)

dt (2.5)

where Ktis the torque constant dened as32P ψF. To facilitate the analysis, let TLbe zero. Performing Laplace transforms on Equation (2.4) and (2.5) leads to the transfer function from Vq(s)to iq(s),

Gm(s) = iq(s)

Vq(s) = s/La

s2+ (Ra/La)s + KtP Ke/(J La) (2.6) To control the speed of the motor another transfer function from Vq to ωe can be found from the same equations and given as follows:

Gω(s) = ωe(s)

Vq(s) = Kt

s2LPJ + RPJs + KeKt

(2.7) This leads to a control system with two control loops, an inner loop and an outer loop, which is shown in Figure 2.5. The boxes labelled PI are PI controllers, which are explained in Section 2.8.1. In order to create good stability the inner loop has to be much faster than the outer loop, ideally reaching a steady state before each new input from the outer loop.

2.3 Field Oriented Control (FOC)

The current owing in each of the windings creates a magnetic eld. The magnitude and direction of this magnetic eld can theoretically be perfectly controlled by the currents in the windings. In Figure 2.4 (a) a vector representation of the three phases, their respective current and the resulting sum of currents is

can be seen. Torque in the motor is produced by the attraction and repulsion between the magnetic eld of the rotor and the magnetic eld the current is produces. This means that if the vector is is placed in the same direction as the magnetic eld of the rotor, no torque is produced. The elds still interact to produce a force, but the force is in line with the axis of rotation of the motor, pushing towards the motor bearings. If isis aligned orthogonal to the magnetic eld of the rotor, all of the force produced in the interaction between the two magnetic elds can be utilized as torque, producing a maximum torque for that current[6].

The purpose of Field Oriented Control (FOC) is to control this current vector isto produce the wanted speed and torque and minimize current consumption. In order to do this easily, the current vector is

is transformed from its original three-phase speed and time dependant system into a two-coordinate

(13)

Figure 2.5: A block diagram for the control loops.

Figure 2.6: A block diagram for eld oriented control of an AC-motor.

(direct and quadrature) time invariant system with use of the Clarke and Park transformations[7]. This two-coordinate (d and q) system is xed to the rotating rotor as seen in Figure 2.4 (b).

A owchart of the FOC process is shown in Figure 2.6. The process starts by measuring the currents

owing in each of the phases in the AC motor. In order to nd the direct and quadrature currents id

and iq the Clarke and Park transformations are used. The Clarke transformation converts the ia, ib and ic into the ctional iαand iβ by Equation (2.8),

( iα= ia

iβ= 1

3(ib− ic) (2.8)

and by utilizing the Park transformation id and iq are found according to Equation (2.9), where θ is the electrical position of the rotor,

 id= iαcos(θ) + iβsin(θ)

iq= iβcos(θ) − iαsin(θ) (2.9)

The next step is to compare id and iq to the reference values dened by the user to generate the error signals for the PI controller. Generally for a BLDC motor, id,ref is set to zero. For permanent magnet synchronous motors a negative id,ref is sometimes used in a process called Field Weakening in order to achieve higher than rated rotation speeds [8]. The output from the PI controller are the two voltages

(14)

Vd and Vq. After being transformed by the inverse Park transformation Vα and Vβ are found. These voltages are used in the Space Vector Pulse Width Modulation process to produce the proper duty cycles for the three-phase inverter. For more information about this particular step, read Section 2.5. It should be noted that knowledge of the rotor position is vital to FOC. Numerous research has been done on the subject of sensor-less FOC where the rotor position is estimated from the back-EMF from the motor, for example JR Meveys very extensive master thesis report [9]. In this project however, an incremental rotary encoder is used to keep track of the rotor position.

2.4 Encoder

An encoder is an electrical and mechanical device which converts the angular position of an axis or similar objects to an digital or analogue code. There are two main types of rotary encoders, incremental or absolute. An absolute rotary encoder keeps track of its position even when there is no power connected to the system. An incremental encoder records changes in position but doesn't know where it is directly on power-up. In this project an incremental encoder was used.

In Figure 2.7 the output from an incremental encoder can be seen when the motor is rotating clockwise as well as counter-clockwise. An incremental encoder has three outputs; A,B and Z. The direction of rotation can be found from detecting which of the A or B pulses arrives rst, or in other words the phase dierence between the A and B pulse. The Z pin pulse occurs when the encoder reaches a specic angular position. This can be used to nd the absolute position of an incremental encoder.

Figure 2.7: Output from an incremental encoder when the motor is rotating in dierent directions

2.5 Space Vector Pulse Width Modulation

2.5.1 The three-phase inverter

The purpose of a power inverter is to change direct current into alternating current and a typical three- phase power inverter is shown in Figure 2.8. In this gure VDC is the continuous inverter input voltage and A,B & C are the three phases of the motor. Number 1-6 represents six switches which are controlled by the inverter. In order to avoid a short circuit situation, the upper and lower switches of the same inverter leg (for example switch 1 and 2) should never be on at the same time. However, at least one switch in each leg should always be on[10].

Since a three-phase inverter has three legs, this creates a situation where the output from the inverter can be one of eight dierent states at any given time. These states can be seen in Figure 2.9 and are

(15)

Figure 2.8: A three-phase inverter, motor, and a DC link shunt resistor.

represented by the space vectors V0 to V7.[10]

In order to create a smooth sinusoidal curve inside the motor, fast switching between these eight states are required. At the same time, it is necessary to arrange the switching sequence in such a way that the switching from one state to the next is done by switching only one inverter leg in order to minimize harmonics. The Space Vector pulse width modulation technique is a good choice for this task[11].

Figure 2.9: A table of the dierent space vectors used in SVPWM.

2.5.2 Space Vector Pulse Width Modulation

Space Vector Pulse Width Modulation (SVM) is one of many dierent methods to generate pulse width modulation (PWM) outputs. Compared to the commonly used sinusoidal pulse width modulation, SVM generates lower current harmonics and a higher maximal modulation index[11][12].

The role of SVM is to control the rapid switching between the eight dierent states, shown in Fig- ure 2.9. When a switching state for a given inverter leg is 1, that means that the upper switch in that leg is on and the lower switch is o. When a switching state is 0, that means that the upper switch is o and the lower switch is on. In Figure 2.8 the inverter is currently in state 101 with switches 1,4 and 5 on, which corresponds to space vector V6. The space vectors V7and V0are zero-current vectors, which means that no current enters the motor through the power inverter when the switches are in these states.

Let's for example assume that some Vα and Vβ are given from the inverse Park transformation. A voltage Vref is then obtained by Equation (2.10) [2],

Vref = q

Vα2+ Vβ2 (2.10)

θ = arctanVα Vβ

(2.11)

(16)

An image representation of the space-vectors as well as Vref can be seen in Figure 2.10. By projecting Vref onto the two space vectors V1 and V2, the times T1, T2 can be found. These times represent the amount of time during the next PWM period Tsof which the inverter should be in the switching state corresponding to space vector V1and V2 respectively. This can be written as[2],

Z Ts 0

Vref = Z T1

0

V1dt +

Z T1+T2 T1

V2dt + Z Ts

T1+T2

V0dt (2.12)

Ts= T0+ (T1+ T2) (2.13)

The method to nd the exact times depends on where the vector Vref is pointing, and won't be covered in this report. During the remaining time T0 = Ts− (T1+ T2) of the PWM period both of the zero vectors V0 and V7 have to be used. In this example when Vref is between V1 and V2, the corresponding inverter output can be seen in Figure 2.11. Note that for the rst and last period marked as T40, the inverter is in state V0, but in the middle two periods marked T40, the inverter is in state V7.

Figure 2.10: A representation of the space vectors V1 to V6, and a voltage vector Vref.

Figure 2.11: The voltages of the three phase and the corresponding space vectors for a PWM period Ts.

(17)

2.6 Current Measurement

In order to control the motor currents in a satisfactory way, good measurements of the phase currents is vital. There are several dierent methods available in order to measure the current, for example current sensors such as Hall sensors or current transducers. These methods works well but brings disadvantages such as drive cost and non-linearity. For low-cost drive systems, some other techniques exists. The most common is probably to measure the DC-link current using a single shunt resistor. Another common solution is to place a shunt resistor in series with each emitter of the low-side switches [13]. Since the purpose of this project is to design a low-cost solution, the two latter techniques are covered in this report. For the rst system design, the single-shunt method is used and for the second system design the three-shunt method is used.

The single shunt circuit can be seen in Figure 2.8. The shunt is placed as a DC-link between the switches and the ground. In this case, precise knowledge of the PWM switching pattern is required in order to sample the voltage drop over the shunt at precisely the correct time. Depending on which switching state the inverter currently is in, a single current can be measured. For example, let's assume that the inverter is currently in state [101] as in Figure 2.8. In this state the current owing into the motor is ia+ ic. Since ia+ ib+ ic= 0 this means that the current we measure is ia+ ic= −ib. A table of which current can be measured in which space vector can be seen in Figure 2.12.

Figure 2.12: A table of the current owing through the DC-link shunt for dierent space vectors.

As explained in Section 2.5.2, the inverter will almost always switch rapidly between the zero vectors and two active vectors. This means that during a single PWM period, up to two dierent currents can be measured depending on the direction of Vref. Note that measuring two currents is enough since the third current can be reconstructed by calculations. The only time when only one current can be measured is if Vref is too close to one of the space vectors. In this case only the current corresponding to that space vector can be sampled. The reason for this is that sampling a current takes a small time, but if Vref is too close to a space vector, the time spent in the adjacent space vector will be too small for a reliable measurement.

In order to produce a satisfactory sample the timing of the sampling is usually set in the middle of the active vectors. In Figure 2.11 an typical PWM period can be seen where two currents could be measured. For space vector V1the measurement should happen after a time T40 +T21/2and for V2 after a time T40 +T21 +T22/2, resulting in measurements of currents ia and −ic.

The second technique covered in this report is the three-shunt current measurement method. By placing a shunt resistor at the emitter of each low-side switch as seen in Figure 2.13, all three currents can be measured at the same time instead of one at a time. In that case, the timing of the measurements is not in the middle of an active space vector but instead in the middle of the zero vector V0, when all lower side switches are turned on. This creates a dierent limitation, namely that the time T0 has to be big enough. The limitations for the two techniques can be seen in Figure 2.14. The blue areas are areas where current measurements are limited or impossible altogether if Vref is in that area. Dierent

(18)

methods may be used to circumvent these problems but the easiest one is probably to ignore all the measurements in these regions. [14]

Figure 2.13: The placement of the resistors in the three-shunt current measurement method and the switching state during measurements.

Figure 2.14: If Vref is inside the blue regions, current measurement is dicult or impossible. The gure to the left is for three shunt current detection and the right one is for single shunt current detection

2.7 Torque ripples

One of the main disadvantages of permanent magnet synchronous motors (PMSM) are the parasitic torque pulsations which occurs at periodic rotor positions. These torque pulsations are especially no- ticeable at low-speed operations, and is naturally ltered down at higher rotor speeds [15]. These are various sources of the torque pulsations, such as deviations from a sinusoidal ux density distribution in the air gap, errors in current measurements, phase unbalancing and cogging. Torque ripple minimization techniques can be classied into two dierent broad categories. The rst category consists of techniques aimed at the motor design so that the characteristics of the PMSM approaches the ideal case. This would make the torque production more smooth, but would complicate the production process and increase the cost of the motors. The second class of techniques consists of algorithms used for an additional control eort to correct for these non ideal characteristics of the machine [16]. Lots of research has been done

(19)

on the second class of techniques, and a technique named Iterative Learning Control [15] was tested and evaluated in this project.

2.8 Controllers

Two dierent kind of controllers are used in this project, the PI controller and ILC.

2.8.1 PI controller

The PI controller is a standard proportional, integrative and derivative (PID) controller where the derivative part is set to zero. The PID controller algorithm is:

u(t) = Kpe(t) + Ki Z t

0

e(τ )dτ + Kdd

dte(t) (2.14)

where e(t) is the error signal (reference signal minus the current signal value) at the time t, and u(t) is the controller output at time t. The PID controller works just as well in discrete time as it does in continuous time, but the equation looks slightly dierent.

2.8.2 Iterative learning control (ILC)

ILC is a control algorithm created to reduce the error of periodic disturbances. The control law used in this project has the following equation:

ui+1(n) = (1 − α)ui(n) + Φei(n) + Γei+1(n) (2.15) where n is the position, ei is the error during the ith repetition, ui is the input to the system during the ith repetition, α is a forgetting factor to reduce the eect of temporary disturbances, Φ and Γ are ILC tuning variables. In ILC, the error and controller output for each position are saved in a memory and updated each repetition in order to reduce the eect of the periodic error. When using ILC in a PMSM the following condition must hold in order for the algorithm to converge[15], where Kt is the torque constant and J is the combined inertia of the rotor and the load .

k1 −Kt

J Φk < 1 (2.16)

(20)

Chapter 3

Implementation

3.1 Project Specications

The present project is concerned with the inner servo system shown in Figure 2.1. The system is intended to control the position of the motor via two inputs. The rst input species the motor rotation direction.

For a zero on the input the motor will spin in a counter-clockwise direction, and for a one the motor will spin in a clockwise direction. The second input was a stream of pulses. For each received pulse the motor should rotate one encoder step. An important characteristic of the rst input is that the unit sending the stream of pulses (the outer servo system) changes the pulse rate every 50 milliseconds, and during these 50 ms the pulse rate is constant.

The limit of the nal movement of the outer servo system was about 35 degrees per second. The gear ratio will be somewhere between 1:40 to 1:50 which means that the maximum rotation speed of the motor needed for this project will be about ve revolutions per second, or 300 rpm. This is quite a slow rotation speed, but on the other hand the error in position had to be very low. In the nal position, the error had to be max 2 encoder points out of 65536 for that encoder. The encoder in the inner system has a resolution of 8192 points per revolution. This converts to an acceptable encoder error of about

2∗8192∗50

65536 = 12.5points for this project with a gear ratio 50:1, which is about 0.5 degrees.

3.2 Motor Specications

The motor used is this project is a 4-pole FL57BLS03 DC Brushless Motor. The specications for this motor are given in Table 3.1. The motor is also equipped with a HKT 56 incremental rotary encoder from Hedss. This encoder has 2048 counts of phase A and B per revolution, but if you count both

anks for both the A and B channel the precision is 8192 points per revolution which corresponds to a mechanical resolution of ≈ 0.044 degrees.

The electrical position of the rotor in the FOC loop is controlled by the variable θ. This is a 16-bit variable which means that the precision is 65536 points per electrical revolution. The motor has 2 pole- pairs, which means that for each mechanical revolution there are two electrical revolutions. So if the motor moves one encoder point, the variable θ changes 65536 ∗ 2/8192 = 16 points.

3.3 Pulse-width modulation

The pulse width modulation circuit of the TMPM373 gives you two options for waveform; sawtooth or triangular. In this project a triangular waveform was chosen, since it gives you a symmetrical center aligned PWM output automatically. A triangular PWM waveform means that the PWM counter starts at zero, counts up to a max value, and counts downwards to zero again which would look like a triangle in a diagram.

The output of the PWM circuit is controlled by a counter in the CPU. When the CPU is operating at 80 MHz, the resolution of the PWM counter is 25 nanoseconds when using a triangular waveform. For

(21)

Table 3.1: The motor specications.

each phase a comparator variable is then set, and when the counter is below that comparator variable the PWM output for that phase is on. This can be seen in Figure 3.1. In this project, the PWM frequency was set to 20 kHz which means that the maximum counter value was set to 1/25∗1020000−9 = 2000

Figure 3.1: The pulse width modulation counter operation and output for a single phase.

3.4 Computer Communication

Communication between the microprocessor and the computer is done via an serial port using an Uni- versal Asynchronous Receiver/Transmitter (UART) which is a on-chip feature of the microprocessor. An UART sends bytes of data by transmitting the individual bits sequentially. Another UART is used as the receiver and puts the received bits in a shift register until a full byte has been assembled. The receiver and transmitter UART has to be set to the same number of data bits per transmission, transmission rate, parity bit setting and other options in order to work. In this project 8 bits of data was sent in each transmission, plus a start and a stop bit. The baud rate was set to 115200 bits per second.

3.5 Current Measurement

For the rst system design the single-shunt described in Section 2.6. For the second system design the three-shunt method was used. Both system designs used the circuit described in this chapter to measure the current owing through the shunt resistor(s). The switch from the single-shunt to the

(22)

three-shunt method was done because of easier timing implementation. It was also possible to always measure the current of all three phases with the three-shunt method. In the single shunt case there are certain moments for each revolution of the motor when the electrical vector is in areas where current measurements are impossible.

The circuit in Figure 3.2 was chosen in order to reliably measure the current [17]. This circuit works for both the single shunt and the three-shunt case. Some additional components such as capacitors was added to various places in order to reduce noise.

Figure 3.2: A circuit used to measure the current passing through a shunt resistor.

Let's analyse what this circuit does. The operation amplier is assumed to be ideal, which means that it has an innite amplication, innite input resistance, zero output resistance and V+ is equal to V at all times. This gives us the following equations

V = Vout R3 R3+R4

V+= Vin+ (10 − Vin)RR1

1+R2

V+= V

(3.1)

Combining these equations leads to an expression for the output voltage Vout

Vout = (Vin+ (10 − Vin) R1 R1+ R2

)R3+ R4

R3 (3.2)

= (Vin(1 − R1

R1+ R2) + 10 R1

R1+ R2)R3+ R4

R3 (3.3)

The maximum peak current allowed into the motor at stall torque is 16.5 A according to the motor specications in Figure 3.1. Since Vout is sent straight into one of the analogue-to-digital inputs of the processor it should never go above 5 V or the processor might break. Rshunt was chosen to be 0.022 which gives the maximum voltage drop over the resistor to be U = 0.022 ∗ ±16.5 = ±0.363 V. The resistors then needs to be dimensioned so that the voltage Vin= −0.363V to +0.363 V corresponds to a Vout = 0V to 5 V.

A good place to start is to assume that when Vin = 0, the output voltage is Vout = 2.5 V. The amplication needed to push Vout up to 5 V when Vinis 0.363 V is then Av = (5−2.5)0.363 = 6.9times. A close match in the E12 resistor series would be to put R4 = 120kΩ and R3 = 22kΩ which gives the amplication Av= R3R+R4

3 = 22kΩ+120kΩ22kΩ = 6.55 times.

Given this amplication, it's straightforward to nd the values of R1 and R2to get the wanted oset of +2.5 V.

(23)

2.5 = (0 ∗ (1 − R1 R1+ R2

) + 10 R1 R1+ R2

) ∗ 6.55 (3.4)

R1

R1+ R2 = 2.5

65.5 (3.5)

A close enough match (again from the E12 resistor series) in this case is R1= 2.2kΩand R2= 56kΩ, diering only ≈ 1% from 2.5/65.5.

3.6 First design

The rst design of the system consisted of three separate PCBs (printed circuit boards) as seen in Fig- ure 3.3. The rst PCB had a UART communication bus, a linear voltage regulator, a crystal oscillator and all of the CPU pins drawn to dierent connectors. Basically everything needed to get the micro- processor running and be able to communicate with a computer. This PCB is the left-most one in Figure 3.3.

The second PCB was a three-phase inverter board. The components used was three switch controlling ICs (integrated circuits), six MOSFET switches and three shunt resistors. This card is in the top-right corner of Figure 3.3. As can be seen from the gure, three sets of cables goes out of this PCB. First, there is a yellow, red and black cable going into the motor. These are the three-phase connectors for the motor currents. Then there is a wide 16 pin IDC connector going between the inverter board and the CPU board (and going out of the picture for a little while). This connector contains the cables for the six switches of the inverter. The last set of cables are the red and black cables going down to the last PCB.

These cables are connected to the shunt resistor and transports the signal down to the measurement circuit on the last PCB.

The third PCB is a card made for an entirely dierent project, but since it had some high performance OP-amps (operational amplier) as well as all the support circuits needed to make them work, it was (after a couple of modications) used as a current measurement circuit. Only the part of the PCB inside the white circle was actually used by this project and the components used were only a couple of resistors and an OP-amp for each red-black connector couple. The three white cables going out of the picture are the outputs of the current measurement circuit and enters the analogue-to-digital converter in the CPU via the 14 pin IDC connector at the bottom of the CPU card.

Figure 3.3: A view of the dierent printed circuit boards used in the rst design of the system.

3.7 Second design

The second design of the system was done by integrating all necessary components on one single PCB.

This PCB, without the ground planes drawn out for easier viewing, can be seen in Figure 3.4. The legend

(24)

points out where specic important components are located on the PCB. The schematics for the PCB can be found in appendix 6.2. The schematics for this PCB was drawn by Andreas Nilsson at Research Electronics and the CAD was done by me in a program called Tango PCB.

The PCB is fed 36 V as input voltage at no 1 in Figure 3.4, since that is the rated voltage for the motor. This voltage is reduced to 12 V by an LM317 linear voltage regulator located at no 5. The 12 V is used to power the three no 9 ICs, which controls the switching of the six power inverter switches. There are also two dierent LM340 linear voltage regulators which regulates the 12 V down to 5 V, marked as no 6. The reason to have two dierent regulators is to create separate circuits so that noise is limited.

Integrated circuits tend to use current in short, bursty segments and such behaviour tend to create a lot of noise. One of the 5 V regulators powers a circuit (no 12) used to create -5 and +10 voltages used to drive the operational ampliers of the current measurement circuits, no 7. The current measurement circuit is placed very close to the shunt resistors, marked as no 8. The second of the 5 V regulators is used to power the microprocessor (no 10), and the communication ICs (no 14 and 13).

The system in real life can be seen in Figure 3.5 with everything connected. The big heat sink seen in the upper parts of the system is due to bad choice of voltage regulator. Using a linear regulator to bring the 36 V input voltage down to 12 V produced a lot of heat. The 12 V part of the PCB used about 0.15 Ampere of current so the power loss in the linear regulator will be (36 − 12) ∗ 0.15 = 3.6 watt. This required quite a big heat sink to dissipate. In the next production iteration the linear regulator will be replaced by a switched voltage regulator which produces almost no heat.

Figure 3.4: The printed circuit board used for the second layout of the system.

(25)

Figure 3.5: The second design of the system with everything connected.

3.8 Programming

The embedded software used in the microprocessor was developed in IAR Embedded Workbench and written entirely in C. Everything needed to make the system work in terms of software will be covered in this section.

3.8.1 Main method

The main loop of the software has the following structure:

int main ( ) {

init_CPU_clock ( ) ; __disable_interrupt ( ) ; init_IO_ports ( ) ;

i n i t _ i n t e r r u p t s ( ) ; __enable_interrupt ( ) ;

// I n i t i a l i z e a l l u n i t s such as UART, com−port , timer e t c . . .

// I n i t i a l i z e a l l g l o b a l v a r i a b l e v a l u e s . . .

FOC_startup ( ) ; //Do zero−current AD measurements , and i n i t FOC while ( encoder_foundZphase==0)

(26)

{

syncEncoder =1; // s p i n s the motor at a low speed }

syndEncoder =0;

delay =5;

while ( delay ) ; //Wait some time u n t i l motor s t o p s moving while ( 1) //Main loop

{

tgt_inp ( ) ;

i f ( print_info_flag ) {

// p r i n t i n f o f o r data c o l l e c t i o n . . .

} } }

All of the initialization functions looks almost the same. The features of the microprocessor used in this project are;

16-bit timer

Vector engine, calculation unit for motor control

Programmable motor driver, 3-phase PWM generator and generator of synchronous AD converter start triggers

Encoder input circuit, counter and comparator for absolute position detection

General-purpose serial interface (UART), communication circuit

12-bit AD converter, analogue-to-digital (AD) converter circuit

General-purpose Input/output ports

In order to initialize these you just write to a bunch of registers in the order specied in the manual.

For example, this is the code to initialize the Vector Engine in the microprocessor:

void init_VE ( void ) {

VEEN=0x3 ;

VEERRINTEN=0x2 ; VEREPTIME=0x10 ; VETRGMODE=0x8 ; VEMODE1=0x2 ; VEFMODE1=0x50 ; VEMDPRD1=0x7d0 ; VEEMGRS1=1;

}

Once all the initialization is done, the next step is to do the FOC start up. This is an automated process where the microprocessor saves the AD values from the current measurement circuit while no current is owing into the motor. This is done three times with some delay in between to minimize the eect of disturbances on the measurements.

(27)

The next step is to look at the encoder synchronization. After the initialization of the programmable motor drive (PMD), an interrupt is turned on so that every time the PWM counter reaches the maximum value a function called PWMinterrupt() is called. This is used to either start the main FOC loop (most of the time) or to start a smaller FOC loop only used for encoder synchronisation. This small FOC loop is shown in the next code segment.

void VE_syncEncoder ( void ) {

i f (VESCHTASKRUN&0x020 ) print_to_com0 ( " Error , . . . " ) ; VETHETA1 += 1 ; // spin around u n t i l Z i s found

i f (EN1TNCR&0x1000 ) {

ENC_foundZ=1; // encoder Z found }

VEACTSCH=0x10 ; // Schedule 1 VETASKAPP=0x50 ;

VECPURUNTRG=0x2 ; //run cpu

i f (VEERRDET&0x2 ) print_to_com0 ( "PWM i n t e r r u p t detected . \ n" ) ; }

3.8.2 Vector Engine

Let's look at the purpose of the vector engine (VE). The VE is a part of the microprocessor which has its own CPU and hardware so that the main CPU can be free to do other things. To control the VE, you specify a schedule to be executed. After specifying a schedule, you choose a task for the VE to start executing from. The VE will then do all tasks from that task to the last task in that specic schedule.

The dierent tasks are all used in the FOC loop and are as follows;

Current control, this is PI control of the currents

SIN/COS computation, calculates sin/cos of the current θ

Output coordinate axis conversion, this does the inverse Park transformation

Output phase conversion, this does the space vector modulation

Trigger generation, calculates PWM compare values for the phases

Input processing, this collects the measured current values

Input phase conversion, this does the clarke transformation

Input coordinate axis conversion, this does the Park transformation

There are four schedules available to choose from. The rst schedule (schedule 0) is Individual task execution where you specify just one task to execute. The second schedule executes all task (schedule 1).

The third schedule (schedule 4) executes all tasks except the current control (useful for forcing the motor to move without any measurements of the currents) and the last schedule (schedule 9) only executes Output control, trigger generation and Input processing. The last schedule is used to do the zero-current AD measurements.

The small FOC loop in the code segment above shows how you use the vector engine properly. First there is a small safety check so that no other schedule is currently executed. Then, θ is increased by one.

A PWM/FOC frequency of 20 kHz where you increase θ by one for every loop means one revolution will take approximately 6.5 seconds. If Z is found the motor is stopped and the synchronisation complete.

Then, the rst schedule and the Current control task (0x50) are chosen and the VE CPU started. Finally a last safety check is conducted to check that the CPU didn't get stuck/took too long during calculations.

(28)

3.8.3 Key press detection loop

The next part of the program is the main loop. By pressing w on the keyboard the print_info_ag turns true which prints chosen variables at a chosen speed. This is how the data for all the experiments in this project were collected. The tgt_inp() function detects when data is being sent to the microprocessor, from a computer for example. Its structure is as follows;

void tgt_inp ( void ) {

i f ( char_receive_count > 0) {

char_receive_count −−;

char=∗r e c e i v e _ p o i n t e r++;

switch ( char ) {

case ' h ' : {

. . . } . . . default :

{

print_to_com0 ( "%c has no command attached to i t , " , char ) ; print_to_com0 ( " p r e s s 'h ' f o r a v a l i a b l e commands . \ n" ) ; break ;

} } } }

Every time a character is received on the UART it is put into a receive buer and char_receive_count is increased by one. The variable receive_counter is always pointing at the current location of the receive buer, and once the CPU executes the tgt_inp() function it checks if there are newly received characters in the buer. If a character is received, some commands corresponding to that character is executed with the switch-statement. Some of the most useful commands are h (prints a help menu), + and - which controls the rotation speed of the motor, p which turns the FOC loop on/o, m which changes between dierent driving modes, c which allows you to enter a new Iqref etcetera.

The print_to_com0 command is a function that sends characters one at a time via the UART to the computer, where a program made by Research Electronics is used to receive the data and communicate with the microprocessor.

3.8.4 Field Oriented Control loop

Before looking at the main FOC loop a few supporting functions need to be looked at. Since the system was tested on its own, a temporary function that created motor commands had to be implemented. This function was made as simple as possible:

void MC_tick( int tick , int d i r ) {

i f ( d i r ==0) {

MC_pos += t i c k ;

i f (MC_pos >= EN1RELOAD) MC_pos −= EN1RELOAD;

References

Related documents

This Section contains results from real experiments on the double tank sys- tem controlled via a wireless CTP network with outage compensation imple- mented as a part of the

The reason for the selection of background technique is that inter stage gain in pipeline ADCs vary with time because of temperature, device aging and power supply

Om detta är rätt sätt finns det nog inget svar på, men vi anser att sådana små saker som SS berättar om gör det lättare både för lärare samt eleverna, det blir på så sätt

Nyckelord: Falklandsöarna, Darwin, Goose Green, Malvinas, Darwin Hill, Boca House, Burntside House, Burntside Pond, Camilla Creek, Taskforce Mercedes, 2 Para, LtCol H Jones,

Resultatet visar att motivationen är snarlik om personen bor i Stockholm kontra Eskilstuna, för att besvara frågeställningen så finns det alltså ingen signifikant skillnad

Vid en första anblick kan det förefalla orimligt att någon kan fällas enligt råd- givningsförbudet för att ha haft insiderinformation och lämnat ett råd till någon annan

Genom att se hur Region Örebro län använder sin styrning och sedan tillägga ett struktureringsteoretiskt perspektiv kan studien bidra till en ökad förståelse för

Om naturvetenskap skall dra till sig ungdomar i framtiden måste de tidigt få uppleva att det är roligt och spännande och framför allt inte svårt (Jakobsson &amp; Marand, 1995).