Application Center - Maplesoft

App Preview:

DC Motor Control Design

You can switch back to the summary page by clicking here.

Learn about Maple
Download Application


 

Image 

DC Motor Control Design  

? Maplesoft, a division of Waterloo Maple Inc., 2008 

Given a model of a DC motor as a set of differential equations, we want to obtain both the transfer function and the state space model of the system. Then, we want to use the state space model to design a LQR controller and study the effect the R parameter in the LQR control design has on the controlled performance of the system. 

System Definition 

 

 

 

System Models 

 

 

 

 


LQR Control Design 

 

 

 

Image 

A DC motor converts electrical signals (voltage and current) into mechanical motion. The electrical and mechanical characteristics can be illustrated by a circuit diagram and a free body diagram respectively (shown in the diagram above). 

System Definition 

Define the Variables and the Parameters that describe the system. 

Parameters 

Name 

Value 

Units 

Parameters 

Moment of inertia of the motor (J) 

Embedded component 

Unit(`*`('kg', `*`(`^`('m', 2)))) 

Damping of the mechanical system (b) 

Embedded component 

Unit(`*`('N', `*`('m', `*`('s')))) 

Electromotive force constant (K) 

Embedded component 

Unit(`/`(`*`('N', `*`('m')), `*`('A'))) 

Motor coil resistance (R) 

Embedded component 

Unit('Omega') 

Motor coil inductance (L) 

Embedded component 

Unit('H') 

Button# Retrieve Parameters Defined

{J = 0.1e-1, K = 0.1e-1, L = .5, R = 1, b = .1}

Variables 

Name 

Description 

Input Variables 

V(t) 

Applied Voltage 

Output Variables 

Theta(t) 

Motor Shaft Angular Position 

i(t) 

Motor Current 

System Models 

Differential Equation Model 

 

To derive the model of the system, first, we apply Kirchhoff's voltage law around the circuit. The back EMF is proportional to the angular velocity of the motor shaft. Using the DynamicSystems[DiffEquation] command we get: 

 

