Academic Company Events NI Developer Zone Support Solutions Products & Services Contact NI MyNI

Document Type: Tutorial
NI Supported: Yes
Publish Date: Sep 1, 2008

Frequency Design Method for Motor Position Control

0 ratings | 0.00 out of 5
Print | PDF

Overview

This tutorial shows how to use the frequency response design method for DC motor position control. This tutorial uses LabVIEW 8.2 with LabVIEW Control Design Toolkit.

These tutorials are based on the Control Tutorials developed by Professor Dawn Tilbury of the Mechanical Engineering department at the University of Michigan and Professor Bill Messner of the Department of Mechanical Engineering at Carnegie Mellon University and were developed with their permission.



 Motor Position Root Locus


Controls Tutorials Menu


Motor Position State Space


From the main problem, the dynamic equations in transfer function form are the following:


and the system schematic looks like:

For the original problem setup and the derivation of the above equations, please refer to the Modeling DC Motor Position page.

With a 1 rad/sec step reference, the design criteria are:

  • Settling time less than 0.04 seconds
  • Overshoot less than 16%
  • No steady-state error to a reference
  • No steady-state error due to a disturbance

Drawing the Original Bode Plot

The main idea of frequency-based design is to use the Bode plot of the open-loop transfer function to estimate the closed-loop response. Adding a controller to the system changes the open-loop Bode plot, therefore changing the closed-loop response. Let's first draw the Bode plot for the original open-loop transfer function.

LabVIEW Graphical Approach

Using the approach that was introduced in the Frequency Response Tutorial, create a transfer function for the system and output the resulting bode plot.


Figure 1: Open-Loop Transfer Function - Block Diagram (Download)

 


Figure 2: Open-Loop Transfer Function - Front Panel (Download)

LabVIEW MathScript Approach

Alternatively, you can achieve the same results using a MathScript approach. Open the MathScript Window (Tools >> MathScript Window) and click on the Script tab to view the Script Editor. Type the following commands in the Script Editor:

J = 3.2284E-6;

b = 3.5077E-6;

K = 0.0274;

R = 4;

L = 2.75E-6;

num = K;

