Robust servo motor control design How to make a toy servo motor useful in industry Master’s thesis in Systems, Control and Mechatronics Sven Åkersten Department of Electrical Engineering CHALMERS UNIVERSITY OF TECHNOLOGY Gothenburg, Sweden 2018 Master’s thesis 2018:015 Robust servo motor control design How to make a toy servo motor useful in industry Sven Åkersten Department of Electrical Engineering Division of Automatic control Chalmers University of Technology Gothenburg, Sweden 2018 Robust servo motor control design How to make a toy servo motor useful in industry Sven Åkersten © Sven Åkersten, 2018. Supervisor: Victor Påsse, Pluspole Examiner: Balázs Adam Kulcsár, Electrical Engineering Master’s Thesis EX015/2018 Department of Electrical Engineering Division of Automatic control Chalmers University of Technology SE-412 96 Gothenburg Telephone +46 31 772 1000 Typeset in LATEX Gothenburg, Sweden 2018 iv Robust servo motor control design How to make a toy servo motor useful in industry Sven Åkersten Department of Electrical Engineering Chalmers University of Technology Abstract Small electric servo motors are found almost everywhere today. Within the hobby of radio controlled vehicles there exist very high performing servo motors but they lack most features required for industry use. This project looks into solving the control algorithm for one such servo redesigned for industry use. With not every specific application not known a very robust solution is required. Moreover the system should also have the possibility to limit acceleration and/or velocity. A trajectory generator and a H infinity designed gain scheduled PID-solution is therefor suggested and implemented on the real servo motor. By constructing a simple test rig the system could be tested with different loads and the system behaviour can be compared with the a prior to this project existing controller. Keywords: PID, Gain scheduling, robust control. v Acknowledgements First I want to thank my examiner Balázs Adam Kulcsár for his help in this thesis. During the project always being very helpful and giving new perspectives when discussing different solutions. With an office almost always open despite a lot of other students asking for his time. I would also like to thank Victor Påsse and all the other people at Pluspole. A very interesting place to work, exchange ideas with highly intelligent engineers and learn a lot at. Especially at Thursday nights when the place almost becomes a Makerspace. Sven Åkersten, Gothenburg, October 2018 vii Contents List of Figures xi 1 Introduction 1 1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.1.1 Previously existing solution . . . . . . . . . . . . . . . . . . . 1 1.2 Scope of this thesis . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1 1.2.1 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2 2 Theory 3 2.1 Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.1.1 BLDC motor . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 2.1.2 Load . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 2.1.3 Gearbox, with backlash . . . . . . . . . . . . . . . . . . . . . . 5 2.1.4 Combined load and motor model . . . . . . . . . . . . . . . . 5 2.2 Sensors and signal processing . . . . . . . . . . . . . . . . . . . . . . 6 2.2.1 Output shaft position sensor . . . . . . . . . . . . . . . . . . . 6 2.2.2 Inner position for velocity estimation . . . . . . . . . . . . . . 6 2.2.3 Discrete time low pass filter . . . . . . . . . . . . . . . . . . . 6 2.3 Controller algorithm . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.3.1 Trajectory generator, acceleration and velocity limits . . . . . 7 2.3.2 2 DOF PIDf controller . . . . . . . . . . . . . . . . . . . . . . 7 2.3.3 Robust H∞ norm controller . . . . . . . . . . . . . . . . . . . 9 2.3.3.1 Generalised performance and robustness . . . . . . . 9 2.3.3.2 H∞ norm . . . . . . . . . . . . . . . . . . . . . . . . 11 2.3.3.3 Optimisation problem for controller generation . . . 11 3 Implementation 13 3.1 Test rig . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13 3.2 Models, simplifications and parameter estimations . . . . . . . . . . . 13 3.2.1 Current feed forward . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.2 Parameter estimation . . . . . . . . . . . . . . . . . . . . . . . 14 3.2.2.1 Motor parameters . . . . . . . . . . . . . . . . . . . 14 3.2.2.2 Combined load and motor parameters . . . . . . . . 14 3.3 Controller generation . . . . . . . . . . . . . . . . . . . . . . . . . . . 15 3.4 Controller implementation . . . . . . . . . . . . . . . . . . . . . . . . 15 3.4.1 Discretization of controller and filter . . . . . . . . . . . . . . 15 ix Contents 3.4.2 Integral anti-windup . . . . . . . . . . . . . . . . . . . . . . . 16 3.4.3 Controller switching . . . . . . . . . . . . . . . . . . . . . . . 17 3.4.4 Bumb-less transfer . . . . . . . . . . . . . . . . . . . . . . . . 18 4 Results 19 4.1 Step response . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 4.2 Quick random reference changes . . . . . . . . . . . . . . . . . . . . . 22 4.3 External disturbance . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 5 Conclusion 27 5.1 Implemented solution . . . . . . . . . . . . . . . . . . . . . . . . . . . 27 5.2 Further improvements . . . . . . . . . . . . . . . . . . . . . . . . . . 27 x List of Figures 2.1 Equivalent circuit of DC-motor model . . . . . . . . . . . . . . . . . . 4 2.2 Non-linear model of backlash in gearbox describing the two relation- ships between input and output torque. . . . . . . . . . . . . . . . . . 5 2.3 Two trajectories taking a reference step in position of one rad, with zero initial and final velocity. One where maximum speed is reached the other not. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 2.4 2 DOF PIDf with the parameters b and c in between 0 and 1. . . . . 8 2.5 Special form with controller, plant with disturbance inputs W (in- cluding reference), controlled input u, measured plant outputs y, per- formance outputs Z and uncertainty feedback delta. . . . . . . . . . . 10 2.6 Weighted performance diagram where all signals are normalised by and weighted in frequency domain. . . . . . . . . . . . . . . . . . . . 10 3.1 High robustness, low performance controller frequency domain weights. 16 3.2 High performance, low robustness controller frequency domain weights. 17 4.1 Step response with no external load and low supply voltage. . . . . . 20 4.2 Step response with small inertial external load and low supply voltage. 20 4.3 Step response with no external load and high supply voltage. . . . . . 21 4.4 Step response with small inertial external load and high supply voltage. 21 4.5 Multiple quick reference changes with no external load and low supply voltage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22 4.6 Multiple quick reference changes with small inertial external load and low supply voltage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.7 Multiple quick reference changes no inertial external load and high supply voltage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23 4.8 Multiple quick reference changes with small inertial external load and high supply voltage. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 4.9 Constant reference and application of external disturbance torque with low supply voltage. . . . . . . . . . . . . . . . . . . . . . . . . . 25 4.10 Constant reference and application of external disturbance torque with high supply voltage. . . . . . . . . . . . . . . . . . . . . . . . . . 25 xi List of Figures xii 1 Introduction Electrical servo motors are used in a wide range of applications in both consumer products and industry. In many applications there is not enough space or economy to fit a conventional industrial servo motor. Luckily there exits small servo motors made for radio control vehicles/toys. The power and torque produced by these motor with respect to their size is remarkable. Produced in large quantities and aimed for a consumer market they are also very cheap. However they are purpose built for model vehicles which means that they are hard to communicate with, have no good position feedback, and are constructed to be powered from a battery. 1.1 Background Most commonly they are designed to be used with the internal batteries of the radio controlled vehicle and therefore a voltage between 5-10 V . In industry and car applications most common voltages are 12 V or 24 V , sometimes even higher. By reconstructing their electronics to use standardised communication, be functional for a wide range of voltages and adapting the control algorithm to meet industry expectations and demands they can become possible replacements used by engineers in various products around. If they should be suited for wide range of applications more control have to be given to the developer who should be able to use the servo motor in his or hers application, features such as velocity/acceleration limits, current limits and position/velocity feedback. 1.1.1 Previously existing solution Previously a company have developed a mostly working solution with new electronics and software. However the control algorithm consists of two cascaded P- controllers where a position controller gives the reference to a velocity controller. The perfor- mance is not that great and a steady state error exists, especially in presence of any external disturbances. Nothing is known about the stability of the system with respect to different loads either. 1.2 Scope of this thesis The ultimate goal of this project would be the impossible task to make a controller that gives maximum performance (guaranteed stability and perfect reference track- ing) for all possible loads in all circumstances. In other words have a a gain of one 1 1. Introduction from reference to output and a gain of zero from disturbances to output with zero phase for all frequencies. Since this is fundamentally impossible the project must specify performance and stability requirements and implement a suitable controller meeting these requirements. The servo motor should manly be used by engineers and incorporated into other projects or products, therefor the end product of this thesis will assume the user to have some engineering knowledge. 1.2.1 Limitations All external loads will be estimated to fit within some linear model and the dynamics will not be dependent on position (angle). In the simplest case this will be a model with a rotational inertia with a viscous damping dissipating energy. The servo motor will be used by engineers that might not be that familiar with control systems or even electronics, therefor limiting performance and having a con- sistent behaviour is prioritised. Therefor a solution that adapts continuously during operations is not desired. 2 2 Theory To be able to design a control algorithm for the system some knowledge of the controlled system is required in some form of models. Due to the nature of the problem the load cannot be known therefore any model of the system will be highly uncertain. Uncertain linear models would be preferred to be able to use linear control theory. However within the servo motor one major non-linear behaviour is known to be present, the gearbox backlash. This non-linear behaviour can be very hard to approximate within uncertainties in a linear model. One way to handle non- linear system in a linear way is to utilise the idea of gain scheduling, approximating the system as different linear systems (different gains) for different operating points of the non-linear system parts (scheduling parameters). However this requires the system to be locally linear around the selected operating points to perform well. By generalising the idea of gain scheduling and select different controller parameters depending on the when the backlash is a significant problem or not. Using one controller to reject external disturbances and keep position steady and another one to follow a fast moving reference that are not stable when being stationary. [1] With simple linear models linear controllers can be designed. To handle the large model uncertainties the controllers generated can be designed in a robust way. Ro- bust control is used to guarantee stability and performance over the uncertainty range including measurement noise. The system have a few measurement possibil- ities for position at given time instances. From this it is also possible to calculate velocity at each time instance. To fulfil the system requirements with a possibility to specify a maximum accelera- tion and velocity for each movement a trajectory generation algorithm is included. A simple implementation is an important part of this project since the available processing power relatively small. Controllers with high complexity or many internal states is therefore not desired. 2.1 Models 2.1.1 BLDC motor The internal brushless DC motor of the servo motor in combination with driving electronics can be seen as a conventional brushed permanently magnetised DC-motor [2] modelled with an equivalent circuit [3] described by figure 2.1. The resistance is the winding resistance, the inductance the winding inductance, the voltage source correspond to the back EMF voltage where the power dissipated 3 2. Theory Uin+ R L − + w ·Km Uin− Figure 2.1: Equivalent circuit of DC-motor model in the voltage source is the power that becomes mechanical power. Neglecting the assumed faster dynamics inferred by the inductance [2] and assuming 100% efficiency i.e. electrical power in equals mechanical power out, R = 0 which gives Uin = U = ω · Km according to figure 2.1. Equation 2.1 and 2.2 yields 2.3 that simplify to equation 2.4 stating that output torque can be expressed as proportional to motor current with the same constant as the motor voltage constant. Pelectric = U · I = Pmechanical = ω · τ (2.1) U = ω ·Km (2.2) ω · τ = ω ·Km · I (2.3) τ = Km · I (2.4) 2.1.2 Load The external driven load can not be known offline due to the nature of the problem where the application is not known. On the other hand some assumptions can be made and selecting some reasonable restrictions on the load dynamics. The servo motor cannot deliver infinity amount of torque or power. With respect to its size a reasonable maximum inertia is selected. The model of the load will not be especially accurate (the same model with uncertain parameter must fit all possible loads) a very simple model with large variation of the parameters is selected. The most simple solution with no dependency on the angle is an uncertain inertia and an uncertain viscous friction. The transfer function of such load with inertia J and viscous friction damping constant d is described by equation 2.5. ω̇ · J = τin − d · ω (2.5) 4 2. Theory 2.1.3 Gearbox, with backlash The gearbox between the inner motor and output shaft consists of a 4 stage reduction gearbox. The reduction gear ratio is about 360:1 (exactly 162197/450 to one). With 4 gear stages the gearbox have a significant backlash. The backlash can be regarded as a non-linear function where motor torque equal outer torque when the gears are in contact, described by equation 2.6. The gears lose contact when the torque though the gearbox change sign and get back into contact when the gears have moved relative to each other the same angle as the backlash is wide. This means that the backlash will mostly be significant when moving at low speeds and accelerations are small. τouter = { τmotor, contact 0, else (2.6) -1 -0.5 0 0.5 1 Torque at inner motor [Nm] -1 -0.5 0 0.5 1 T o rq u e a t o u tp u t s h a ft [ N m ] Non-linear backlash model Contact Else Figure 2.2: Non-linear model of backlash in gearbox describing the two relationships between input and output torque. 2.1.4 Combined load and motor model By combining equation 2.4 and equation 2.5 a model described by equation 2.7 of the system can be obtained where current is input and output is the state-variables velocity and position. [ θ̇ ω̇ ] = [ 0 1 0 −d J ] [ θ ω ] + [ 0 Km J ] I (2.7) 5 2. Theory 2.2 Sensors and signal processing In the hardware within the servo there are 2 different possible angle measurements. The commutation state of the internal brushless DC motor which provides a resolu- tion of 1/6 electrical revolution (60 electrical degrees) of the motor and a hall effect angular sensor on the output shaft. 2.2.1 Output shaft position sensor The output shaft have a sensor mounted measuring the output shaft angle. It is a hall effect encoder with some noise in the absolute angle that correlates with the angle and some hysteresis. The minimum sampling time is approx. 0.5 milliseconds. 2.2.2 Inner position for velocity estimation Every time the processor changes commutation state a time stamp in microseconds is saved. This means that the time at which the inner motor passes each 1/6 of an electrical revolution. The angle is therefore known at specific times and the average velocity between each commutation can therefore be calculated with a sampling time that varies inversely proportional with velocity. When the inner velocity goes towards zero this corresponds to the sampling time approaching infinity and therefore not updating the velocity measurement. A max- imum possible speed can be calculated by inferring the knowledge that if the motor haven’t changed commutation step the maximum possible angular change is 1/6 of a turn (60 deg). While the commutation step is constant the time since last change will correspond to a theoretical upper bound on the inner velocity. 2.2.3 Discrete time low pass filter A continuous first order low pass filter can be described as in equation 2.8. 1 1 + Ts (2.8) An Euler backward approximate discretization of this filter with sampling time h gives equation 2.9 1 1 + T z−1 hz (2.9) Results in a discrete domain filter as in equation 2.10. y[k] = αx[k] + (1− α)y[k − 1], α = h T + h (2.10) 6 2. Theory 2.3 Controller algorithm 2.3.1 Trajectory generator, acceleration and velocity limits A trajectory through state space can be generated in numerous ways [2], in this case the system should have two features that can be implemented using a tra- jectory generator. A maximum velocity and a maximum acceleration/retardation. Minimum time from one position to another with limited acceleration and velocity then will become a piece-wise constant acceleration with the three possible values, maximum acceleration, zero acceleration or maximum retardation. Integrating this acceleration profile will generate a trapezoidal velocity profile. Position will then follow a second order polynomial during acceleration/retardation and a first order polynomial (straight line) while constant maximum velocity. 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Time [s] 0 0.5 1 A n g le [ ra d ] Position 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Time [s] 0 1 2 3 V e lo c it y [ ra d /s ] Velocity 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1 Time [s] -10 -5 0 5 10 A c c e le ra ti o n [ ra d /s 2 ] Acceleration Figure 2.3: Two trajectories taking a reference step in position of one rad, with zero initial and final velocity. One where maximum speed is reached the other not. 2.3.2 2 DOF PIDf controller A two degree of freedom PIDf (see figure 2.4) controller consist of a common PID controller (control signal is a sum of Proportional, Integral and Derivative gain on the control error) with a few changes. It is a linear controller just like the a standard 7 2. Theory PID controller. The integral part is the same, a gain on the integral of the error. The proportional gain have two different gain with one gain for the actual position and another for the control error. The derivative gain have a two different gains as well, one for the actual derivative and another for the control error. Then a first order low pass filter to counteract the influence of high frequency noise. Such controller in parallel form is described in Laplace domain as 2.11 from measurements and reference to control signal. I = Kp(b · θref − θ) + Ki s (θref − θ) + Kd 1 + Tf · s (c · ωref − ω) (2.11) Figure 2.4: 2 DOF PIDf with the parameters b and c in between 0 and 1. The controller integral action is an essential part to counteract external disturbances as well as some of the not modelled (linear and non-linear) effects within the system that can lead to steady state error. A anti-windup is a function that limits the integral action when the control signal is saturated, in a linear setting the controller must be able to give an unlimited control signal [4]. If saturation occurs the error integral would still continue to increase while the control signal and system response would not, this will in a large unwanted overshoot. One way to implement an anti- 8 2. Theory windup is to stop the integration of the error so that the control signal never exceeds its maximum. 2.3.3 Robust H∞ norm controller By rewriting the whole closed loop system in a special form where performance and uncertainties are included as normalised costs in frequency domain it is possible to use the H∞ methodology. This makes it possible to guarantee performance and/or robustness. Unfortunately this methodology only take in consideration the absolute value of the system transfer function matrix components and not the phase resulting in that it is an over specified requirement for stability. In other words it is not a theoretical optimal solution, higher performance while still having a fully stable system can theoretically be achieved. 2.3.3.1 Generalised performance and robustness By studying a transfer function (matrix) the response (output) for different inputs can be studied. Constructing a general closed loop transfer function (matrix) where weighting functions (in frequency domain) are included, different matrix norms can relate the system gains for different output (Z) and input (W) signals. In other words a reference tracking objective, a disturbance response or a even control signal, all with frequency dependent cost functions can be specified as outputs. A matrix norm can provide a measure of how large the output signals can become for specific input signals (W) such as noise, external disturbances and reference. A optimal solution can be achieved in a general case where the outputs are costs that should be minimised with respect to the objectives. However an optimal solution might not be possible to calculate. 9 2. Theory Figure 2.5: Special form with controller, plant with disturbance inputs W (including reference), controlled input u, measured plant outputs y, performance outputs Z and uncertainty feedback delta. Figure 2.6: Weighted performance diagram where all signals are normalised by and weighted in frequency domain. 10 2. Theory 2.3.3.2 H∞ norm The H∞ norm is defined as the supremum [5] function on a transfer function (the least upper bound on all values in the set, in this case gain for any frequency). One interpretation of this can be the single maximum gain (absolute value) for any frequency or phase. Minimising this norm measure within the form described in figure 2.5 with respect to the free controller parameters results in a controller design that takes into account uncertainties and performance demands weighted in relation to each other. A very useful result since multiple objectives and demands can be compared and a solution to the required trade offs can be made mathematically. Minimising the H∞ norm is not optimal in a global sense but it is minimising the maximum gain and if the gain always is below one all disturbance responses will go to zero in infinite time (stability guaranteed). In other words the H∞ norm measures the worst case (worst element for the the worst frequency). However stability guarantees requires that the controller can take H∞ norm below one which is not always the case. 2.3.3.3 Optimisation problem for controller generation Write the system in figure 2.5 in a state space form where x is the state vector, z is the vector of performance measures (costs), y is the system output vector, w is the vector of disturbances (including reference), u is the vector of control signal. All elements within the transformation matrix (P) can be linear transfer functions.ẋz y  = A B1 B2 C1 D11 D12 C2 D21 D22  ︸ ︷︷ ︸ P(s) xw u  (2.12) Define the controller as any transfer function matrix from the measurements (y) to the control vector. If any of the disturbances are measured, for instance if a reference the system should track, redefine the plant 2.12 with one element of the output vector (y) be equal to the measured disturbance (the reference). u = K(s)y (2.13) Close the control loop on 2.12 with the controller 2.13 that is let the control sig- nals of the system be in terms of a transfer function matrix applied on the system measurements. Then it is possible to construct a transfer function matrix from the exogenous disturbances (w) to the performance measures (z) dependent on the controller 2.13 and the system P(s) in 2.12. z = T (P (s), K(s))w (2.14) Minimising theH∞ of the transfer function matrix over all controllers K(s) will result in the optimal controller in H∞ sense that is lowest possible gain (of cost) for the worst case (frequency and element) in the transfer function matrix. Any number of constraints can be added such as limiting the set of possible controllers or controller 11 2. Theory parameters. One example could be limiting the possible controller space to a PID structure with just the parameter space to minimise over. [6]. minimize K(s) ‖T (P (s), K(s))‖∞ subject to T internally stable (2.15) 12 3 Implementation The controller is directly implemented within the software of the servo. The system uses a 32 bit microcontroller running an operating system. Therefore all filters and the controller must be in discrete time. With a microcontroller the available process- ing power is limited which also requires simple realisation of the whole algorithm. Inferring as little changes as possible to the existing firmware will save developing time when implementing controllers and filters. By constructing and building a test rig where different load conditions could be tested the actual controller could be tested and compared to the previously existing solution. Especially the robustness for different loads could be tested for some loads within the feasible set. The existing system have possibilities to sample internal variables within the micro- controller during run time via debug interface. Which provides possibilities to test directly on the real system with all unknowns and non-linear behaviour. 3.1 Test rig The test rig make it possible to mount different weights as rotational inertia on a shaft. On one end of the shaft is the driving servo motor, the other have a high precision angle encoder. On the shaft a number of different weights can be mounted. The maximum inertia was selected as a reasonable maximum load the servo could be used for. 3.2 Models, simplifications and parameter esti- mations The controlled input was selected to be current for two reasons. First the user of the servo should be able to specify a maximum current for the servo motor to limit the output torque (approx. proportional to current, see equation 2.4) and to always make sure that the current always stays within maximum bounds irregardless what goes wrong in the position feedback loop. The current cannot be measured by the hardware, a feed forward algorithm based on the motor model see equation 3.2 is instead implemented. 13 3. Implementation 3.2.1 Current feed forward The motor velocity and input voltage is measured within the software. To control the motor input voltage (driving voltage) the duty cycle (D) is specified. The driving voltage is a fraction (the duty cycle) of the input voltage as in equation 3.1. Uin = D · Uexternal (3.1) The duty cycle cannot exceed 1 (or below -1 which represent negative voltage) since this would correspond to a higher voltage from the motor driver then its input voltage (hardware limit), the control signal (current) does therefor saturate when the absolute value of the duty cycle reach 1. The complete feed forward when no saturation occurs is therefore described as equation 3.2. D = ω ·Km+ I ·R Uexternal (3.2) 3.2.2 Parameter estimation The simplified combined load and motor model (2.7) only have two parameters, the motor voltage constant divided by the load inertia (Km J ) and the viscous damping constant divided with the load inertia ( d J ). Both the load inertia and the viscous damping constant is uncertain due to the nature of the task and therefore all pa- rameters in the model for controller generation is uncertain. However the current feed forward have the two motor constants, equivalent winding resistance (R) and motor voltage constant (Km). 3.2.2.1 Motor parameters To estimate the motor voltage constant (Km) the gearbox was removed and a few different voltages applied. By assuming no losses a proportional relationship between motor velocity and back emf voltage is obtained with the motor voltage constant as multiplying factor. The winding equivalent resistance have been estimated by the company prior to the project with a simple thermal model compensating for temperature changes. 3.2.2.2 Combined load and motor parameters By applying different up to maximum current on the real system in the test rig with both maximum inertia and no load at all the two parameter bounds can be estimated. Using the Matlab system identification toolbox and forcing the model to a state space model with one state (velocity) and canonical form the two parameters correspond to the A and B matrix. The A matrix will be the damping divided by the inertia ( d J ) and the B matrix the motor voltage constant divided by inertia (Km J ). ω̇ = A · ω +B · I (3.3) ω̇ = −d J · ω + Km J · I (3.4) 14 3. Implementation This is the best fit model parameters for the case of no load damping with both maximum and no load inertia. This correspond to maximum and minimum value of the Km J parameter and minimum value of d J parameter. The maximum damping (viscous friction) divided by the inertia is selected so its maximum braking torque requires no more then half of absolute maximum current at maximum velocity. 3.3 Controller generation Two linear continuous time domain 2-DOF PIDf controllers are generated with the help of the robust control box in Matlab. By selecting between two robust 2-DOF PIDf controllers, both high performance and maintaining stability when the backlash becomes a significant effect is possible. One high gain controller for high performance and one tuned more conservatively for holding a steady position/low frequency reference-tracking. Two linear controllers maintains performance and ro- bustness during different mode of operation of the non-linear system. Specifically when the backlash (and to some extent the voltage dead-space) is significant (low velocities/steady position and low control signal) and when it’s not (faster opera- tion/movement and high control signal). The high robustness controller (see fig. 3.1) desired system behaviour (Wmodel) taper of at a lower frequency then the high performance controller (see fig. 3.2). 3.4 Controller implementation The controller needs to be implemented in software in the micro controller therefore need to be in discrete time domain. Within the operating system it is possible to have a thread running periodically, with a minimum time between each execution call of one ms. Every time the thread is called by the operating system a number events occur in order. Position and velocity reference is updated according to trajec- tory, control signal saturation limits are calculated with respect to thermal, voltage and specified limits, position and velocity measurements are updated and then the controller function is called with all those parameters and return the new control signal that should apply. 3.4.1 Discretization of controller and filter The velocity first order low pass filter in 2.10 is applied directly at the inner velocity estimation. That means that the sampling time varies and therefor the filter coeffi- cient α is recalculated each time the motor commutates. Since derivation is a linear operator and the derivative of position is velocity: d dt (e) = d dt (θref − θ) = d dt (θref )− d dt (θ) = ωref − ω (3.5) The reference velocity is calculated within the trajectory generation and the velocity is already known. Therefore no discrete time derivation that can introduce more noise is required. However since the low pass filter is only implemented within the 15 3. Implementation 100 101 102 103 104 -100 -50 0 50 100 150 M a g n it u d e ( d B ) Wcmd Wmodel Wact Wt Wperf1 Wperf2 Wdist Bode Diagram Frequency (rad/s) Figure 3.1: High robustness, low performance controller frequency domain weights. velocity estimate for simplicity the velocity reference is not low-pass filtered as it should be. On the other hand the velocity reference does not contain any high frequency noise (generated) and by it’s own nature contain mostly low frequencies (limited acceleration i.e velocity derivative). The integral part of the PIDf controller is discretized with an backward Euler ap- proximation: ∫ e(t) ≈ ∑ h · e(kh) (3.6) 3.4.2 Integral anti-windup Two different signals saturate within the system and can lead to wind-up problems. When the control signal (current) reach it’s maximum possible (due to voltage re- strictions or thermal/specified limit) and when the micro controller cannot processes the motor commutations any faster and therefore limiting the velocity. The anti- windup consist on two conditions that stops the integration. Either if the velocity is above the absolute maximum (or below minimum) the system can reach and the position error have the opposite sign (maximum/minimum velocity with decreasing 16 3. Implementation 100 101 102 103 104 -150 -100 -50 0 50 100 M a g n it u d e ( d B ) Wcmd Wmodel Wact Wt Wperf1 Wperf2 Wdist Bode Diagram Frequency (rad/s) Figure 3.2: High performance, low robustness controller frequency domain weights. position error). Or if the control signal is saturated in the same direction as the error integral increases. 3.4.3 Controller switching To select between the two controllers two conditions are used. The fast controller is chosen when the absolute value of the position error is above a position threshold or the absolute value of the velocity reference is above a velocity threshold. To get back to the more robust and slow controller the absolute value of both velocity reference and position error needs to be below their respective thresholds. To minimise the risk of the system oscillating between the two controllers a hysteresis is added the the position error threshold. This since the position measurement will introduce some noise into the position error. These switching conditions result in a slow and robust control rejecting low frequency external disturbances when holding a position steady and during operation when backlash is significant causing limit cycle behaviour. While still having a fast controller when a movement is commanded or required to minimise a large error, basically aggressive operation when the backlash is less of an issue. This will in some sense create a tube with some margin around the reference 17 3. Implementation through state-space that the controller aggressively will force the system into and then slowly (within the tube) converge to the reference. 3.4.4 Bumb-less transfer When switching between different controllers (parameters) the control signal may take large steps when the gains change. This might cause unstable behaviour as it excite the system with higher frequency control signals then the linear controllers are designed for. Therefor the error integral is set at each controller switching so the control signal satisfy some conditions. In this case the error integral is reset at each switching. But since the implemented controllers have a part of it’s control signal as a direct response to absolute position resetting the error integral to zero is not desired. Instead the error integral is set so the control signal from absolute position is perfectly counteracted at the moment the switching occurs. 18 4 Results Using the test rig the real system performance and robustness can be tested for a small set of feasible loads. The dynamical controller of this thesis is compared in all cases with the previously existing static cascaded system. Two different test cases are tested with different supply voltages and loads. The test cases are selected to mimic two realistic applications. One step at a time and then holding position steady for a long time, like opening or closing a valve on an operator command. The other case is randomly changing desired position so often that the system cannot track perfectly, corresponding to when the servo is controlled by some sort of external controller. In some sense testing both human timescale and computer timescale responses. Two different load cases are tested, no load at all on the output shaft and a small inertia. Two realistic load cases that the system can move at it’s physical limit. The maximum inertia used in the controller generation cannot be tested since the output shaft mechanically brakes down before reaching maximum acceleration/deceleration. Each load and test case is then tested with both 12 V and 24 V supply voltage to see the system behaviour when the amount of control signal saturation increases. As a final test the disturbance rejection is tested, to see if the dynamical controller remove the steady state error. 4.1 Step response A reference step of 1 rad is applied to the system. In the case of the new controller a maximum acceleration and velocity needs to be specified as well, these are specified to around the maximum of what the system can handled physically, approximately 25 rad/s and 1200 rad/s2. With no external load and 12 V supply (figure 4.1) the switch from the aggressive controller to the very robust and slow controller can clearly be seen when the re- sponse get close to the final value. With the small inertia (figure 4.2) some small oscillations occur close to the final value. In both cases with 12 V supply (figure 4.1 and 4.2) it is observed that the maximum velocity of the response does not make it possible for the system to reach the velocity of the reference. This is assumed to be because the input voltage restricts the maximum velocity since the same behaviour is not observed with a supply voltage of 24 V , figure 4.3 and 4.4. With higher input voltage the maximum velocity the system can reach increases and some small overshoot occur before the very robust and slower controller take over. 19 4. Results 6.9 7 7.1 7.2 7.3 7.4 7.5 Time [s] 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 A n g le [ ra d ] No Inertia 12V Step reference Existing response H reference H response Figure 4.1: Step response with no external load and low supply voltage. 6.9 7 7.1 7.2 7.3 7.4 7.5 Time [s] 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 A n g le [ ra d ] Small Inertia 12V Step reference Existing response H reference H response Figure 4.2: Step response with small inertial external load and low supply voltage. 20 4. Results 6.9 7 7.1 7.2 7.3 7.4 7.5 Time [s] 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 A n g le [ ra d ] No Inertia 24V Step reference Existing response H reference H response Figure 4.3: Step response with no external load and high supply voltage. 6.9 7 7.1 7.2 7.3 7.4 7.5 Time [s] 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 A n g le [ ra d ] Small Inertia 24V Step reference Existing response H reference H response Figure 4.4: Step response with small inertial external load and high supply voltage. 21 4. Results 4.2 Quick random reference changes This test case shows that the dynamic controller struggles to converge to its final value in the same time the static existing controller does. However it can clearly be seen that the static controller response suffers from a large steady state error that vary in size at each position. Observing the the two smallest step changes that occur during the sequence, at time 16.68 s and 17.85 s an interesting effect can be seen. The previously existing solution does not respond at all to the small reference change at 24 V supply (figure 4.7 and 4.8). Only in the two cases with the 12 V supply (figure 4.5 and 4.6) a very small response to the reference change at 17.68 s can be seen. 17.4 17.5 17.6 17.7 17.8 17.9 18 Time [s] 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 A n g le [ ra d ] No Inertia 12V Step reference Existing response H reference H response Figure 4.5: Multiple quick reference changes with no external load and low supply voltage. 22 4. Results 17.4 17.5 17.6 17.7 17.8 17.9 18 Time [s] 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 A n g le [ ra d ] Small Inertia 12V Step reference Existing response H reference H response Figure 4.6: Multiple quick reference changes with small inertial external load and low supply voltage. 17.4 17.5 17.6 17.7 17.8 17.9 18 Time [s] 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 A n g le [ ra d ] No Inertia 24V Step reference Existing response H reference H response Figure 4.7: Multiple quick reference changes no inertial external load and high supply voltage. 23 4. Results 17.4 17.5 17.6 17.7 17.8 17.9 18 Time [s] 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 A n g le [ ra d ] Small Inertia 24V Step reference Existing response H reference H response Figure 4.8: Multiple quick reference changes with small inertial external load and high supply voltage. 4.3 External disturbance To apply an external disturbance that would be consistent in magnitude a 1 kg weight lifting weight was hung by a string around the small inertial load. With a radius of 36 mm this correspond to an externally applied torque of approximately 0.35 Nm. An interesting result is observed with a larger steady state error for the higher supply voltage (figure 4.10) then for the lower supply voltage (figure 4.9). Graphically observing approximately twice as steady state error for the twice as large supply voltage (12 V vs 24 V ). A possible explanation is that the hardware and low level control software will give discrete steps in duty cycle and therefore is the minimum driver motor voltage a constant fraction of the input voltage. 24 4. Results 3.8 4 4.2 4.4 4.6 4.8 5 Time [s] 1.5 1.55 1.6 1.65 A n g le [ ra d ] Disturbance 12V Step reference Existing response H reference H response Figure 4.9: Constant reference and application of external disturbance torque with low supply voltage. 4 4.1 4.2 4.3 4.4 4.5 4.6 4.7 4.8 Time [s] 1.5 1.55 1.6 1.65 A n g le [ ra d ] Disturbance 24V Step reference Existing response H reference H response Figure 4.10: Constant reference and application of external disturbance torque with high supply voltage. 25 4. Results 26 5 Conclusion The fundamentally impossible task of controlling all possible load with perfect dis- turbance rejection have not been solved as expected. However the system performs well with some of the loads selected to be representative and the maximum load the system was assumed to be useful with was beyond the mechanical capabilities of the system rather the control system. Comparing the previous existing static controller with the dynamic developed in this thesis it have both benefits as well as drawbacks depending on the application. 5.1 Implemented solution The dynamic PIDf solution solves the control problem for the tested subset of fea- sible loads and performs similar for different loads even if the combined load and motor model have very large uncertainties. Especially the large uncertainty for the steady state gain does not result in unstable behaviour. But it could be the biggest performance limiting factor. What happens if the load have large phase lags for some frequencies is not known since that kind of behaviour is not included in the set of loads. The discretization can also give very small stability margins since the sam- ple frequency is limited by the operating system at the moment at not by designer choice. The implemented solution is used in real world application after the project finished and does what it is supposed to do in those applications known when this project ends. 5.2 Further improvements A more sophisticated method to handle the backlash in the gearbox would be a huge improvement. Since the current commutation step of the inner motor and the outer position is known it would in principle be possible to measure the current state of the backlash. Rather then the crude switching between the two parameter sets depending a guessed system state (not including measured backlash state). A large limitation have been the requirement on a non-adapting controller. This have also limited the possibility to schedule the controller with the load. Simply because estimating the load with the noisy measurements and the limited processing power would require a slow (compared to system bandwidth) adaptation to the load. By easing on the non-adaptive requirement a more robust and higher performing controller would probably be possible. Expanding the set of feasible loads with more diverse load behaviours (especially 27 5. Conclusion with high phase lag) until the purposed solution becomes unstable. To investigate if more complex control structures such as multiple cascaded PID controllers designed with H∞ can regain the system stability and performance. Therefore resulting in an even more robust servo motor system. 28 Bibliography [1] R. Bruns, J. Diepstraten, X. Schuurbiers, and J. Wouters, Motion control of systems with backlash, ser. DCT rapporten. Technische Universiteit Eindhoven, 2006, dCT 2006.075. [2] L. V. B. Siciliano, L. Sciavicco and G. Oriolo., Robotics: Modelling, Planning and Control. Springer, 2010. [3] B. Lennartson, Reglerteknikens grunder, 4th ed. Studentlitteratur AB, 2002. [4] J. Öhr, Anti-windup and control of systems with multiple input saturations : tools, solutions and case studies. Uppsala: Signals and systems [Signaler och system], Univ.-bibl. [distributör], 2003, diss. Uppsala : Univ., 2003. [5] K. Zhou, J. Doyle, and K. Glover, Robust and Optimal Control, ser. Feher/Pren- tice Hall Digital and. Prentice Hall, 1996. [6] P. Apkarian, D. Noll, and P. Pellanda, Nonsmooth H Synthesis, 05 2005, vol. 51. 29 List of Figures Introduction Background Previously existing solution Scope of this thesis Limitations Theory Models BLDC motor Load Gearbox, with backlash Combined load and motor model Sensors and signal processing Output shaft position sensor Inner position for velocity estimation Discrete time low pass filter Controller algorithm Trajectory generator, acceleration and velocity limits 2 DOF PIDf controller Robust H norm controller Generalised performance and robustness H norm Optimisation problem for controller generation Implementation Test rig Models, simplifications and parameter estimations Current feed forward Parameter estimation Motor parameters Combined load and motor parameters Controller generation Controller implementation Discretization of controller and filter Integral anti-windup Controller switching Bumb-less transfer Results Step response Quick random reference changes External disturbance Conclusion Implemented solution Further improvements