`:=`(sysElectrical, DynamicSystems[DiffEquation]([`+`(`*`(L, `*`((D(i))(t))), `*`(R, `*`(i(t)))) = `+`(V(t), `-`(`*`(K, `*`((D(theta))(t)))))], [V(t)], [theta(t)])); -1; DynamicSystems[PrintSystem](sy...
`:=`(sysElectrical, DynamicSystems[DiffEquation]([`+`(`*`(L, `*`((D(i))(t))), `*`(R, `*`(i(t)))) = `+`(V(t), `-`(`*`(K, `*`((D(theta))(t)))))], [V(t)], [theta(t)])); -1; DynamicSystems[PrintSystem](sy...
`:=`(sysElectrical, DynamicSystems[DiffEquation]([`+`(`*`(L, `*`((D(i))(t))), `*`(R, `*`(i(t)))) = `+`(V(t), `-`(`*`(K, `*`((D(theta))(t)))))], [V(t)], [theta(t)])); -1; DynamicSystems[PrintSystem](sy...
 

(2.1.1)
 

 

Second, we model the mechanical component of the motor as a second order differential system with moment of inertia J and damping ratio of b. The torque is proportional to the current i(t) driving the motor. 

`:=`(sysMechanical, DynamicSystems[DiffEquation]([`+`(`*`(J, `*`(((`@@`(D, 2))(theta))(t))), `*`(b, `*`((D(theta))(t)))) = `*`(K, `*`(i(t)))], [i(t)], [theta(t)])); -1; DynamicSystems[PrintSystem](sys...
`:=`(sysMechanical, DynamicSystems[DiffEquation]([`+`(`*`(J, `*`(((`@@`(D, 2))(theta))(t))), `*`(b, `*`((D(theta))(t)))) = `*`(K, `*`(i(t)))], [i(t)], [theta(t)])); -1; DynamicSystems[PrintSystem](sys...
 

(2.1.2)
 

 

The overall differential equation model in terms of the voltage, V(t), and angular position, Theta(t), is:  

 

 

`:=`(sysOverall, DynamicSystems[DiffEquation]([`+`(`*`(L, `*`((D(i))(t))), `*`(R, `*`(i(t)))) = `+`(V(t), `-`(`*`(K, `*`((D(theta))(t))))), `+`(`*`(J, `*`(((`@@`(D, 2))(theta))(t))), `*`(b, `*`((D(the...
`:=`(sysOverall, DynamicSystems[DiffEquation]([`+`(`*`(L, `*`((D(i))(t))), `*`(R, `*`(i(t)))) = `+`(V(t), `-`(`*`(K, `*`((D(theta))(t))))), `+`(`*`(J, `*`(((`@@`(D, 2))(theta))(t))), `*`(b, `*`((D(the...
`:=`(sysOverall, DynamicSystems[DiffEquation]([`+`(`*`(L, `*`((D(i))(t))), `*`(R, `*`(i(t)))) = `+`(V(t), `-`(`*`(K, `*`((D(theta))(t))))), `+`(`*`(J, `*`(((`@@`(D, 2))(theta))(t))), `*`(b, `*`((D(the...
 

(2.1.3)
 

 

Transfer Function Model 


To obtain the transfer function model of our system, we convert the overall differential equation model
( into a transfer function model using DynamicSystems[TransferFunction] command.  TFopen is the open loop transfer function for the angular position Theta(t) from the input V(t) and is defined as:
 

`:=`(TFopen, DynamicSystems[TransferFunction](sysOverall)); -1; DynamicSystems[PrintSystem](TFopen)
`:=`(TFopen, DynamicSystems[TransferFunction](sysOverall)); -1; DynamicSystems[PrintSystem](TFopen)
 

(2.2.1)
 

 

State Space Model 

 

The state space model of a system is defined as follows:  

 

diff(x(t), t) = `+`(Typesetting:-delayDotProduct(A, x(t), true), Typesetting:-delayDotProduct(B, u(t), true)) 

y(t) = `+`(`*`(C, `*`(x(t))), `*`(D, `*`(u(t)))) 

 


 

 

 

 

Name 

Description 

u(t) 

System input signal, p ? 1 vector 

y(t) 

System output signal, m ? 1 vector 

x(t) 

System state vector, n ? 1 vector 

A 

System matrix, n ? n matrix 

B 

Input matrix, n ? p matrix 

C 

Output Matrix, m ? n matrix 

D 

Direct through matrix, m ? p matrix 

 

For the case of the DC motor, the states x1(t), x2(t) and x3(t) represent current, i(t), angular position, Theta(t), and angular velocity, (D(Theta))(t), respectively. 

 

To obtain the state space model of our system, we convert the overall differential equation model ( into a state space model using DynamicSystems[StateSpace] command.   

 

`:=`(SSopen, DynamicSystems[StateSpace](sysOverall)); -1; DynamicSystems[PrintSystem](SSopen) 

(2.3.1)
 

 

Model Analysis 


The DynamicSystems[ResponsePlot]command can be used to plot the angular position Theta(t)with parameter set, params, initial conditions, and input voltage signal, defined below:
 

 

params 

{J = 0.1e-1, K = 0.1e-1, L = .5, R = 1, b = .1} (2.4.1)
 

`:=`(ic, [theta(0) = 0, (D(theta))(0) = 0, i(0) = 0]) 

[theta(0) = 0, (D(theta))(0) = 0, i(0) = 0] (2.4.2)
 

 

 

DynamicSystems[ResponsePlot](TFopen, Heaviside(t), output = theta(t), initialconditions = ic, parameters = params, duration = 3, thickness = 2, gridlines = true, title =
DynamicSystems[ResponsePlot](TFopen, Heaviside(t), output = theta(t), initialconditions = ic, parameters = params, duration = 3, thickness = 2, gridlines = true, title =
DynamicSystems[ResponsePlot](TFopen, Heaviside(t), output = theta(t), initialconditions = ic, parameters = params, duration = 3, thickness = 2, gridlines = true, title =
DynamicSystems[ResponsePlot](TFopen, Heaviside(t), output = theta(t), initialconditions = ic, parameters = params, duration = 3, thickness = 2, gridlines = true, title =
 

Plot_2d
 

 

The system can also be analyzed in the frequency domain. Substituting the parameter values into the open loop transfer function in results in: 

eval(TFopen:-tf, params) 

Matrix(%id = 64873468) (2.4.3)
 

 

The above transfer function can be plotted as a magnitude plot and a phase plot. 

DynamicSystems[BodePlot](TFopen, parameters = params, hertz = true, thickness = 2, labelfont = [HELVETICA, 10], font = [HELVETICA, 10])
DynamicSystems[BodePlot](TFopen, parameters = params, hertz = true, thickness = 2, labelfont = [HELVETICA, 10], font = [HELVETICA, 10])

Plot_2d Plot_2d

 

LQR Control Design 

Step Responses 

 

Button# LQR procedure 

Drawing-Canvas 

Our objective is to be able to rotate the shaft position, Theta(t), of the motor to specified desired positions.  In control terms, this translates to minimizing the motor shaft position error. As such, we put higher weighting on the position state, x2(t), in the Q matrix in our LQR controller design. 

`:=`(A, eval(SSopen:-a, params)); 1; `:=`(B, eval(SSopen:-b, params)); 1 

 

Matrix(%id = 69276456)
Matrix(%id = 65478320) (3.1.1)
 

Qlqr 

Matrix(%id = 65233480) (3.1.2)
 

 

The controller gain for the full state feedback LQR controller is then computed using the custom procedure LQR( ). With the Q matrix defined in Matrix(%id = 65233480)and Rlqr = .1the result is the gain vector Kss given by:
 

`:=`(Kss, LQR(A, B, Qlqr, Rlqr)) 

Matrix(%id = 70010912) (3.1.3)
 

 

The numeric solution can now be obtained for the step response of the open loop (uncontrolled) and closed loop (controlled) cases.
 

Button#Define Open loop and Closed l 

Open loop (uncontrolled) response 

Closed loop (controlled) response 

Input functions used examine the open loop and closed loop response are defined as:  


InputSig; 1
 

Plot_2d Plot_2d

 

Determine the open loop Differential Equation Model in terms of the State Space variables x1(t), x2(t) and x3(t).

DynamicSystems[PrintSystem](DEopen)
 


(3.1.4)
 

(3.1.5)
 

The open loop response is defined as:  

 

DynamicSystems[PrintSystem](sysOpenLoop) 


(3.1.6)
 

The closed loop response is defined as:
 

DynamicSystems[PrintSystem](sysClosedLoop) 


(3.1.7)
 

The plot of the open loop state response is:
 

StatePlot1 

Plot_2d
 

 

The plot of the closed loop state response is:
 

StatePlot2 

Plot_2d
 

 

The plot of the open loop state response is:
 

OutputPlot1 

Plot_2d
 

 

The plot of the closed loop angular position Theta(t) step response is:
 

OutputPlot2 

Plot_2d
 

 

 

In the controlled case, the shaft position of the DC motor follows the step change in the desired position (defined by the step input) and settles into the desired steady state value as expected. 

How varying R affects the System Response 

We want to vary the weighting factor R for the LQR controller to see how it affects the system output response. 

 

The R factor is the weighting coefficient for the input signal. By increasing R, we are putting more penalty on the control signal.   

As such, the resulting controller will try to minimize the control efforts used to achieve the desired output. 

 

Consider the results obtained earlier for R = 0.1. 

 

 

Button#Define Step response and Cont 

Step response 

Control Effort 

First, recall the system step response output for the case R=0.1 developed previously. This will serve as our benchmark for comparison. 

For comparison, we define an energy-like quantity (square of the input voltage) to give us an idea of the cost or the control effort required in operating the DC motor. Here, we show the control effort over time for the case R = 0.1. 

 

StepResponse 

Plot_2d
 

 

EffortPlot 

Plot_2d
 

 

 

Next, we generate the controller and the corresponding step time response for each value of R from 0.1 to 2. To compare the performance of each of the controllers, we define the control effort of the controller as the square of the input signal, summed over time. This associated control effort (or energy-like) value for each controller is the total cost in operating the individual controllers. 

 

The following plot illustrates the total cost (integral of the energy like control function) for different values of R.  

 

Button# Procedure to calculate total 

 

TotalCostPlot 

Plot_2d
 

To see the effect of varying R, you can drag the slider to select different values of R and observe the resulting step response and the control effort. 

 

Button# Procedure controlling slider 

 

Max R 

Embedded component 

Min R 

        R =0.59 

 

Embedded component 

    Embedded component