den = [(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0];

motor = tf(num,den);

The main idea of frequency-based design is to use the Bode plot of the open-loop transfer function to estimate the closed-loop response. Adding a controller to the system changes the open-loop Bode plot, therefore changing the closed-loop response.

Let's first draw the Bode plot for the original open-loop transfer function. Add the following code to the end of your code, and then run the script.

w=logspace(0,4,101);

bode(motor,w)

Result

Either approach should result in the following Bode plot:


Figure 3: Original Open-Loop Transfer Function

Adding an Integrator

Now lets add an integrator for zero steady-state error in response to a step disturbance.

LabVIEW Graphical Approach

Create a second transfer function model to represent the controller. Place the controller model in series with the plant model, and draw the bode plot from the combined system.


Figure 4: Adding an Integrator - Block Diagram (Download)

 


Figure 5: Adding an Integrator - Front Panel (Download)

LabVIEW MathScript Approach

If you are using the MathScript approach, add the following lines to your existing code:

numi = 1;

deni = [1 0];

contr = tf(numi,deni);

bode(contr*motor,w)

Result

Either approach should result in the following plot:


Figure 6: System with Integrator for Zero Steady-State Error

Gain and Phase Margin Specifications and Controller Design

From the Bode phase plot we can see that there is a pole near 60 rad/sec. We will use a PI controller to put a zero at s=60 to flatten out the phase curve.

LabVIEW Graphical Approach

Using the previous VI, modify the controller so that the controller transfer function is (s+60)/s.

LabVIEW MathScript Approach

If you are using the MathScript approach, add the following lines to your script:

numpi = [1 60];

denpi = [1 0];

contr = tf(numpi,denpi);

bode(contr*motor,w)

Result

Either approach should result in the following plot:


Figure 7: System with PI Controller

We want less than a 16% overshoot, so let's compute the damping ratio based on a 16% overshoot. Also the corresponding phase margin is 100 times the damping ratio. From the settling time requirement, we are able to compute the desired bandwidth frequency.

We want to have at least 50 degrees of phase margin, therefore the gain should fall between -6 and -7.5 dB at some frequency after 250 rad/sec. From the Bode plot we see that we must add about 80 degrees of phase and 60 dB of gain at a frequency of 250 rad/sec. The gain plot will then lie between -6 and -7.5 dB and after 244 rad/sec. 

From the previous bode plot, we can see that we need 50 more degrees of phase at a frequency of 250 rad/sec. Lets now try a lead compensator to add exactly 50 degrees of phase.

LabVIEW Graphical Approach

Using the previous VI, insert a CD Series VI into the block diagram, between the existing CD Series VI and the CD Bode VI. Create a MathScript node, create a transfer function output called 'contr2', and paste the following code into the node:

zeta = -log(.16)/sqrt(pi^2+(log(.16))^2);

PM = 100*zeta;

wbw = (4/(0.04*zeta))*sqrt((1-2*zeta^2)+sqrt(4*zeta^4-4*zeta^2+2));

 

a = (1 - sin(PM*pi/180))/(1 + sin(PM*pi/180));

T = 1/(wbw*sqrt(a));

contr2 = tf([T 1],[a*T 1]);

Your block diagram should look like this:



Figure 8: Gain and Phase Margin Compensator - Block Diagram (Download)

LabVIEW MathScript Approach

If you are using the MathScript approach, add the following lines to your existing code:

zeta = -log(.16)/sqrt(pi^2+(log(.16))^2);

PM = 100*zeta;

wbw = (4/(0.04*zeta))*sqrt((1-2*zeta^2)+sqrt(4*zeta^4-4*zeta^2+2));

Next, add the following lines to the end of your script:

a = (1 - sin(PM*pi/180))/(1 + sin(PM*pi/180));

T = 1/(wbw*sqrt(a));

contr2 = tf([T 1],[a*T 1]);

w = logspace(2,3,101);

bode(contr*contr2*motor,w)

Result

Either approach should result in the following plot:


Figure 9: System with Lead Compensator

This new Bode plot now shows that the phase margin is about right at 250 rad/sec, but the gain is too small by about 20 dB. The gain crossover must occur at 240 rad/sec. 

To bring the gain up by 20 dB we will multiply by a gain of 10.

LabVIEW Graphical Approach

Add an additional transfer function model and put it in series with the previous controller. Create a numeric constant for the numerator, and set its value to 10.


Figure 10: System With Gain of 10 - Block Diagram (Download)

LabVIEW MathScript Approach

Add the following lines to the end of your script:

Kp = 10;

bode(Kp*contr*contr2*motor,w)

Result

With either approach, you should get the following plot:


Figure 11: System with Gain of 10

Let's now check the step response of the closed loop system.

LabVIEW Graphical Approach

Place a CD Feedback VI on the block diagram, and create a new transfer function with a numerator of 1 (as we did in the tutorial). This Model 1 input for the feedback VI should come from the output of the previous CD Series VI, and the Model 2 input should come from the new transfer function model.

Place a CD Step Response VI on the block diagram, and use the output from the feedback VI as the Step Response input. On the front panel, set the time constraints so that t0 = 0, dt = 0.001, and tf = 0.1.


Figure 12: Block Diagram for Step Response of System

LabVIEW MathScript Approach

Type the following code in the Command Window:

sys_cl = feedback(Kp*contr*contr2*motor,1);

t = 0:0.001:0.1;

step(sys_cl,t)

Result

With either approach, you should get the following plot:


Figure 13: Step Response of the Closed-Loop System

The overshoot is now too large, however the settling time is better than expected. So let's try another design where the phase margin is larger, say around 70 degrees.

LabVIEW Graphical Approach

On the block diagram, change the value of PM in the MathScript Node. Replace the second line of code with:

PM = 70;

LabVIEW MathScript Approach

Add the following lines to the end of your script:

PM = 70;

a = (1 - sin(PM*pi/180))/(1 + sin(PM*pi/180));

T = 1/(wbw*sqrt(a));

contr2 = tf([T 1],[a*T 1]);

w = logspace(2,3,101);

bode(contr*contr2*motor,w)

Result

With either approach, you should get the following plot:


Figure 14: System with Phase Margin of 70 Degrees

This new bode plot shows that the phase margin is good at around 250 rad/sec, but the gain is too small by about 14 dB. The gain crossover must occur at 240 rad/sec. To bring the gain up we will multiply by a gain of 5.

LabVIEW Graphical Approach

On the block diagram, find the numeric constant for the numerator of the gain model, which was set to 10. Right-click the constant and change it to a control.

On the front panel, change the control to a vertical slider by right-clicking the control and selecting 'Replace'.

Run the VI, and change the value from 10 to 5.

LabVIEW MathScript Approach

Add the following lines to the end of your script:

Kp=5;

bode(Kp*contr*contr2*motor,w)

Result

With either approach, you should get the following plot:


Figure 15: System with Gain of 5

Now let's check the step response again.

LabVIEW Graphical Approach

The resulting step response should appear on your front panel as you change the gain.

LabVIEW MathScript Approach

If you are using the MathScript approach, type the following code in the Command Window:

sys_cl = feedback(Kp*contr*contr2*motor,1);

t = 0:0.001:0.1;

step(sys_cl)

Result

With either approach, you should get the following step response::


Figure 16: Step Response of Closed-Loop System

From the step response we now see that the overshoot is fine, but the settling time is too long. Let's try a slightly higher bandwidth.

LabVIEW Graphical Approach

In the MathScript Node on the block diagram, insert the following just above the last line of code:

wbw = 300;

a = (1 - sin(PM*pi/180))/(1 + sin(PM*pi/180));

T = 1/(wbw*sqrt(a));

LabVIEW MathScript Approach

Add the following lines to the end of your script:

wbw = 300;

a = (1 - sin(PM*pi/180))/(1 + sin(PM*pi/180));

T = 1/(wbw*sqrt(a));

contr2 = tf([T 1],[a*T 1]);

w = logspace(2,3,101);

bode(contr*contr2*motor,w)

Result

With either approach, you should get the following plot:


Figure 17: System with Higher Bandwidth

This new bode plot shows that the phase margin is about right at a frequency of 250 rad/sec, but the gain is too small by about 18 dB. The gain crossover must occur at 240 rad/sec. To bring the gain up we will multiply by a gain of 8.

LabVIEW Graphical Approach

Change the gain to 8 using the front panel slider.

LabVIEW MathScript Approach

Add the following lines to the end of your script:

Kp = 8;

bode(Kp*contr*contr2*motor,w);

Result

With either approach, you should get the following plot:


Figure 18: System with Gain of 8

Now let's check the step response of the closed loop system.

LabVIEW Graphical Approach

The resulting step response should appear on your front panel as you change the gain.

LabVIEW MathScript Approach

Type the following code in the Command Window:

sys_cl = feedback(Kp*contr*contr2*motor,1);

t = 0:0.001:0.1;

step(sys_cl)

Result

With either approach, you should get the following step response:


Figure 19: Final Step Response of Closed-Loop System

Now everything looks good. We have less than 16% overshoot and a settling time of about 40 milliseconds.

Final LabVIEW VI

The final VI block diagram should look like this:


Figure 20: Final Block Diagram (Download)

Final MathScript Code

The MathScript code below is the simplified version of what was done above. After you run this script, you will get the last two plots shown above.

J = 3.2284E-6;

b = 3.5077E-6;

K = 0.0274;

R = 4;

L = 2.75E-6;

 

num = K;

den = [(J*L) ((J*R)+(L*b)) ((b*R)+K^2) 0];

motor = tf(num,den);

 

PM = 70;

wbw = 300;

 

a = (1-sin(PM*pi/180))/(1+sin(PM*pi/180));

T = 1/(wbw*sqrt(a));

numpi = [1 60];

denpi = [1 0];

contr = tf(numpi,denpi);

contr2 = tf([T 1],[a*T 1]);

 

Kp = 8;

w = logspace(2,3,101);

bode(Kp*contr*contr2*motor,w)

 

sys_cl = feedback(Kp*contr*contr2*motor,1);

t = 0:0.001:0.1;

step(sys_cl)



 Motor Position Root Locus


Controls Tutorials Menu


Motor Position State Space


 

Reader Comments | Submit a comment »

 

Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).