You are on page 1of 12

 

   

University at Buffalo 

Motor Position 
Control Lab 
MAE543 Continuous Control

Diing‐wen Peng 
12/5/2009 
 
Table of Contents 
Introduction .................................................................................................................................................. 3 
Procedure ...................................................................................................................................................... 3 
Derivations .................................................................................................................................................... 3 
Controller Design .......................................................................................................................................... 5 
Design Implementation................................................................................................................................. 7 
Signal Generator ....................................................................................................................................... 8 
Numerical Integrator ................................................................................................................................ 8 
Motor Simulation ...................................................................................................................................... 8 
Motor Control ........................................................................................................................................... 9 
Discussion of Results ................................................................................................................................... 11 
Conclusion ................................................................................................................................................... 12 
References .................................................................................................................................................. 12 
 

   
Introduction 
The objective of this experiment is to build a motor model using LabVIEW (VI files) for the purpose of 
simulation, implement a PD controller based on a set of given design criterion, and finally, test and 
evaluate the controller implementation using the physical model. 

Procedure 
The step by step procedure to achieve the objectives of this lab can be summed up below, 

1. Development of the mathematical model (see section on derivations) 
2. Create the LabVIEW models, including 
a. A signal generator (sub‐VI) that outputs a custom sine, triangle or square wave 
b. A numerical integrator (sub‐VI) that determines the angular position and velocity by 
calculating and integrating the angular acceleration. 
c. A main VI that allows the control of system parameters and signal type, supplied data 
acquisition sub‐VIs are also implemented to send the open loop signal to the motor. 
3. Determine the proportional and derivative gain that satisfy the design requirements, including 
a. Zero steady state error 
b. 5% 
c. 0.1   
4. Implement the controller by modifying the main VI  
5. Using the supplied data acquisition sub‐VIs to send the controlled signal to the actual motor and 
plot the encoder readings. 

See the subsequent sections for further details. 

Derivations 
The schematics for the electric motor is given as below, 

Figure 1. Electric Motor Schematics 

The mechanical torque on the shaft is proportional to the current   passing through the system, 
 
Where   is the motor efficiency and   is the motor‐torque constant that represents the lumped 
electrical terms. The back‐emf is produced as the armature rotates in the magnetic field, resulting in the 
following relationship, 
 
Where   is the back‐emf constant and   is the motor shaft velocity. Using Kirchoff’s voltage law, 
which states that the voltage drop across a close circuit must be zero, the following equation is obtained 


Since  100   (The small value can also be deducted from the relative small size of the stator.), 
and  1 amp/s. The values of   and   are easily orders of magnitude greater than 
. Now disregard the motor inductance and a simplified equation for   can be obtained, 

Using Newton’s 2nd Law of motion, the mechanical aspect of the motor can be modeled as 

Where   is the motor moment of inertia,   is the efficiency of the gearbox,   is the gear ratio, and 


 is the torque generated by the motor,   is the toque applied by the load.  

Now Newton’s 2nd law at the load of the motor becomes, 

 
Where   is the load angular velocity,   is the load shaft moment of inertia, and   is the viscous 
damping term at the output. Combining the previous two equations,  

Note that   and   , the above equation can be rewritten as 

Differentiate   to obtain   and plug in the equation for  ,the equation above becomes 

Take the Laplace transform and rearrange the terms, the desired transfer function becomes 

 
Where  0.0052,  0.1894,  0, and  
0.333. The parameters used are listed in the table below, 

Table 1. Motor Parameters 

Controller Design 
The design specifications for this system are 

• Zero steady state error 
• 5% 
• 0.1   

The form of transfer function for the system as derived in the previous section is, 

With  0, this becomes a type 1 system, and will have zero steady state error for a step input, thus 
no additional integrator is needed. 

A PD controller of the form   will be used to obtain desired transient response for the 
system. 

The closed loop transfer function becomes 

 
1

To approximate the 2nd order system response, disregard the additional zero in the numerator and 
assume the following form for the denominator, 

2  
Using the design criterions, the damping ratio   and natural frequency   can be calculated as 

0.05  

0.1  
1

Take the natural log of each side for   and solve for  , obtaining  0.698. Plug this value into the 


equation for   to obtain  43.8. 

Compare the 2nd order response with the closed loop transfer function, values for   and   are 


obtained, 

29.96 
2
0.389 

Note that these values are only approximations of the transient behavior, the additional zero is likely to 
decrease the rise time but also increase the overshoot in the process. 

In order to satisfy requirements for the actual system, the controller gains must be tuned. The following 
diagram can be sketched to give an idea of required location of the poles. 

 
0.698  Im

1  
0.1

Re

Figure 2. Design Requirements 

The controlled system is simulated using Simulink with the following block diagram, and the unit step 
response is plotted, 
Simulink Model

29.96
0.333
Kp
0.0052s2 +0.1894s
Step Scope
0.386 du/dt Theta_L(s) / V_m(s)

Kd Derivative

,
Simulation: Closed Loop Response to Unit Step Input with Kp=29.96, Kd=0.386
1.4

1.2

1
Angular Position (rad)

0.8

0.6

0.4

0.2

0
0 0.05 0.1 0.15 0.2 0.25 0.3 0.35
Time (s)
 

Figure 3 and 4. Simulink Block Diagram and Simulation Results 

Upon closer inspection of the simulation,  4% and  0.1   , which satisfies the design 


specifications. However, further tuning may still be required in the actual system. 

Design Implementation 
Even though the design was done in the continuous time domain, the implementation using LabVIEW 
and its associated hardware requires the use of D/A and A/D converters to drive the system and obtain 
the encoder readings, therefore discrete time effects must be taken into consideration. The Nyquist 
frequency, stability of the numerical algorithm (for the integrator), saturation of the control signal, and 
the quantization of encoder readings will have to be carefully evaluated. 
Signal Generator 

Figure 5. The signal generator is a 
simple sub VI that takes the signal 
type(sine, triangle, and square) and 
parameters (amplitude, frequency, 
time) as input and output the signal 
  value. 

Numerical Integrator 
The numerical integrator is implemented using the backward Euler method, where 

1 1 Δ  

Where   denotes the current step. The backward Euler method is used instead of Euler method (Where 
 replaces  1 ) to eliminate the effect of the time step size. If   is used, Δ  must be less 
than 2/ , where   is the largest eigenvalue of the system, to maintain the numerical stability. 

Figure 6. The numerical integrator 
  used for the simulation. 
 

Motor Simulation 
The open loop motor is simulated using the transfer function 

 
Rearranging the terms, the expression for acceleration is obtained 

Or    /   ,which will be integrated twice to obtain the motor position. 

Figure 7. The motor position is 
simulated by first calculating the 
acceleration, integrate once to obtain 
the velocity, and integrate again to 
obtain the position using the 
numerical integrator.  
 

Motor Control 
The Quaser SRV02‐E DC servo motor is used in junction with the UPM2405 universal power module and 
controlled digitally through LabVIEW and the NI terminal board. Data acquisition VI’s are given and 
implemented as part of the main VI used in this lab. 

A serial cable connects the NI terminal board to the computer where LabVIEW is installed. From the 
terminal board, the signal output is connected to the UPM (which has a built in D/A converter) to drive 
the motor. From the motor, the encoder output is connected to the A/D port on the UPM, which is then 
connected back to the NI terminal board. 

In place of a standard derivative block when implementing the PD controller, a high pass filter is used to 
provide a similar frequency response as presented by the derivative term   (See ref. [5] and 
corresponding bode diagrams). In addition, the high pass filter also eliminates higher frequencies that 
may damage the motor in the long term.  

Finally, the main VI is modified to display the input signal, simulation results, and encoder readings. 
Figure 8. Controller implementation. 
A high pass filter is used to obtain the 
derivatives while attenuating noise at 
higher frequencies, which may 
damage the motor in the long run.  
 

Figure 9. A simple calculator that 
extracts the natural frequency and 
damping ratio from Kp, Kd and the 
system parameters. 
 

Controller 

Model

Signal Generator

Figure 10. Main‐VI.  
Discussion of Results 

 
Figure 11. The encoder output and simulated response are plotted alongside the input signal. 

In Fig.11, the input is a sine wave with amplitude and frequency as specified in the figure. The slight 
phase lag of the encoder output as compared with the simulation can be explained by the physical path 
the control signal must take, i. e. Computer‐>Terminal Board‐>UPM‐>Motor and the encoder signal also 
needs to travel back to the computer in the reverse sequence. The traveling time of the signal and the 
processing speed of the computer together introduced the delay. On the other hand, the overshoot and 
response seems to be behaving well within the design requirements for a sine wave input. 

Figure 12. The same settings as in 
Fig.11 are used to plot the system 
response to a triangle wave. The 
overshoot and peak time are slightly 
more evident in this case due to the 
discontinuities at the peaks. 
Figure 13. The same settings as in 
Fig.11 are used to plot the system 
response to a square wave. The 
overshoot and peak time also more 
pronounced since the derived 
controllers did not account for the 
additional zero. 
The phase lag as explained before 
also becomes quite clear in this case. 
Since square waves and triangle wave 
(as in Fig.12) are comprised of infinite 
frequencies, the higher frequencies 
may have been amplified if a 
standard PD block is used as opposed 
 
to the high pass filter. 
 
Note that the time step Δ  is carefully chosen so the frequency is at least twice the waveform frequency 
(or simply very small, in the case of square and triangle waves), however it also must be large enough to 
avoid the effects of quantization. The encoder output, which passed through the A/D converter, is a 
quantized signal. If Δ  is too small, consecutive zero derivatives may be the result, which is not desirable 
for a sine and triangle wave input. 

Conclusion  
The resulting controller, though satisfactory in the Simulink simulation, fails to deliver desired results on 
the physical model. As discussed before, this is due to the failure to account for the additional zero in 
the closed loop transfer function during the derivation (or rather, approximation) of the controller gains. 
During the testing of the physical model, additional discrete time control considerations such as 
quantization effects and Nyquist frequency also had to be carefully evaluated. The majority of the time 
was spent on debugging LabVIEW VI’s, which involved laborious line tracing and eye squinting. On the 
bright side, much insight with the software package was also gained by the end of this lab, which should 
facilitate any future implementations using LabVIEW. 

References 
[1] MAE 543 Continuous Controls: Class Notes, University at Buffalo 

[2] MAE 543 Continuous Controls: Motor Modeling Lab Manual, University at Buffalo 

[3] MAE 543 Continuous Controls: Open Loop Motor Simulation Lab Manual, University at Buffalo 

[4] MAE 543 Continuous Controls: Position Control Lab Manual, University at Buffalo 

[5] High‐Pass Filter – Wikipedia: http://en.wikipedia.org/wiki/High‐pass_filter 

You might also like