0% found this document useful (0 votes)
4 views70 pages

Lab Manual

The ECE 360 Control Systems I lab manual outlines a series of experiments focused on controlling a Permanent Magnet Direct Current (PMDC) motor, including modeling, closed-loop control, and disturbance rejection. The labs utilize a hardware and software platform consisting of a PC workstation, an MF634 I/O board, and an interface system to facilitate real-time control and measurement. Each lab builds on the previous one, culminating in advanced control techniques applied to a Ball and Beam system.

Uploaded by

Eric Johson
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views70 pages

Lab Manual

The ECE 360 Control Systems I lab manual outlines a series of experiments focused on controlling a Permanent Magnet Direct Current (PMDC) motor, including modeling, closed-loop control, and disturbance rejection. The labs utilize a hardware and software platform consisting of a PC workstation, an MF634 I/O board, and an interface system to facilitate real-time control and measurement. Each lab builds on the previous one, culminating in advanced control techniques applied to a Ball and Beam system.

Uploaded by

Eric Johson
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Department of Electrical & Computer Engineering

University of Alberta

ECE 360 Control Systems I: Lab Manual


Fall 2016, Version 4

Developed by
Florian Kaumanns (kaumanns@[Link])
Prof. Alan Lynch ([Link]@[Link])
Contents
1. Lab 1: The Hardware and Software Platform 1
1.1. Platform Overview . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . 1
1.1.1. PC Workstation and MF 634 I/O board . . . .
. . . . . . . . . . . . . 2
1.1.2. Interface System . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . 3
1.1.3. Physical Plant . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . 4
1.2. H-Bridge PMDC Motor Drive Model . . . . . . . . . .
. . . . . . . . . . . . . 7
1.3. Simulink and RTWT . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . 9
1.4. Experiment I: H-bridge Simulink PWM Output Block . . . . . . . . . . . . . 16
1.5. Experiment II: Current Measurement . . . . . . . . . . . . . . . . . . . . . . . 18
1.6. Experiment III: Velocity Estimation . . . . . . . . . . . . . . . . . . . . . . . 19
1.7. Experiment IV: Ball Position Measurement . . . . . . . . . . . . . . . . . . . . 20

2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive 21


2.1. PMDC Motor Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.2. Experiment I: Armature Resistance R . . . . . . . . . . . . . . . . . . . . . . 23
2.3. Experiment II: Motor Constant Kt and Friction Coefficients b, Kf . . . . . . . 24
2.4. Experiment III: Estimation of Motor Inertia J . . . . . . . . . . . . . . . . . . 25
2.5. Experiment IV: Armature Inductance L . . . . . . . . . . . . . . . . . . . . . 27
2.6. Experiment V: Open-loop Simulation . . . . . . . . . . . . . . . . . . . . . . . 29

3. Lab 3: Closed-loop Speed Control for a PMDC Motor 30


3.1. Experiment I: Current Mode Controller Design . . . . . . . . . . . . . . . . . 30
3.1.1. Transfer Function Modeling of the PMDC Motor for Current Mode Control 30
3.1.2. Inner Loop Current Control with PI controller . . . . . . . . . . . . . . 32
3.1.3. Outer Loop Velocity Control with PI controller . . . . . . . . . . . . . 33
3.2. Experiment II: Voltage Mode Controller Design . . . . . . . . . . . . . . . . . 35

4. Lab 4: Disturbance Rejection and Advanced PI Control 37


4.1. Experiment I: Load Torque Disturbance Rejection of Closed-loop Velocity Control 37
4.2. Experiment II: Anti-Windup PI (Optional) . . . . . . . . . . . . . . . . . . . . 39
4.3. Experiment III: Motor Position Control and Load Torque Disturbance Rejection 41

5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency
Domain Methods 43
5.1. Transfer Function Modeling of the Ball and Beam . . . . . . . . . . . . . . . . 43

ii
Contents

5.2. Experiment I - Lead Controller Design for Ball Position using Root Locus . . 46
5.3. Experiment II - Lead Controller Design for Ball Position Using the Frequency
Response Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50

A. Appendix: Datasheets 53
A.1. A-max 32 motor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 53
A.2. HEDL 5540 Encoder . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55
A.3. Current Filter Inductor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57
A.4. H-bridge . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59

Bibliography 67

iii
1. Lab 1: The Hardware and Software
Platform
The labs for ECE 360 Control System I all relate to controlling a Permanent Magnet Direct
Current (PMDC) servo motor. During Labs 2 and 3 this motor will be controlled with no load
attached (most of the time). In Lab 4 we attach an identical PMDC motor operated as a generator,
and in Lab 5 we attach a Ball and Beam positioning system. The PMDC motor is an important
device for achieving servoing or motion control tasks in general. For example, closed-loop velocity
control of a wheeled mobile robot often relies on PMDC motors.
The content of the five labs is
• Lab 1: This lab introduces the experimental platform.
• Lab 2: This lab involves PMDC motor modeling and model parameter identification. A
comparison of simulated and experimental open-loop PMDC motor response is performed.
• Lab 3: This lab investigates closed-loop velocity control using Voltage and Current Modes
of operation. Time domain control design methods are used.
• Lab 4: This lab investigates closed-loop position and velocity control with a generator load
disturbance. It also investigates an anti-windup method.
• Lab 5: This lab considers position control of a Ball and Beam system using root locus and
frequency response design methods.

1.1. Platform Overview


Figure 1.1 shows a block diagram of the hardware and software platform used in the lab. There
are three basic components:
1. A PC Workstation and Data I/O card (MF634) for real-time controller development and
simulation using Matlab/Simulin.
2. An Interface System which provides current measurement, H-bridge motor drives, power,
and protection circuits.
3. A Physical Plant which can include the PMDC motor, PMDC generator, and Ball and
Beam.
We describe these three subsystems in more detail.

1
1. Lab 1: The Hardware and Software Platform

MATLAB
SIMULINK
MF 634 + RTWT

PC Workstation

Current I/O
Transducers H-bridges + Protection

Interface System

Physical Plant

Motor/Generator Ball and Beam


+ Motor position + Ball position

Figure 1.1.: Block diagram of ECE 360 Lab platform.

1.1.1. PC Workstation and MF 634 I/O board


The PC Workstation runs Windows 7 and Matlab/Simulink which is the software environment
used in the ECE 360 labs. This software provides a intuitive graphical method for developing
control systems in simulation or run in real-time and interfaced to the Physical Plant via the MF
634 I/O board and Interface System. The motivation for using this software environment is to
reduce the complexity of implementation. For example, implementation in Matlab/Simulink
does not require I/O board driver development and control laws can be implemented without
hand-coding in a programming language. This should be compared with a traditional approach
to embedded system development where low level programming by hand is normally required.
Matlab/Simulink also allows us to move from simulation to experiment seamlessly, and this
makes it easier to focus on control theory learnt in lecture rather than implementation details.
The MF634 I/O card, manufactured by Czech company Humusoft, is installed in a PCIe slot of
the PC workstation. A full description of this card is in [1]. The MF634 provides a wide variety

2
1. Lab 1: The Hardware and Software Platform

of I/O:

• 8x analog-to-digital inputs (“ADinX” denotes AD Channel X). 14 bit Analog to Digital


(AD) converter with ±10 V range.

• 8x digital-to-analog outputs(“DAoutX” denotes DA Channel X). 14 bit Digital to Analog


(DA) converter with ±10 V range.

• 8x digital inputs (“DinX” denotes digital input Channel X), 8x digital outputs (“DoutX”
denotes digital output Channel X)

• 4x encoder inputs (“EncX” denotes encoder input X).

• 4x timer/counter channels. The channels will be used for Pulse-width Modulation (PWM)
outputs (“PWMoutX” denotes PWM output Channel X). Note: the timer/counter channels
have a 50 MHz clock, 32 bit resolution, and are dual purpose, i.e., they must be configured
as either frequency generator outputs or counter inputs. However, counter functionality (e.g.
frequency measurement of pulse counting applications) is not required in this lab (other
than the separate encoder input).

The MF634 allows controls running on the PC’s CPU to perform I/O with a physical system.
For example, we will read current of the PMDC motor using an AD channel.
Drivers for the MF634 are provided in Simulink’s Real-time Windows Target (RTWT)
toolbox1 . Together with an installed Microsoft Visual C++ compiler, this toolbox allows us
to build Simulink models which can send and receive data to the MF634 without performing
any hand-coding. RTWT also ensures the control laws run in real-time on the CPU of the PC,
e.g. our control law is implemented with a predictable sampling time in spite of the needs of
the Windows OS. Section 1.3 describes the library of Simulink blocks provided by RTWT to
program the I/O of the MF634. The section also briefly introduces Simulink in general with an
emphasis on RTWT functionality.

1.1.2. Interface System


As shown in Figure 1.1, an Interface System lies in between the PC and MF634 and the Physical
Plant. The Interface System includes a circuit board shown in Figure 1.2 which allows for physical
interconnection of the MF634 with the Physical Plant. The circuit board contains two H-bridge
amplifiers, current measurement circuits, and I/O board protection circuitry. This board is
connected to the MF634 via two 40-pin ribbon cables. The H-bridges are used to drive the
motors as the MF634 cannot provide high current output. Current measurement is achieved
using Hall-effect transducers which provide an isolated measurement of the motor current output
by the H-bridges. This current measurement is low-pass filtered to reduce ripple components and

1
It is important to note that RTWT has been renamed to Simulink Desktop Real-Time in MATLAB 2015a.
We refer to the product as RTWT.

3
1. Lab 1: The Hardware and Software Platform

provide anti-aliasing so that it can be fed to an AD channel of the MF634. The voltage sent to
the AD is only proportional to current and so calibration is required as discussed in Section 1.5.
The interface board protection circuits decrease the risk of damaging the MF634 which costs
about $1500. The Interface System includes a regulated switched power supply that feeds the
H-bridge amplifiers a DC voltage. It also supplies power to other components of the interface
board. It delivers a controlled DC voltage Vd = 46 V at a maximum current of 6.8 A. On the top
panel of the circuit board a power switch is mounted. It passes both the 46 V supply, indicated
by a blue LED, and a 5 V supply, indicated by a green LED, to the interface system components.
The outside of the Interface System is show from the top and side in Figure 1.3.

Figure 1.2.: Circuit Board inside the Interface System.

1.1.3. Physical Plant


The Physical Plant consists of the PMDC motor, generator, and Ball and Beam system. These
are the physical systems whose behaviour we want to control.
The PMDC motor is shown in Figure 1.4. It is an A-max 32 which is a 32 mm diameter, 20 W
precision servo motor manufactured by Maxon AG in Switzerland (Part No. 353239). This motor
has a rated voltage of 24 V, rated current of 1.33 A, rated speed of 6460 rpm, and rated torque of
44 mN m. The data sheet for this motor is in Section A. The motor does not include a gearhead.
The motor includes an integrated Maxon HEDL 5540 optical encoder which provides 500
Encoder Counts per Turn (CPT) position measurement and line drivers for improved
signal conditioning (Part No. 110512). The data sheet for the encoder is in Appendix A. The
PMDC motor is used in all labs.

4
1. Lab 1: The Hardware and Software Platform

Figure 1.3.: The box housing the Interface System. Top view (left) showing various interconnection
jacks. Side view (right) showing LEDs and encoder input jacks.

Encoder
Motor

Figure 1.4.: The A-max 32 PMDC motor with HEDL 5540 encoder attached.

The PMDC generator is identical to the PMDC motor except that it does not include an
encoder. It is coupled to the motor using a rigid aluminum coupling. The coupled motor-generator
system is shown in Figure 1.5 and is used in Lab 3.
The Ball and Beam system is shown in Figure 1.6. It is a 2-link mechanism which attaches
to the PMDC motor shaft. A ball rolls along one of the links and we study the problem of
controlling its position in Lab .

5
1. Lab 1: The Hardware and Software Platform

Coupling

Motor

Generator

Encoder

Figure 1.5.: The A-max 32 PMDC motor-generator.

Ball

Beam with
position 1:1 Gears
measurement
Motor shaft

Figure 1.6.: The Ball and Beam system.

6
1. Lab 1: The Hardware and Software Platform

Figure 1.7.: H-bridge converter.

1.2. H-Bridge PMDC Motor Drive Model


To enable so-called “4-quadrant operation” (see Section 2.1 for details) a motor drive interfaced
to a PMDC motor should have following features:

• It should be capable of applying positive and negative v at the motor terminals. This
voltage should be independent of the current i provided which could be either positive or
negative.

• To ensure a simple control of the PMDC motor, the relation between the drive’s control
input and its output voltage should be modelled by a pure gain.

• In order to minimize losses and torque/speed pulsations the current i produced should have
small ripple.

Although a linear amplifier satisfies all the aforementioned requirements its low efficiency makes
it uncommon today. To improve efficiency, modern PMDC drives rely on DC-DC converters
which employ power electronic switches. A switched power electronic amplifier often used for
DC motor drives is the Full-bridge or H-bridge converter depicted in Figure 1.7. This topology
enables 4-quadrant operation and provides a simple way to control voltage to the PMDC motor.
The four switching cells S1 - S4 each comprise one MOSFET and one freewheeling diode. Each
cell can be thought of as an ideal switch.
In contrast to linear amplifiers, armature current delivered by the H-Bridge suffers from ripple
components due to its switched mode of operation. However, it is possible to reduce the amount
of ripple to an acceptable level by adjusting supply voltage, switching frequency, or inductance
(see Section 2.5).

7
1. Lab 1: The Hardware and Software Platform

Vd v i

0 5Tsw 6Tsw 7Tsw


dTsw Tsw 2Tsw 3Tsw 4Tsw t

–Vd S3,S4

S1,S2
S1,S4 S2,S3

Figure 1.8.: PWM waveforms for i > 0 and v̄ greater (0 < t ≤ 4Tsw ) and smaller (4Tsw < t ≤ 8Tsw )
than zero. The blue lines corresponds to the average voltage v̄.

In the experimental setup used for this lab a 3-level PWM switching scheme is used to drive
the four switching cells S1 - S4 . This means v can be either negative (−Vd ), positive (Vd ) or zero.
In this lab Vd = 46 V. PWM involves turning Sk on and off at the so-called constant switching
frequency fsw = 1/Tsw . In this lab we take fsw = 30 kHz. By adjusting the on duration of the
switching cells over the switching period Tsw the average value of v can be controlled. We define a
duty cycle 0 ≤ d ≤ 1 which is the ratio of the on time to the switching period Tsw . The expression
for the average value of v over one switching period Tsw is

1 Z t+Tsw
v̄ = v(τ )dτ (1.1)
Tsw t

Since the PWM switching frequency is high, our modelling and control of the PMDC motor drive
will use average voltage v̄ as a system variable. In Section 2.6 you will compare a PMDC drive
models based on average voltage v̄ and instantaneous voltage v. This comparison proves the time
average model of the drive is sufficiently accurate.
Next, we describe the basic operation of the H-bridge converter. In the first case let’s assume
i ≥ 0. Then the following two cases can be distinguished depending on v̄ being smaller or greater
than 0 (i.e., Q I & Q II):

• v̄ ≥ 0: S1 and S4 are turned on and S2 and S3 are turned off during 0 < t ≤ dTsw where d
denotes duty cycle. Since i is positive the current flows through the MOSFETs of S1 and S4 .
During the first interval of the switching period 0 < t ≤ dTsw we have v = Vd . In the second
interval of the switching period dTsw < t ≤ Tsw , S3 is turned on while S1 is turned off (S4
remains on and S2 remains off). Due to i > 0 the current flows through the MOSFET of S4
and the diode of S3 . The motor terminals are short-circuited, hence v = 0. Using (1.1) the

8
1. Lab 1: The Hardware and Software Platform

average voltage is v̄ = dVd .

• v̄ < 0: During the first interval of the switching period 0 < t ≤ dTsw S2 and S3 are turned
on and S1 and S4 are turned off. Since the current is greater than 0 it flows through the
body diodes of S2 and S3 , and v = −Vd . In the interval dTsw < t ≤ Tsw , S1 is turned on
while S3 is turned off (S2 remains on and S4 remains off). The current flows through the
MOSFET of S1 and the diode of S2 . Again, the motor voltage is short-circuited v = 0.
Using (1.1) the average voltage is v̄ = −dVd .
Similar analysis can be performed for the case i < 0 and v̄ ≥ 0 or v̄ < 0 (Q III & Q IV). In
summary v̄ is independent of the direction of i and the input-output relation for the H-bridge is

 d · Vd , for non-negative v̄
v̄ = (1.2)
−d · Vd , for negative v̄

We remark in general the average voltage v̄ is a time varying quantity used to control the PMDC
motor. The duty cycle d and v̄ only remain constant over the switching period Tsw .
As mentioned earlier these averaged quantities are used for modelling and control design.
Therefore the bar notation is dropped in general, and v and i refer to their averaged quantities
from now on.

1.3. Simulink and RTWT


Simulink is part of Matlab and is intended for simulating complex systems using block diagram
models. A Getting Started guide is available at [2] and detailed User’s Guide is at [3]. In this
section, we only briefly introduce the use of Simulink and RTWT. Further details on RTWT is
in [4].

• Starting: Typing in simulink in the Matlab command window will open the Simulink
Library Browser shown in Figure 1.9. By selecting New from the File menu you get a
new model window which you use to build a Simulink model. This model is saved as a file
with .slx extension.

• Creating blocks: Simulink has a standard block library shown currently selected in Figure 1.9
and labelled Simulink; additionally, there are other libraries such as RTWT, Communication
System Toolbox, Control System Toolbox, etc. We will only be using the Simulink and
RTWT libraries. To create a Simulink model, you can drag and drop blocks from any of the
Libraries in the Simulink Library Browser into your model.

• Connecting inputs and outputs: Building system models in Simulink is intuitive. To


connect the output of block A to the input of block B, left click the output port of block
A, drag it to the input port of block B, and release the mouse button. To connect a point

9
1. Lab 1: The Hardware and Software Platform

Figure 1.9.: The Simulink Library Browser.

from a data line to an input or output port, press and hold the Ctrl key, and then click
on the point in the line and drag it to the port. When the ports are connected, the angle
brackets disappear and the solid arrowhead indicates the direction of signal flow as shown
in Figure 1.10. Rather than hold the Ctrl key you can also left click the block you want to
connect to and drag to the data line.
• Simulation parameters: Figure 1.11 shows the Configuration Parameters dialog with
the Solver settings selected. Launch this dialog by hitting the gear button in the menu bar
of your model window (see Figure 1.13). The simulation stop time has to be chosen to meet
the requirements of the experiment or simulation. Pick the fixed-step ode3 solver. The
fundamental sample time should always be initialized with the variable T_s. Since T_s
should also be used in the RTWT I/O blocks in the field Sample time, it is recommended
to define T_s in a script which is run before the simulation or experiment. See Figures 1.17a–
1.17c. If the Simulink model does not include RTWT blocks, configuration of the simulation
is finished. However, if RTWT blocks are involved adjustments to the Code Generation
section have to be made. As shown in Figure 1.12, under Target Selection hit the Browse
button to select a different target. In the dialog that pops up select [Link] and press
OK twice to apply the changes. Additionally, the simulation mode has to be changed from
the default Normal to External in the button area of your model window menu bar (see
Figure 1.13).

10
1. Lab 1: The Hardware and Software Platform

Figure 1.10.: Connecting blocks in Simulink.

• Simulating: In order to simulate a standard (i.e., no RTWT blocks) Simulink model hit
the green Run button in your model window or select Start from the Simulation menu. If
a model containing RTWT blocks has to be run, use the following steps: First, build the
model by hitting the green run button in the model’s menu bar (see Figure 1.13). This
will rebuild the model (i.e., generate source code corresponding to the model and compile
it). Generally, the model has to be rebuilt whenever it was modified structurally (e.g.
signals lines deleted or rerouted). This does not include adjustments made to parameters

Figure 1.11.: Simulink solver settings.

11
1. Lab 1: The Hardware and Software Platform

Figure 1.12.: Code Generation settings for RTWT in Simulink.

(e.g. changing parameters in the Gain, Constant or Transfer fcn block). Note that the
build process takes some time so it’s good to remember that it is not required when only
parameters in the model have been changed. In fact, you can vary model parameters while
the model is running. This is a very useful feature of RTWT as it allows the real-time
response of your system to be tuned. If the model builds successfully, it will start to
execute immediately. Important: you can hit the Stop button to terminate the program
if something does not look right. You can also turn off the power to the Interface System to
stop the system faster.

• Plotting: Generally, for plotting purposes the Scope block which is a standard block in
Simulink is used. It can be found in the Simulink library under Commonly Used Blocks.
Place the Scope in your model. Double-click the scope symbol and press the gear button

Settings Run Stop Simulation mode

Library browser Stop time Build

Figure 1.13.: Simulink menu bar and buttons for a model window.

12
1. Lab 1: The Hardware and Software Platform

Figure 1.14.: Scope settings in Simulink.

to invoke the settings window shown in Figure 1.14. In the General Tab choose the
number of axes depending on the number of subplots you wish to create in the scope.
Select the History Tab and remove the tick from data points limitation. Check the Save
data to workspace box and leave the default settings. In standard Simulink models the
environment automatically takes care of storing all data that is visualized in the Scope.
If the RTWT kernel is involved in External mode (i.e., you are performing a physical
experiment) you have to specify the buffer length for the data to be stored. If not configured
properly data loss may occur. Configuration involves navigating to the Code menu in
the model window and pressing External Mode Control Panel. In the pop-up window
select Signal & Triggering.... You should see the window in Figure 1.15. The only

Figure 1.15.: Buffer settings in External mode.

13
1. Lab 1: The Hardware and Software Platform

adjustment that has to be made in order to get the desired behavior when recording data
is the Duration field. Since the Duration field assumes a value in terms of samples you
have to take the sample time T_s and the duration of the simulation into account when
calculating the buffer length. As an example, assume T_s=1e-3 (1 ms) and the desired
simulation stop time is 10 s (T_sim=10). To avoid data loss the buffer length has to be
chosen to Tsim /Ts + 1 = 10001 samples. The one is added since the buffer would otherwise
get flushed right at the end of the simulation (10000th sample). Once a simulation is finished
you can access the scope data from the Matlab workspace. Normally data is best visualized
in Matlab and the Simulink scopes are mainly for fast access to data in real-time. As
shown in Figure 1.14, the scope data is exported to the workspace in a structure called
ScopeData by default. Assuming the number of axes was three, the following commands
should be executed to produce a plot
plot ( ScopeData . time , ScopeData . s i g n a l s ( : , 1 ) . v a l u e s , ’ x l a b e l ’ , ’ t / s ’ ) ;
hold a l l ;
plot ( ScopeData . time , ScopeData . s i g n a l s ( : , 2 ) . v a l u e s ) ;
plot ( ScopeData . time , ScopeData . s i g n a l s ( : , 3 ) . v a l u e s ) ;

• RTWT blocks: Throughout this lab you will use the Frequency Output, Encoder Input,
Analog Input, Digital Input, and Digital Output blocks that can be found in the
Real-Time Windows Target Library in the Simulink Library Browser. When you
use any of these block you must ensure that the MF634 I/O card is selected in the Data
acquisition board section of the blocks’ settings. After selecting the MF634 a dialog
box shown in Figure 1.16 will open asking for you to configure the counter/timer channels.
Configure all channels as Frequency Generator as shown in Figure 1.16. Additionally, sample
time has to be assigned consistently in every block of a model by using the sample time
variable T_s that has to be defined in the workspace.

Figure 1.16.: Time/counter setup dialog. Be sure to select all channels to use the frequency generator
functionality.

The Frequency Output block whose settings are shown in Figure 1.17a is responsible for
providing high frequency PWM signals to drive the H-bridges. In addition to selecting
the correct board hit the Board Setup button and set all frequency outputs to Frequency

14
1. Lab 1: The Hardware and Software Platform

PWMout1 PWM output to motor H-bridge (PWMH)


PWMout2 PWM output to generator H-bridge (PWMH)
ADin1 AD voltage input for motor current
ADin2 AD voltage input for generator current
ADin3 AD voltage input for unfiltered motor current
ADin4 AD voltage input for ball position
Encin1 Encoder input for motor
Dout1 Digital output for motor H-bridge direction (DIR)
Dout2 Digital output for motor H-bridge mode control (PWML)
Dout3 Digital output for generator H-bridge direction (DIR)
Din1 Digital input for motor H-bridge fault status
Din2 Digital input for generator H-bridge fault status

Table 1.1.: Summary of channels used.

generator. Channel 1, denoted PWMout1, drives the motor H-bridge and Channel 2, denoted
PWMout2, drives the generator H-bridge. Important: To ensure proper behavior after the
model terminates, the initial and final values for the switching frequency and duty cycle
have to be chosen as shown in Figure 1.17a. Enable the external duty cycle pin by selecting
duty source as external.
In order to read motor shaft position you will need the Encoder Input block whose settings
are shown in Figure 1.17b. Make sure all settings (except the channel selection) match
the ones in Figure 1.17b, especially the Reset input function. The channel has to be
selected consistently with the physical channel chosen for the encoder. We choose to use
Channel 1 which is denoted Encin1.
The Analog Input block shown in Figure 1.17c is responsible for capturing analog input
signals. Channel 1, denoted ADin1, is connected to the low-pass filtered current sensor
output of the motor H-bridge, ADin2 to the low-pass filtered current sensor output of the
generator H-bridge, ADin3 to the current sensor output of the motor H-bridge enabled to
measure the current transients and ADin4 to the DIN-connector for the Ball and Beam.
Make sure all settings correspond to the ones shown in Figure 1.17c.
Finally, the Digital Input and Digital Output blocks enable reading low frequency
digital signals into the MF634 and applying low frequency digital outputs from the MF634.
Some of these signals will be used with the H-bridges.
A summary of the channels used in the 5 labs is in Table 1.1.

15
1. Lab 1: The Hardware and Software Platform

(a) Frequency Output Block (b) Encoder Input Block set- (c) Analog Input Block set-
settings (PWM output). tings. tings.

Figure 1.17.: Important RTWT block settings for the MF634 I/O card.

1.4. Experiment I: H-bridge Simulink PWM Output


Block
In order to operate the H-bridges in the PWM mode used in this lab and described in Section
1.2 we cannot use just a single MF634 Frequency Output block. The H-bridge has additional
digital inputs and outputs responsible for PWM mode selection and fault detection which should
be used to ensure proper operation. Figure 1.18 shows the connections from the two H-bridges
to the MF634. Each pin has two labels: the label in the box relates to the H-bridge and the
one outside corresponds to the MF634 I/O channel. The “DIR” or direction pin enables reverse
direction of the motor. We define negative voltages to result in negative shaft direction which
can be achieved by applying 1 with a MF634 Digital Output block. As shown in Figure 1.18,
Dout1 (i.e., Channel 1 of the Digital Output block) relates to the motor H-bridge and Din2 is
tied to the generator H-bridge. The “PWMH” pin is the input of the PWM signal generated
by the MF634 Frequency Generator block. As described earlier, PWMout1 is connected to the
motor H-bridge and PWMout2 is connected to the generator H-bridge. Finally, the fault flag pins
“FF1” and “FF2” of both H-bridges are connected to an OR gate whose output is logic 1 if either
of the flags is set. Hence, the output of the OR gates indicate a fault condition such as a short
circuit, under-voltage or over-temperature. The outputs of the OR gates have to be monitored by

16
1. Lab 1: The Hardware and Software Platform

Motor
H-bridge

Dout1 DIR
FF1
Dout2 PWML Din1
FF2
PWMout1 PWMH Generator
H-bridge

Dout3 DIR
FF1
Din2
FF2
PWMout2 PWMH

Figure 1.18.: Internal connections from H-bridges to the MF634.

using the Digital Input block. As soon as a logic 1 is detected at a digital input the PWM
duty cycle of the corresponding H-bridge has to be set to zero to avoid possible damage. Faults
of the motor H-bridge are monitored at Din1 and faults of the generator H-bridge are monitored
at Din2.
In order to ensure the H-bridge is in a “drive-brake” mode (which is the usual mode used in
the labs and discussed further in the “Motor Control Options” section of Appendix A.4) it is
necessary to keep “PWML” high. Hence, be sure to set Dout2 to a high voltage. This also implies
that Initial value and Final value in the settings of the Digital Output block should be
set to 1.
When identifying the motor model parameters in Lab 2, it useful to use the so-called “coast”
mode which is enabled by setting “PWML” and “PWMH” low. This functionality should be
included in your model.
More details on the H-bridge can be found in Appendix A.4. A summary of the channels
discussed above are listed in Table 1.1.

Tasks
• Design and implement a PWM output block for the motor H-bridge in Simulink that
satisfies all requirements discussed in this section. The input of this custom block should
be the average voltage v̄. Also include a binary input for enabling “coast” mode. See
Figure 1.19 for the block diagram. Refer to Section 1.2 for how to compute duty cycle d
from this voltage. Test your PWM output block with a duty cycle of d = 0.5. Use sample
time of Ts = 1 ms. Important: include a saturation block to limit your average voltage to
24 V. This will prevent potential damage to the system.
• Test the PWM output block by applying sufficiently large voltage with both, positive and

17
1. Lab 1: The Hardware and Software Platform

Figure 1.19.: Block diagram for the PWM output.

Analog
Input 1/5
1
Analog Input
i
Humusoft
MF634 [auto] offset
2
calibration
C_i

Figure 1.20.: Current measurement Simulink model.

negative signs and check if the motor behaves as expected. Verify your “coast” mode
functions by rotating the shaft quickly and feeling the reduced resistance.

1.5. Experiment II: Current Measurement


Since the transient current waveform is measured by a Hall effect current transducer several
signal conditioning stages are required to minimize the ripple in the measurement and match
the input range of the AD converter with the output range of the current transducer. This is
achieved by an Operational Amplifier (OPAMP) circuit that implements a second order low pass
filter with corner frequency ωcg = 2π · 6000 rad s−1 and a gain of 5. The hall effect current sensor
measures a voltage proportional to the measured current. The constant of proportionality is
determined by the circuit design and the value is Ci = 0.5. Hence, the overall gain from the
current to the analog input is 10. The circuitry is identical for both, motor and generator H-bridge
current measurement. The analog input channels used are ADin1 and ADin2 for the motor and
generator respectively. A small offset is contained in the measurement and should be compensated.
To compensate the aforementioned effects the Simulink model shown in Figure 1.20 has to be
used for current measurement. The constant named offset is the offset constant you have to
determine at the beginning of every lab.
The interface board features an additional current measurement port that allows measurement
of the transient ripple current waveform. This allows direct measurement of the unfiltered current
waveform with an oscilloscope.

18
1. Lab 1: The Hardware and Software Platform

Tasks

• Calibration of the parameter offset is done by applying zero output voltage across the
motor and generator terminals so that current is zero. Measure the current for a couple
of seconds. Average the signal over the measurement period and the result is the offset.
Assign this value to a variable offset in your scripts. Use sample time of Ts = 1 ms.

• Provide plots of your current measurements with and without offset compensation.

1.6. Experiment III: Velocity Estimation


Velocity of the motor shaft can be estimated by differentiating the position signal produced by
the encoder. Since this signal is discrete the process of differentiation introduces considerable
noise which can be reduced with a low pass filter. We choose the bandwidth of the low pass
filter to sufficiently high to capture transient velocities and sufficiently low to filter noise. This
compromise is obtained with the transfer function

s · 2π75
D (s) = .
s + 2π75

Use this transfer function along with the other blocks shown in Figure 1.21 for your velocity
estimation. The constant K_enc calibrates the output of the encoder in pulses to units of radians.
The data sheet of the encoder in Section A provides the information required to obtain this
constant. Additionally, note that we operate the encoder in a quadruple Quadrature mode
which means that the number of counted pulses is multiplied by four (see Figure 1.17b). w_cal
represents another calibration parameter which is necessary since the differentiaton is not exact.
The differentiator gain depends on the sample time parameter T_s, and has to be recalibrated
when a different T_s is used.
Tasks

• The procedure to determine w_cal is as follows: Apply a constant (positive) voltage at the
motor terminals for a couple of seconds, set w_cal to one and measure position and velocity
of the motor shaft with the block diagram shown in Figure 1.21. After the experiment is
terminated read the steady state velocity estimate from the scope. Then, take two position
data points from the linear region of the position waveform. Determine the real value of
the velocity by computing the slope. Finally, adjust w_cal such that the velocity estimate
matches the real value of the velocity. Take care that velocity resulting from a positive
voltage being applied should be also positive by convention. Hence, a sign change may be
introduced to w_cal. Perform the computation for w_cal with two different sample times
Ts = 1 ms and Ts = 50 µs. You can use the fit(x,y,’poly1’) command to obtain the
velocity from a linear fit of the position data.

19
1. Lab 1: The Hardware and Software Platform

Encoder 2*pi*75s
Input K_enc w_cal
s+2*pi*75
E ncoder Input LP Derivitive
Humusoft Velocity
MF634 [auto]

Figure 1.21.: Velocity estimation Simulink model.

1.7. Experiment IV: Ball Position Measurement


In this section we determine a linear relationship between the position of the ball on the beam
and a voltage which is read into an analog input. This position information will be used in Lab 5
to control the ball’s position.

Tasks

• Position the ball at the endpoints of the beam and record the corresponding voltages using
ADin4. Obtain a linear calibration relationship between voltage and ball position. Take the
positive ball position corresponding to positive voltage. You can use the fit(x,y,’poly1’)
command to obtain the linear relation between ball position and voltage from ADin4.

Important: be sure to keep a copy of all your models in this lab as they will be used in
subsequent labs.

20
2. Lab 2: Modelling a Permanent
Magnet DC (PMDC) Motor and
Drive
The purpose of this lab is to make you familiar with the dynamic model of the PMDC motor and
its operation with the H-bridge drive introduced in Lab 1. The motor model involves a number of
model parameters which are commonly found in data sheets supplied by the manufacturer. As an
engineer specifying a PMDC motor in some application, you will be expected to understand the
meaning of the model parameters in order to ensure your motor meets the design specifications of
your entire system. This lab will demonstrate how the values of the model parameters can be
determined from various experiments. This is useful if data sheets are unavailable or incomplete.
Most importantly however, the experiments build an appreciation of the physical meaning of the
parameters and how they affect motor performance. Lab provides an important basis for work in
subsequent labs. Hence, special care should be taken to understand its content.
Important note: Download the files relating to Lab 1 from the ECE 360 Lab eclass site.

2.1. PMDC Motor Model


We consider the PMDC motor system shown in Figure 2.1. To obtain its differential equation
model we apply Newton’s Law at the output shaft:

J ω̇ = τ − τf − τl , (2.1)

where J is the effective inertia of the motor system which is due to all rotating components (i.e.,
the shaft, rotor, and encoder), ω is the output shaft velocity, τ the electrical torque generated by
the PMDC motor, τf frictional torque and τl load torque. The latter is sometimes treated as an
unknown disturbance.
The electrical torque τ generated by the PMDC motor is linearly related to the armature
current i:
τ = Kt i, (2.2)

where Kt is the motor’s torque constant.

21
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

R L
i
+ +
ω, τ τf , τl
v eA − Jl
+ Js
− −

Figure 2.1.: Electro-mechanical equivalent circuit of PMDC motor. The inertia of the shaft is Js and
load Jl . The effective inertia of the system J = Js + Jl .

Frictional torque τf is modeled as a combination of viscous friction proportional to speed and


a constant Coulomb friction term:

τf = Kf · sgn(ω) + bω, ω 6= 0, (2.3)

where Kf is the Coulomb friction torque, b the viscous friction coefficient, and


−1,x<0



sgn(x) = 0, x = 0


 1, x > 0

Combining (2.1) - (2.3) for ω > 0 yields


J = Kt i − bω − Kf − τl (2.4)
dt

The dynamics for armature current i can be found by application of KVL and is given by

di
L + Ri = v − Km ω, (2.5)
dt

v is the input voltage, Km the motor’s back-emf constant, L armature inductance and R armature
resistance. We denote the back-emf voltage as eA = Km ω. It can be shown that Km = Kt if stated
in MKS units. Hence, to simplify notation we replace Km with Kt from here on. Differential
equations (2.4) and (2.5) give the time domain dynamic model of the PMDC motor for ω > 0.
In order to reduce current ripple we add an additional external inductor L1 to the armature
circuit. This is discussed further in Section 2.5. The external inductor introduces a parasitic

22
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

Reverse Braking Forward Motoring


Q II QI
eA ≤ 0, i ≥ 0 eA , i ≥ 0

Reverse Motoring Forward Braking


Q III Q IV
eA , i ≤ 0 eA ≥ 0, i ≤ 0

Figure 2.2.: Four Quadrant operation of a DC motor.

resistance R1 which adds to the armature resistance of the motor. The model parameters L and
R discussed above will include the circuit parameters of the external inductor. The values used
are L1 = 3.3 mH and R1 = 1.27 Ω. These values are taken from the data sheet in Appendix A
(Model No. 1130-332K-RC).
Depending on the sign of ω and τ the motor operates in four different modes that are denoted
as quadrants Q I, Q II, Q III, and Q IV. The forward motoring mode or Q I occurs when ω and
τ are positive. Consider a motor driving an inertial load which accelerates from rest in a positive
direction. During this period of acceleration eA and i are greater or equal to zero or in other
words power is transferred from the voltage source to the mechanical load.
Now consider the problem of decelerating the motor from a positive velocity to rest. This
process of braking requires a negative electrical torque which means a negative i which can be
obtained by adjusting v < eA . Initially ω, and therefore eA , remain positive until rest. Hence,
the motor is operating in forward braking mode or Q IV. Since τ · ω < 0, power is absorbed into
the voltage source from the mechanical system. As expected eA · i < 0 since the voltage source
absorbs power.
The two aforementioned modes of operation can be also explained if the motor is turning in
negative direction. This corresponds to reverse motoring (Q III) and reverse braking (Q II).
Evidently, in generating modes Q II and Q IV the motor transfers power from the mechanical
system to the voltage source. In contrast, in Q I and Q III the motor is in motoring mode since
power is fed to the mechanical system from the voltage source.

2.2. Experiment I: Armature Resistance R


Armature resistance R is a lumped parameter comprising winding resistance, brush resistance
and other resistances in the electrical path of the PMDC motor. From Figure 2.1 R can be

23
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

determined by exciting the electrical subsystem by an input voltage v such that output angular
velocity ω remains zero. This is possible due to the non-zero friction at zero velocity provided |v|
is sufficiently small. Furthermore the PMDC motor has no disturbance load (i.e., τl = 0). Under
these assumptions and in steady state R is determined by

v
R= , (2.6)
i

since back-emf eA is zero (ω = 0).

Tasks

• Modify the script armature_resistance, which includes code to calibrate the current
measurement, to estimate R ten times and average the values obtained for R in every run.
Set the average voltage to v = 2.5 V to obtain your current measurements and rotate the
shaft to obtain a range of measurements. The reason for this are the brushes that make R
dependent on the rotor position. Discard measurements that indicate extraordinary high
resistance values and repeat them at a different angle. You should attach a gear to the
shaft so that you can prevent the motor from rotating.

• Compare your result to the reference value provided in the motor data sheet and take
the parasitic resistance of the smoothing inductor into account. See Section A and motor
No. 353239.

• Remove the gear from shaft.

2.3. Experiment II: Motor Constant Kt and Friction


Coefficients b, Kf
In this section we first estimate the motor constant Kt . Assuming steady state in (2.5) and
solving for Kt we obtain
v − Ri
Kt = (2.7)
ω

In the next step the coefficients of the friction model (2.3) are determined. This can be accom-
plished by means of (2.4) and if torque constant Kt and armature resistance R are known. Then,
under the assumption of steady state conditions, ω > 0, and an unloaded shaft (τl = 0) (2.4)
becomes
Kt i = Kf + bω. (2.8)

24
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

In order to obtain values for b and Kf we excite the motor with a range of voltages and measure
the current and speed. Using (2.8) and averaging the measurements, we can obtain an estimate
for b and Kf . Figure 2.3 shows a sample identification of b and Kf . The values given there might
not be the same as your motor. and data obtained from a sample experiment using e.g. fit.

Tasks
• Modify the script torque_constant, which performs current calibration using the model
experiment_i.slx, to compute the torque constant Kt . The script torque_constant relies
on the model exp2_torque_constant.slx to obtain necessary measurements. Insert the pre-
viously determined value for R in the script
torque_constant. Determine the duty cycle required to apply an average constant voltage
of v̄ = 24 V. Compute Kt by averaging i and ω and using (2.8).
• Compare your result for Kt to the reference value provided in the data sheet in Section A.
• The script friction_coefficients collects the data for ω and i. Modify the script
friction_coefficients to perform a linear curve fit for Kf and b. For example, you can
use Matlab’s fit.

2.4. Experiment III: Estimation of Motor Inertia J


The inertia of the system is denoted J and is due to the motor’s rotor and encoder. Inertia affects
how fast a motor’s speed will change for a given applied torque. It therefore affects the speed of
response of velocity.

1.25

1.00
τf (mN m)

0.75

0.50

0.25

0 100 200 300 400 500 600


−1
ω (rad s )

Figure 2.3.: Friction torque sample data. First order polynomial curve fitting yielded Kf = 0.9677 mN m
and b = 4.1 × 10−4 mN m s.

25
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

ω measured
600 Curve fit
ω (rad s−1 )

400

200

0
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14
t (s)

Figure 2.4.: Inertia experiment waveform and curve fitted linear model.

To estimate J we initially operate the PMDC motor at some steady state velocity ω. In order
to see a full transient deceleration we choose the initial velocity corresponding to the nominal
v = 24 V. At some instant the voltage supply is disconnected from the motor terminals. We
assume that armature current i instantly vanishes. This is a valid assumption since the time
constant of the electrical system is much smaller than the time constant of the mechanical
subsystem. From (2.4), after we disconnect the power supply the dynamics of the mechanical
subsystem dominate and are governed by the differential equation

J ω̇ + bω = −Kf · sgn(ω) (2.9)

For simplicity if we take b as negligible then for ω > 0, the solution to (2.9) with b = 0 is given
by
Kf
ω (t) = ω0 − (t − t0 ) (2.10)
J

where ω0 denotes the initial velocity before the power supply was disconnected at instant t = t0 .
Throughout the experiment ω is captured (see Figure 2.4). This is followed by a curve fit to the
linear model (2.10).

Tasks

• Complete the script moment_of_inertia with your previously determined value for Kf and
make sure the parameters in the Calibration section are defined. Identify J by performing
a linear curve fit and (2.10).

26
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

• Compare your results to the values provided in the data sheets in Appendix A.

2.5. Experiment IV: Armature Inductance L


Armature inductance L is a parameter lumping all inductive components in the current path. The
main components consist of self inductance of the armature winding and current filter inductor.
Due to the switched mode operation of the PMDC motor L can be determined from the switched
current and voltage waveform. From (2.5), the dynamics describing the electrical subsystem are

di
L + Ri = v − eA (2.11)
dt

The solution to this differential equation can be obtained assuming unipolar PWM and constant
eA :
  
 − τt Vd −eA − τt
Imin ·e + 1−e , 0 < t ≤ dTsw

 e e
R
i (t) = t−dTsw

t−dTsw
 (2.12)
Imax


 · e− τe − eA
R
1 − e− τe , dTsw < t ≤ Tsw

where τe = L/R is an electrical subsystem time constant. Figure 2.5 shows the values of Imin and
Imax . The non exponential shape of the current waveform in Figure 2.5 will be explained later.
Since eA was assumed constant, this implies constant average armature current. This in turn
requires zero average voltage drop across the inductor. In order to comply with these assumptions

Vd
Imin

Imax

0
dTs Ts 2Ts 3Ts 4Ts t

Figure 2.5.: PWM voltage and current waveforms.

27
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

d has to satisfy
eA + iR
d= (2.13)
Vd

Now, the ripple of the armature current can be computed

∆Ipp = Imax − Imin , (2.14)

where

Vd − eA
 
− dTτsw dTsw
Imax = Imin · e e + 1 − e− τe (2.15)
R 
eA

− Tsw −dT sw − Tsw −dT sw
Imin = Imax · e τ e − 1−e τe . (2.16)
R

It can be shown that the maximum ripple ∆Ippm occurs if d = 1/2. In this case the ripple current
is given by
Tsw
Vd 1 − e− 2τe
∆Ippm = · . (2.17)
R 1 + e− T2τswe

In practical applications (2.17) can be simplified because the PWM switching frequency is chosen
such that Tsw < τe . Then the maximum ripple current is given as

Vd Tsw
∆Ippm = (2.18)
4L

The relation Tsw < τe is also the reason for the triangular current waveform in Figure 2.5. Suffi-
ciently high switching frequency ensures that the current stays within the linear region of the
exponential. The validity of Tsw < τe for our experimental setup can be shown since fsw = 30 kHz:
τe = 3.85 mH
5.26 Ω
= 526 µs, Tsw = 1/fsw = 33.3 µs.

Tasks
• Connect the BNC connection labelled “OSC” on the interface box to a scope to measure
the unfiltered current waveform. Run armature_inductance and measure measure the
∆Ippm and compute L by means of (2.18). The output of “OSC” is a voltage which must
be converted to current in Amps. The gain for this conversion is 0.2 A/V. You must use
this gain when calculating your value for ∆Ippm .
• Compare your result to the armature inductance value provided in the data sheets in

28
2. Lab 2: Modelling a Permanent Magnet DC (PMDC) Motor and Drive

Section A. The external inductor is manufactured by Bourns and has a model number
1130-332K-RC.

2.6. Experiment V: Open-loop Simulation


In this experiment you will simulate the PMDC motor with the parameters you estimated. Two
average models are simulated: one which accounts for the dynamics of the electrical subsystem
and one which neglects them.
Taking the Laplace transform of (2.4) and (2.5) with b = 0, τl = 0 and eliminating I give

Kt sL+R
LJ LJ Kf
Ω(s) = K2
V (s) − K2
. (2.19)
s2 + sR + t
s + sR
2 + LJt s
L LJ L

Since for most motors τe = L/R  1, we obtain an approximate first order model

1 R
Kt Kt2 Kf
Ω(s) = JR V (s) − JR (2.20)
Kt2
s +1 Kt2
s +1 s

Defining the gain KV = 1/Kt and mechanical time constant τm = JR/Kt2 , we can transform
(2.20) into a standard time constant format

R
KV Kt2 Kf
Ω(s) = V (s) − (2.21)
τm s + 1 τm s + 1 s

Tasks
• Collect the velocity response using the script and model from Experiment IV where a
v = 24 V input was applied.
• Implement a Simulink model for the 1st and 2nd order models described above. You can
perform this simulation after the lab and the results will be included in the lab report. Use
a constant input voltage of v = 24 V. You should run these Simulink models from a script
which defines your model parameters.
• Compare these simulation plots with experimental data for the velocity response.
• Compare the open-loop no-load steady state velocity to the one provided in the data sheet
in Appendix A.

29
3. Lab 3: Closed-loop Speed Control
for a PMDC Motor
In this lab we consider two closed-loop velocity controls for the PMDC motor:

• Experiment I: Cascade or current mode control of PMDC motor velocity

• Experiment II: Voltage mode control of PMDC motor velocity

The design method used in this lab involves time domain specification formulas for the transient
response of second order systems and the notion of System Type. The goal is to perform two
control designs for regulating constant velocity references while rejecting constant load torque
disturbances.
Although current mode requires a measurement of armature current, it is a common choice
of velocity control structure for PMDC motors for a number of reasons. It is based on a two
loop controller structure where an inner loop controls current and an outer velocity loop provides
the reference current to the inner loop. Current Mode control is popular since the outer loop
can readily limit the armature current reference fed to the inner loop. This provides a means to
prevent overcurrent situations (e.g. during startup when inertia is large) which can damage the
PMDC drive, motor, and attached loads. The Current Mode control admits a relatively simple
design since two designs are performed on lower order subsystems. As well, controller tuning
is simplified since it is performed subsystem-at-a-time. Moreover the inner current control can
be used to implement torque control of a PMDC motor. Current mode also shows performance
improvement in face of voltage dead-zone which exists in H-bridge amplifiers.

3.1. Experiment I: Current Mode Controller Design


3.1.1. Transfer Function Modeling of the PMDC Motor for Current
Mode Control
The Current Mode control decouples the model into an electrical and mechanical subsystem.
Hence, we present the transfer functions of each subsystem next.

30
3. Lab 3: Closed-loop Speed Control for a PMDC Motor

Electrical Subsystem
The dynamics of the electrical subsystem of the PMDC motor are given by

di
v − eA = R · i + L (3.1)
dt

Taking the Laplace transform of (3.1) assuming zero initial conditions yields

V (s) − EA (s) = RI(s) + sLI(s). (3.2)

For the problem of current control we denote V as the control input, I as the controlled output,
and EA as a disturbance input. Although we measure velocity and therefore could compute
EA , this would complicate the current control. The objective of current control is to regulate a
prescribed reference current I ∗ while rejecting disturbance input EA . Solving for I in (3.2) gives

1 1
I(s) = V (s) − EA (s) (3.3)
sL + R sL + R

For control design we define the transfer function

I(s) K
Pi (s) = = , (3.4)
V (s) τe s + 1

where τe = L/R is the electrical subsystem time constant and K = 1/R the gain of the electrical
subsystem.

Mechanical Subsystem
According to Section 2.1 the dynamics of the mechanical subsystem obey Newton’s Law. Hence,
taking the Laplace transform of (2.4) and assuming the current dynamics are negligible (i.e.,
τe = L/R ≈ 0) yields
Kf
sJΩ(s) = Kt I(s) − − Tl (s) ω > 0. (3.5)
s

Here, Ω is treated as the system output whereas I is the control input. Static friction Kf /s is
assumed to be negligible. Load torque Tl represents an unknown disturbance which should be

31
3. Lab 3: Closed-loop Speed Control for a PMDC Motor

ei v
i∗ Ci Pi i
− −
eA

Figure 3.1.: Inner current control loop with PI controller.

compensated in control design. Using (3.5) we obtain

Kt 1
Ω(s) = I(s) − Tl (s) (3.6)
sJ sJ

The control design for the outer loop is based on the transfer function

Ω(s) Kt
Pω (s) = = . (3.7)
I(s) Js

3.1.2. Inner Loop Current Control with PI controller


To perform current control we choose a Proportional-Integral (PI) control which ensures zero
steady state current tracking error for constant references and provides two control gains which
allow us to satisfy rise time (i.e., bandwidth) and Percent Overshoot (PO) specifications. PO
relates to the relative stability of the closed-loop.
Using the notion of System Type we observe the open-loop transfer function requires at least
one pole at s = 0 to achieve zero steady state error for step reference inputs. A PI control ensures
the system is Type I since its transfer function is

V (s) kp s + ki
Ci (s) = = (3.8)
Ei (s) s

where kp is the proportional gain, ki the integral gain, and ei = i − i∗ denotes current error, where
i∗ is the current reference. Figure 3.1 depicts the current control with PI-controller.

Tasks

• Derive the closed loop transfer function of the current control loop by neglecting the
disturbance and bring it into standard form:

ωn s
αζ
+ ωn2
Hi (s) =
s2 + 2ζωn s + ωn2

32
3. Lab 3: Closed-loop Speed Control for a PMDC Motor

• Identify α, ζ and ωn in terms of ki , kp , K, and τe .



• Design your controller such that ζ = 1/ 2 and ωn = 2π · 1000 rad s−1 .

• Calibrate the current measurement unit as described in Section 1.5.

• Run an experiment with the actual physical system using the same controller and reference
step input. Pick sample time Ts = 50 µs. Important: Current increases fast so take care
that the simulation time is limited to a maximum value of 10 ms. If you do not limit
the simulation time the motor will accelerate until the velocity saturates. This can cause
irreversible damage to the brushes and has to be avoided. Collect and plot experimental
data of the current step response.

• In order to improve the step response PO we reduce the value of ki . Attempt to find a
value of ki which reduces PO to about 10 %.

• Simulate the current control system shown in Figure 3.1 in Simulink using the transfer
function model (3.4). For the controller, use Simulink’s built-in PID block and set the
derivative gain to zero to realize the PI controller. Perform the simulation with a step
i∗ = 1 A. Plot the current response using the same gains as the previous step.

• Introduce a Transport Delay block in front of your transfer function block for Pi . Use a
Time delay value of around 5 · Ts so that the experimental and simulated curves coincide.
The Transport Delay models delay introduced by the control system (i.e., AD and PWM
output delays). Plot the step response using the same gains as the previous step.

• Compare the simulations to the experimental result.

3.1.3. Outer Loop Velocity Control with PI controller


In this section we design a velocity control using an outer velocity feedback loop that generates
the reference current for the inner current loop. The control design taken in this section uses a
PI controller and second order system formulas as in Section 3.1.2. However, unlike Section 3.1.2
here we track constant velocity references while rejecting constant torque disturbances.
A cascade control separates the control problem into two simpler inner and outer loop designs.
It is feasible to separate the inner and outer loop designs in a cascade control since the bandwidth
of the inner loop is designed sufficiently high to make the dynamics of the inner loop negligible
from the point of view of the outer loop. That is, we can model the inner loop as a simple unity
gain (i.e., Hi (s) ≈ 1). In our case the natural frequency ωn of the velocity loop will be chosen 50
times smaller than the one of the current loop.
The PI controller gains for the velocity PI controller

k̄p s + k̄i
Cω (s) =
s

33
3.
3. Lab
Lab 3:
3: Closed-loop
Closed-loop Speed Control for
Speed Control for aa PMDC
PMDC Motor
Motor

τl

e i∗ i τe −
ω ∗ Cω Hi (s) ≈ 1 Kt 1/(Js) ω

Figure 3.2.: Outer velocity control loop.


Figure 3.2.: Outer velocity control loop.

The PI controller gains for the velocity PI controller


are denoted k̄p and k̄i . Figure 3.2 depicts the closed-loop velocity control system. Ω∗ is the
Laplace transform of the reference speed ω ∗ .
k̄p s + k̄i
Cω (s) =
s
Important note: The following designs should be carefully saved for future labs where you will
be required to reuse the designs.
are denoted k̄p and k̄i . Figure 3.2 depicts the closed-loop velocity control system. Ω∗ is the
Laplace transform of the reference speed ω ∗ .
Tasks

• Derive note:
Important The loop
the closed following designs
transfer should
function be carefully
of the velocity saved
controlforloop
future labs whereHyou
by assuming i (s) will
=1
be required to reuse the
and neglecting the designs.
disturbance torque. Bring it into standard form

ωn s
Tasks + ωn2
Hω (s) = 2 αζ
+ 2ζω
• Derive the closed loop transfer function ofsthe velocity ωn2
n s + control loop by assuming Hi (s) = 1
and neglecting the disturbance torque. Bring it into standard form
• Identify α, ζ and ωn in terms of k̄p , k̄i , Kt , and J.
ωn s 2
√ αζ + ωn
Hωζ(s)
• Design the PI controller such that == 1/ 22 and ωn = 2π2 · 25 rad s−1 .
s + 2ζωn s + ωn
• Simulate the velocity control system shown in Figure 3.2 with Hi (s) = 1 in Simulink
using the transfer function model (3.7). For the controller, use the PID block and set the
• Identify α, ζ and ωn in terms of k̄p , k̄i , Kt , and J.
derivative gain to zero to realize the PI controller. Perform the simulation with a step
∗ √
• ω
Design the
= 200 PIs−1
rad controller
. Plot thesuch that ζresponse.
velocity = 1/ 2 and ωn = 2π · 25 rad s−1 .
•• Implement
Simulate the thevelocity
completecontrol
cascadesystem shown
control in Figure
system 3.2 with Combine
in experiment. Hi (s) = 1thein PI velocity
Simulink
using the transfer function model (3.7). For the controller, use the PID block and set3.1.2.
controller used in the previous item with the PI current control designed in the Section the

derivativethe
Perform gain to zero towith
experiment realize theωPI
a step 200 rad s−1 .Perform
=controller. the simulation
Superimpose with
the velocity a step
response
ω ∗ = the
with rad s−1 . Plot
200 simulated onethe
on velocity response.
a time scale which shows the transient performance. Comment
on any differences in velocity tracking performance relative to the previous item.
• Implement the complete cascade control system in experiment. Combine the PI velocity
controller the
• Compute usednumerical
in the previous item
value of α. with
Whatthe PIyou
can current controlthe
say about designed
impactinofthe
theSection
zero on3.1.2.
the
Perform
PO in thethe experiment
step response?with a step ω = 200 rad s . Superimpose the velocity response
∗ −1

33
34
3. Lab 3: Closed-loop Speed Control for a PMDC Motor

• Design an input feed forward filter that cancels the zero of the velocity control loop transfer
function. Its transfer function is given as follows:

ωn2
ωn s
αζ
+ ωn2

Now add this feed forward filter to your control system model in Simulink and repeat the
simulation. Provide a plot of the velocity step response.

• Test your velocity control system with feed-forward filter in an actual experimental setup.
Pick Ts = 50 µs. Collect and plot data of two velocity step responses with ω ∗ = 200 rad s−1
and ω ∗ = 500 rad s−1 and compare it to your previously obtained simulation result.

3.2. Experiment II: Voltage Mode Controller Design


In this section we design a Voltage Mode velocity control system with the same performance
requirements as in the Current Mode design. Unlike Current Mode velocity control Voltage Mode
does not split the system into two parts and no current measurement is required. In Voltage
Mode the control is based on the approximate first order transfer function model of the PMDC
motor derived in Section 2.6 in Lab 2, and only one control loop is required. We recall this model
as
R
KV Kt2 Kf
Ω(s) = V (s) − (3.9)
τm s + 1 τm s + 1 s

We assume Kf = 0. In (3.9) KV = 1/Kt and τm = JR/Kt2 . From (3.9) the transfer function
model is obtained:
Ω(s) KV
Pω,V (s) = = (3.10)
V (s) τm s + 1

Figure 3.3 shows the closed-loop velocity control system in Voltage Mode. Unlike in Current
Mode, here the PI controller
kp0 s + ki0
Cω,V (s) =
s

with proportional gain kp0 and integral gain ki0 directly generates a voltage that is fed to the motor.

Important note: The following designs should be carefully saved for future labs where you will
be required to reuse the designs.

35
3. Lab 3: Closed-loop Speed Control for a PMDC Motor

τl KRt

e v
ω∗ Cω,V Pω,V ω

Figure 3.3.: Voltage Mode velocity control system.

Tasks

• Derive the closed loop transfer function of the velocity control loop shown in Figure 3.3 by
neglecting the disturbance torque. Bring it into standard form

ωn s
αζ
+ ωn2
Hω,V (s) =
s2 + 2ζωn s + ωn2

and identify α, ζ and ωn in kp0 , ki0 , τm , and KV .

• In order to compare with the Current Mode design take the gains of the PI controller kp0

and ki0 such that ζ = 1/ 2 and ωn = 2π · 25 rad s−1 .

• Implement and simulate the velocity control system


ωn s shown
2 in Figure 3.3 in Simulink
using the transfer function model (3.9). For theαζ + ω n use the PID block and set the
controller,
H ω,V (s) =
derivative gain to zero to realize the PI controller.
s2 + 2ζωPerform
n s + ωn
2the simulation with a step
ω ∗ = 200 rad s−1 .

• Compute α and provide a solution to minimize the PO. Implement it in Simulink and run
and identify
theα, ζ and again.
simulation ωn inCould
kp0 , kthe
0
i , τm
PO, and KV . and why?
be minimized

• In order •toRun
compare withwith
an experiment thethe
Current Modesystem
actual physical design take
using the controls
the same gains of andthe PI controller
reference
step inputs. √
Pick T = 50 µs. Collect and plot experimental data of the step response.
and ki0 suchCompare
that ζyour 2 and ω .
rad s−1results
s
= 1/
experimental n = to
results · 25
2πthe simulation from the previous task.

• Implement• Inand
a lastsimulate thethevelocity
step compare control
experimental systemfrom
results obtained shown in Figure
the Voltage 3.3 in Simuli
Mode velocity
using the transfer function model (3.9). For the controller, use the PID block and set t
control to the ones from the Current Mode velocity control.

derivative gain to zero to realize the PI controller. Perform the simulation with a st
ω ∗ = 200 rad s−1 .
• Compute α and provide a solution to minimize
36 the PO. Implement it in Simulink and r
the simulation again. Could the PO be minimized and why?
4. Lab 4: Disturbance Rejection and
Advanced PI Control
This lab includes three experiments which investigate
• a motor-generator setup where the generator applies a controlled load torque. We investigate
the disturbance rejection performance of a closed-loop motor velocity control.
• an advanced PI control for velocity which reduces the negative effect of a saturated PI
controller.
• a position controller which is based on the velocity controls you performed in Lab 3.

4.1. Experiment I: Load Torque Disturbance Rejection of


Closed-loop Velocity Control
In this Experiment we consider a motor-generator setup shown in Figure 4.1 where we can study
the load torque disturbance rejection performance of the PMDC motor under closed-loop velocity
control. The PMDC generator is directly coupled to the PMDC motor shaft and enables us to
apply a controlled load torque profile. To get a specific load torque we use a closed-loop current
control. That is, from (3.4) we recall the transfer function from voltage to current

I(s) K
Pi (s) = = , (4.1)
V (s) τe s + 1

Neglecting frictional torque in the generator and using τl = Kt · i we have

Tl (s) Kt K
Pτl (s) = = (4.2)
V (s) τe s + 1

The generator is an identical copy of the PMDC motor but without an attached encoder. Hence,
its plant parameters are the same as those of the PMDC motor determined in Lab 2.

Tasks

37
4. Lab 4: Disturbance Rejection and Advanced PI Control

Coupling

Motor

Generator

Encoder

Figure 4.1.: The PMDC motor-generator system.

• Write down the closed-loop disturbance to velocity transfer function into a form

Ω (s) As
Hd (s) = = 2 (4.3)
Tl (s) s + 2ζωn s + ωn2

Use the current mode control you derived in Section 3.1.3 where the dynamics of the current
loop are neglected. Express ωn , ζ, A in terms of Kt , J, k̄i , k̄p .
• What is the System Type relative to the disturbance input τl ?
• When determining your k̄p and k̄i use the same design as in Section 3.1.3 but take twice
the inertia used there to model combined inertia of the PMDC motor-generator. Compute
mp , tp , and ts .
• Simulate the velocity control system with a step load torque disturbance. You can ignore
the inner loop current control in your simulation.
Take a pulse waveform load torque disturbance with amplitude of 35.2 mN m (1 A), frequency
0.1 Hz, and 50 % duty cycle. In the Pulse Generator settings use a Phase delay of 5 s
to allow the motor to reach a steady-state velocity before a load torque is applied. Use a
reference velocity of 300 rad s−1 . Record the output velocity and current waveforms. Also,
determine settling time, peak time, and minimum value of the velocity response.
• Use the current control you designed in Section 3.1.2 to implement a torque control loop
for the generator system. No modifications to your design is required since τe and K are
the same as in the PMDC motor.
• Run the experiment under the same conditions as the simulation. Extract settling time,
peak time, and minimum value from the velocity response. Compare the results with the
simulation.

38
4. Lab 4: Disturbance Rejection and Advanced PI Control

4.2. Experiment II: Anti-Windup PI (Optional)


In this lab we investigate the use of feedback to reduce the negative effect of saturation in PI
control. This saturation often occurs in practice as actuators and plants usually operate on a
limited range of signals. For example, in our lab the voltage supply for the H-bridges is limited
and this affects the transient performance of a PI current control in the case of large current
references. Consider the closed-loop system shown in Figure 4.2 with saturated PI control and a
plant which contains a delay. A PI controller saturates after being exposed to an error signal
whose average value has not changed its sign for a long period. Typically system delays can cause
such problems. In such a situation the magnitude of the integrator output will grow or windup.
During this windup, the increase in controller output u is not useful since the input to the plant
us stays constant. This state of operation can be considered open-loop since changes in e do not
affect the value of us . Only when the sign of the error signal changes will the magnitude of the
integrator output ui reduce. If the saturation lasted a long time, it can take considerable time
for the integrator to recover and operate below the saturation limits. The problem of windup
leads to transient responses with longer periods of PO and longer settling time. A comparison of
closed-loop step responses for a saturated and unsaturated PI Control is shown in Figure 4.3.
An anti-windup control method reduces the effect of windup on system performance. Many
anti-windup methods have been proposed and we focus on the “tracking” anti-windup scheme.
This method is built into Simulink’s Proportional-Integral-Derivative (PID) block and called
the “back calculation” method. The block diagram of the tracking anti-windup scheme is shown
in Figure 4.4. The basic idea is to limit how deep the controller goes into saturation by adjusting
the integrator input as a function of the degree of saturation which is measured by the difference
u − us . This difference is fed back to the integrator input though a gain ka .
As in Experiment I we use the PMDC motor-generator setup. The velocity of the motor is
controlled in closed-loop. We investigate the use of anti-windup to improve the transient velocity
response of the motor. In particular we reduce PO which is caused by windup.

Tasks
• Edit your Simulink model from Experiment I to include antiwindup in the velocity PI
controller for the motor. Follow the block diagram in Figure 4.4.
• Take a constant load disturbance of i∗ = 1 A for the generator (i.e., rated load for the

ei u us
i∗ PI e−sTtot Pi i
− −
eA

Figure 4.2.: Block diagram of saturated PI control with plant containing a delay.

39
4. Lab 4: Disturbance Rejection and Advanced PI Control

2
Unsaturated
1.5 Saturated
i (A)

1
0.5
0
18 19 20 21 22 23 24 25 26
80
Unsaturated
60 Saturated
uI (V)

40
20
0
18 19 20 21 22 23 24 25 26
60
Unsaturated
us − u (V)

40 Saturated

20

0
18 19 20 21 22 23 24 25 26
t (ms)

Figure 4.3.: Closed-loop step responses of saturated and unsaturated PI controller. The saturated
controlled shows the characteristic of integrator windup: longer periods of overshoot and longer
settling time.

motor). Use a 2 A saturation level for your anti-windup velocity PI controller. Use a step
input reference for motor velocity which starts at 100 rad s−1 and moves to 400 rad s−1 at
t = 1 s.

• Calibrate the current measurement unit as described in Section 1.5.

• Run the experiment with an anti-windup gain ka = 0. Then run with ka = ki initially, and
tune ka to optimize the transient velocity response PO to about zero.
Once you have tuned the anti-windup scheme plot the following responses for both the
ka = 0 and tuned ka cases: the velocity response, integral (I) component of the controller
output ui , and the difference across the saturation block u − us . Combine the three graphs

40
4. Lab 4: Disturbance Rejection and Advanced PI Control

uP
kp
ei u us
1
uI
ki s

ka

Figure 4.4.: Block diagram of tracking anti-windup control.

into a single figure using the subplot.

4.3. Experiment III: Motor Position Control and Load


Torque Disturbance Rejection
In this experiment we design a closed-loop motor position control. This design will use the
Current and Voltage Mode velocity controllers designed in Lab 3. As in previous experiments we
use the PMDC generator to investigate the load torque disturbance rejection performance. The
position loop control adds an additional stage to the cascade structure. We choose a Proportional
(P) control for the position loop.

τl

τ
P ω Pθ θ


i∗ ω∗ e
Kt · Hi Hω C θ∗

Figure 4.5.: Block diagrams of cascade position control based on Current Mode velocity controllers.

If we assume the inner loops are tracking their references perfectly, the position control is based
on single integrator model
Θ(s) 1
Pθ (s) = = (4.4)
Ω(s) s

41
4. Lab 4: Disturbance Rejection and Advanced PI Control

Hence, a simple P control provides a closed-loop transfer function

Θ(s) 1
Hθ (s) = ∗
= (4.5)
Θ (s) 1 + s/kp

which has a DC gain of 1 for perfect step reference tracking and a bandwidth of kp . We choose
kp = 2π · 5 for a bandwidth of 5 Hz.

Task

• Verify your position controls in experiment. Use the Current Mode Design you performed
in Lab 3, Section 3.1. This controller was used in Experiment I of this lab. Use a pulse
waveform position reference with amplitude of 30°, frequency 1 Hz, and 50 % duty cycle.
Use the load torque controller you designed in Experiment I of this lab to apply a torque
disturbance to the PMDC motor shaft. For a reference torque use a pulse waveform with
amplitude of 35.2 mN m (1 A), frequency 0.1 Hz, and 50 % duty cycle. Provides plots of θ,
current i, and velocity ω.

42
5. Lab 5: Controlling the Ball and
Beam using Root Locus and
Frequency Domain Methods
5.1. Transfer Function Modeling of the Ball and Beam
The Ball and Beam system is shown in Figure 5.1. It consists of a two link mechanism which is
coupled to the PMDC motor. We refer to the link of length `1 as the “Beam” on top of which a
steel ball can roll. One side of the beam is attached to a fixed support which allows the beam
to rotate in a vertical plane. We define the angle of rotation as α. The purpose of the Ball and
Beam system is to control the position ξ of the ball on the beam by varying motor shaft position
θ. This is possible since one end of the second link of length `2 is attached to the shaft of the
PMDC motor. The other end of the second link is connected to the Beam. Hence, by varying
motor shaft position θ we can vary α. Non-horizontal beam configurations α 6= 0 imply gravity
acts on the ball and this allows us to control its motion.
In this section we derive a transfer function model of the Ball and Beam. We treat the system
input as motor position θ and ball position ξ as the system output. Effectively we take an two
loop controller structure as in Current Mode control in 3. But here ball position ξ is the outer
loop output and θ is the inner loop output (and outer loop input). For the inner loop we chose
the Current Mode position controller from 4 to track θ.
Neglecting friction between the ball and beam, Conversation of Energy gives

V = Kt + Kr , (5.1)

where V is potential energy of the ball due to gravity, Kt is translational kinetic energy of the
ball, and Kr is rotational kinetic energy of the ball. Using (5.1) we have

1 1
mg ξ sin α = mv 2 + Jb ω 2 (5.2)
| {z } |2 {z } |2 {z }
V Kt Kr

where m is mass of the ball, g is gravitational acceleration, ξ is the ball position on the beam,
v = ξ˙ is velocity of the ball’s center of mass, Jb is moment of inertia of the ball and ω is angular

43
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

ℓ1
ξ
α
Beam
y
b
ℓ2
Beam support

a
r θ
x
Gear

Figure 5.1.: Ball and Beam setup with geometric quantities.

velocity of the ball. We define ξ = 0 at the middle of the beam. Since the ball rotates without
slipping ω = v/R where R is the radius of the ball.
Differentiating (5.2) with respect to ξ yields the force equation

!
Jb dv 2
mg sin α = m + 2 (5.3)
R dξ

Applying the chain rule gives


!
Jb dv
mg sin α = m + 2 v , (5.4)
R dξ

where the differential dξ can be rewritten as dξ = v dt. Substituting this into (5.4) yields

!
Jb ¨
mg sin α = m + 2 ξ. (5.5)
R

ξ¨ is the acceleration of the ball’s center of mass. We remark mg sin α corresponds the component
of gravitational force in ξ-direction.

44
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

Since the control input to the ball-beam system is the rotational position of the motor shaft θ,
we require a relation between beam angle α and θ. To achieve this we use the (x, y)-coordinate
system shown in Figure 5.1. We define a vector to the position where the beam assembly attaches
to the gear and a vector b which points to the end of the beam. We have

a = (r cos θ, r sin θ)T (5.6)


 T
b = r + l1 (cos α − 1) , l2 + l1 sin α (5.7)

Since the mechanical system is rigid we have the constraint

ka − bk2 = l22 (5.8)

q
where kpk = p21 + p22 , p = (p1 , p2 ) ∈ R2 denotes the Euclidean norm. Combining (5.6) - (5.8)
yields an expression relating α to θ:

l12 − l1 r + r2 + l1 (r − l1 ) cos α − l1 r cos(α − θ)+


r (l1 − r) cos θ + l1 l2 sin α − l2 r sin θ = 0 (5.9)

The expression (5.9) can be solved for α and is nonlinear in θ. To obtain a linear model we derive
an approximate linear relationship using a small angle assumption sin θ ≈ θ and cos θ ≈ 1:

r
α= θ (5.10)
l1

We take the same small angle approximation in (5.5) to obtain

!
Jb
mgα = m + 2 ξ¨ (5.11)
R

Substituting (5.10) into (5.11) yields the equation of motion for the system output ξ in terms of
the system input θ:
mgr
ξ¨ =  θ (5.12)
l1 m + RJb2

45
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

m 65.9 g
g 9.81 m s−2
`1 42.5 cm
R 1.27 cm
r 1.27 cm

Table 5.1.: Ball and Beam model parameters.

Finally, the transfer function between Ξ (s) and Θ (s) is obtained as

Ξ(s) mgr 1 Kbb


Pbb (s) = =  
2
= 2 . (5.13)
Θ(s) J
l1 m + R2 s
b s

Table 5.1 contains the parameters of the Ball and Beam system. Note that the inertia of a ball
about its centre is Jb = mR2 2/5

5.2. Experiment I - Lead Controller Design for Ball


Position using Root Locus
In this section we design a ball position control for the Ball and Beam using a lead controller and
the root locus method. We model the inner motor position loop as a first order stable transfer
function with unity DC gain:
Θ(s) 1
Pθ (s) = ∗
= (5.14)
Θ (s) τθ s + 1

Since the bandwidth of the motor position loop was designed to be 5 Hz we take 1/τθ = 2π·5 rad s−1 .
In the experimental validation of our design we use the current mode-based inner motor position
loop (5.14) designed in Lab 4, Section 4.3. The closed-loop system used for design is shown in
Figure 5.2. Later in Experiment II, Section 5.3 we repeat the control design for Ball and Beam

e θ∗ 1 θ
ξ∗ C Pθ = τθ s+1 Pbb ξ

Figure 5.2.: Cascaded ball position control system (velocity and current loop not shown).

46
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

position using a frequency response method.


As shown in the previous section, the Ball and Beam system is modeled by the double integrator
transfer function (5.13). Since (5.13) is unstable and has a zero phase margin, it is natural that
we choose a lead controller to add phase and provide sufficient stability margin and closed-loop
bandwidth.
We recall the transfer function of the lead controller

1 + τ αs s−z
C(s) = K = αK = K̄ C̄(s), α > 1, τ, K > 0 (5.15)
1 + τs |{z} s−p

where we have defined C̄(s) = s−z


s−p
, the lead controller pole p = −1/τ and zero z = −1/(ατ ) of
C. It is useful to think of controller (5.15) as a low pass filtered PD control. A lead controller
provides improved system bandwidth and stability margin. Its design involves a trade-off between
both these performance measures. The controller C provides a maximum phase of

α−1
φm = arg(C(jωm )) = arcsin
α+1

which occurs at
1
ωm = √ . (5.16)
ατ

At frequency ωm the magnitude of C/K is


|C(jωm )/K| = α

The bode magnitude and phase plots are shown in Figure 5.4.

Tasks
• We use root locus design to place a pair of complex conjugate dominant closed-loop poles at
a desired location. These two poles will determine the response of the closed-loop system.
Clearly, the closed-loop system is 4th order and it is therefore essential that we verify the
two remaining poles be either canceled by a zero or be far into the LHP (i.e., fast). We
choose the dominant pole pair to have the following parameters
– a damping ratio ζ = 0.7
– and natural frequency ωn = 1.2 rad s−1 .
Determine the real and imaginary parts of these poles. We remark that ωn = 1.2 rad s−1 is
chosen sufficiently lower than the inner motor position loop bandwidth of 5 Hz.

47
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

30
26
20 · log α
C(s) / dB

20

20 · log α
13
10

0
90

ωm
arg(C(s)) / °

60

30 φm

z p
0
10−3 10−2 1
ατ
10−1 √1
ατ
1
τ
101 102
ω / rad s−1

Figure 5.3.: Bode plots of a lead controller with α = 20.

We choose the zero of (5.15) as z = −1/(ατ ) = −1/2 which pulls the uncompensated root
locus sufficiently far into the LHP. This leaves the design of the pole p = −1/τ and gain K
of C to be determined.
The design method ensures that a pair complex conjugate closed-loop poles lies on the
system’s root locus. This is guaranteed by using the phase condition

arg(C(s) · Pbb (s) · Pθ (s)) = 180° + 360°(l − 1), l∈Z (5.17)

48
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

Im

sd
Im(sd)

𝜙 (2)
Re
-1/𝜏𝜃 p r1 z

r2

Figure 5.4.: Geometry of the phase contribution of p in the s-plane.

Since

arg(C(s) · Pbb (s) · Pθ (s)) = arg(C(s)) + arg(Pbb (s) · Pθ (s))


= arg(s − z) − arg(s − p) + arg(Pbb (s) · Pθ (s)) ,

we require the phase contribution φ = arg(s − p) from the pole of C to satisfy (5.17). Hence,

φ = −180° − 360°(l − 1) + arg(sd − z) + arg(Pbb (sd ) · Pθ (sd )) (5.18)

where sd denotes the desired pole location. Use (5.18) to determine a value for φ.

• Use φ = arg(s − p) to determine p from φ.

• Use the magnitude condition to determine the lead controller gain. That is

¯ = 1
K̄ (5.19)
|Pθ (sd ) · Pbb (sd ) · C̄(sd )|

The lead controller is therefore


s−z
C(s) = K̄
s−p

49
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

• Compute the root locus of the system and verify that your root locus passes through the
point sd . Compute the closed-loop poles and zeros. Are the poles at sd dominant? Use
Matlab’s rltool command and related features to execute this task. For example to obtain
a root locus of L(s) = 1/(s + 1) we use the command
s=t f ( ’ s ’ ) ;
r l t o o l ( 1 / ( s +1) )

• Compute the closed-loop output step response of the system by simulation. Use the first
order system Pθ to simulate the inner motor position control loop. Use a step reference
input of amplitude 0.1 m.
Collect trajectories for the ball position ξ, reference ball position ξ ∗ , and motor position θ.

• Determine the stability margins of your design.

• Using the same model as in the simulation, implement your design in experiment and obtain
the output step response for the same reference used in simulation above. Use the current
mode-based inner motor position loop (5.14) designed in Lab 4. For safety, add a ±75°
saturation block after you lead controller to limit the motor angle reference.
Provide plots of ball position ξ, desired ball position ξ ∗ , motor position θ, voltage input
v, and current i. Superimpose your simulation results for ξ and θ on your experimental
results.
Use subplot to plot your graphs on one figure and superimpose your experimental graphs
on those obtained in simulation.

5.3. Experiment II - Lead Controller Design for Ball


Position Using the Frequency Response Method
The objective of this section is to perform a lead controller design using the Frequency Domain
Method for ball position of the Ball and Beam. In the experimental validation of our design we
use the current mode-based inner motor position loop (5.14) designed in Lab 4, Section 4.3.

Tasks

• Perform a lead controller design with these performance specifications:


– Crossover frequency of ωcg = π · 1 rad s−1 .
– Phase margin of PMd = 35°.
When performing your design place the frequency ωm where C provides maximum phase at
the gain crossover frequency ωcg (i.e., ωm = ωcg ). Our design assumes the motor position
loop is modelled by a first order unity gain transfer function Pθ , as in Experiment I.

50
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

The design is performed by considering the definition of the desired phase margin

PMd = arg(Pbb (jωcg ) · Pθ (jωcg ) · C(jωcg )) + 180° (5.20)

where ωcg satisfies


|Pbb (jωcg )Pθ (jωcg )C(jωcg )|2 = 1 (5.21)

The procedure to compute the lead controller uses (5.20) with PMd = 35° and ωcg =
π · 1 rad s−1 and the constraint ωm = ωcg . We obtain

α−1
arcsin − arctan(τθ ωcg ) = PMd = 35° (5.22)
α+1

The relation (5.22) determines a value for α. Next, from (5.21) we can compute K since

Kbb 1 √
|Pbb (jωcg )Pθ (jωcg )C(jωcg )| = 2
q K α=1 (5.23)
ωcg τθ2 ωcg
2 +1

• Validate your design by plotting the Bode magnitude and phase of C · Pbb Pθ . Show the
phase margin is obtained. To perform this step use the Matlab command tf and bode.
For example you can obtain the bode plots of 1/(s + 1) using
s=t f ( ’ s ’ ) ;
bode ( 1 / ( s +1) ) ;

Once the Bode plot appears in the figure window, you can right click and choose
Characteristics → All Stability Margins.

• Determine the closed-loop bandwidth using the Matlab command bandwidth. How does
it compare with the crossover frequency?

• Use Simulink to implement the closed-loop position control system for the Ball and Beam.
Use a step reference input of 10 cm and plot the closed-loop step response.
Provide plots of ball position ξ, reference ball position ξ ∗ , and motor position θ. Use
subplot to plot your graphs on one figure.

• Create a Simulink model to validate your design experimentally. We use the motor position
control from Lab 4 as an inner loop. We suggest that you confirm the operation of this
motor position control before you add your Ball and Beam position control outer loop.
Obtain the output response for the same reference input as in the previous item.

51
5. Lab 5: Controlling the Ball and Beam using Root Locus and Frequency Domain Methods

Provide plots of ball position ξ, desired ball position ξ ∗ , motor position θ, voltage input v, and
current i. Use subplot to plot your graphs on one figure and superimpose your experimental
graphs on those obtained in simulation. Compare the simulated and experimental responses.

52
A. Appendix: Datasheets
A.1. A-max 32 motor

53
-max 32 ∅32 mm, Graphite Brushes, 20 Watt
High Power
maxon -max

M 1:2
Stock program Part Numbers
Standard program
Special program (on request)

with terminals 236666 236667 236668 236669 236670 236671 236672


with cables 353236 353237 301030 353239 353240 353241 353242
Motor Data
Values at nominal voltage
1 Nominal voltage V 6 9 12 24 30 36 42
2 No load speed rpm 4880 5000 4670 6460 6160 5860 5650
3 No load current mA 123 84.2 58.2 42.8 32.3 25.3 20.8
4 Nominal speed rpm 3400 3480 3170 5060 4740 4430 4210
5 Nominal torque (max. continuous torque) mNm 44.5 43.1 44 45.5 45.1 45.4 45
6 Nominal current (max. continuous current) A 3.96 2.62 1.87 1.33 1.01 0.804 0.659
7 Stall torque mNm 153 146 140 212 197 189 178
8 Starting current A 13.2 8.57 5.77 6.02 4.27 3.24 2.54
9 Max. efficiency % 80 81 81 84 83 83 83
Characteristics
10 Terminal resistance Ω 0.454 1.05 2.08 3.99 7.02 11.1 16.6
11 Terminal inductance mH 0.0601 0.13 0.264 0.556 0.954 1.52 2.22
12 Torque constant mNm/A 11.6 17 24.3 35.2 46.1 58.2 70.4
13 Speed constant rpm/V 825 562 394 271 207 164 136
14 Speed / torque gradient rpm/mNm 32.4 34.8 33.8 30.8 31.6 31.3 31.9
15 Mechanical time constant ms 15 14.9 14.7 14.6 14.6 14.6 14.7
16 Rotor inertia gcm2 44.2 40.8 41.7 45.3 44.2 44.6 43.8

Specifications Operating Range Comments


Thermal data n [rpm] Continuous operation
17 Thermal resistance housing-ambient 7.5 K/W In observation of above listed thermal resistance
18 Thermal resistance winding-housing 2.1 K/W 20
6000 (lines 17 and 18) the maximum permissible winding
19 Thermal time constant winding 17.8 s 236670
temperature will be reached during continuous op-
20 Thermal time constant motor 521 s
21 Ambient temperature -20…+85°C eration at 25°C ambient.
4000
22 Max. permissible winding temperature +125°C = Thermal limit.

Mechanical data (ball bearings) 2000 Short term operation


23 Max. permissible speed 6000 rpm The motor may be briefly overloaded (recurring).
24 Axial play 0.12 - 0.22 mm
25 Radial play 0.025 mm 20 40 60
26 Max. axial load (dynamic) 7.6 N Assigned power rating
27 Max. force for press fits (static) 110 N 0.5 1.0 1.5
(static, shaft supported) 2000 N
28 Max. radial load, 5 mm from flange 32 N

Mechanical data (sleeve bearings) maxon Modular System Overview on page 20–25
23 Max. permissible speed 6000 rpm
24 Axial play 0.12 - 0.22 mm Planetary Gearhead Encoder MR
25 Radial play 0.012 mm ∅32 mm 256 - 1024 CPT,
26 Max. axial load (dynamic) 5.0 N 0.75 - 6.0 Nm 3 channels
27 Max. force for press fits (static) 110 N Page 272–277 Page 320
(static, shaft supported) 2000 N Spur Gearhead Encoder HED_ 5540
28 Max. radial load, 5 mm from flange 10.5 N ∅38 mm 500 CPT,
0.1 - 0.6 Nm 3 channels
Other specifications Page 282 Page 326/327
29 Number of pole pairs 1 Spindle Drive
30 Number of commutator segments 13 ∅32 mm Recommended Electronics:
31 Weight of motor 240 g Page 301–303 ESCON 36/2 DC Page 342
ESCON Module 50/5 343
Values listed in the table are nominal. ESCON 50/5 344
Explanation of the figures on page 79. ESCON 70/10 344
EPOS2 24/2 350
Option EPOS2 Module 36/2 350
Sleeve bearings in place of ball bearings EPOS2 24/5, EPOS2 50/5 351
EPOS2 P 24/5 354
EPOS3 70/10 EtherCAT 357
MAXPOS 50/5 360
Notes 22
144 maxon DC motor April 2014 edition / subject to change
A. Appendix: Datasheets

A.2. HEDL 5540 Encoder

55
Encoder HEDL 5540 500 CPT, 3 Channels, with Line Driver RS 422
Cycle C = 360°e
Pulse P = 180°e

UHigh

maxon sensor
Channel A
ULow
Phase shift 90°e
UHigh
Channel B
ULow
UHigh
Channel I
ULow
s3 s4 s1 s2 s 1..4 = 90°e
∆ s < 45°e

Direction of rotation cw (definition cw p. 78)


Stock program Part Numbers
Standard program
Special program (on request)
110512 110514 110516
Type
Counts per turn 500 500 500
Number of channels 3 3 3
Max. operating frequency (kHz) 100 100 100
Max. speed (rpm) 12 000 12 000 12 000
Shaft diameter (mm) 3 4 6

overall length overall length

maxon Modular System


+ Motor Page + Gearhead Page + Brake Page Overall length [mm] / • see Gearhead
RE 25 107/109 75.3
RE 25 107/109 GP 26/GP 32 270/272 •
RE 25 107/109 KD 32, 1.0 - 4.5 Nm 281 •
RE 25 107/109 GP 32, 0.75 - 6.0 Nm 273/276 •
RE 25 107/109 GP 32 S 301-303 •
RE 25, 20 W 108 63.8
RE 25, 20 W 108 GP 26/GP 32 270/272 •
RE 25, 20 W 108 KD 32, 1.0 - 4.5 Nm 281 •
RE 25, 20 W 108 GP 32, 0.75 - 6.0 Nm 273/276 •
RE 25, 20 W 108 GP 32 S 301-303 •
RE 25, 20 W 108 AB 28 372 94.3
RE 25, 20 W 108 GP 26/GP 32 270/272 AB 28 372 •
RE 25, 20 W 108 KD 32, 1.0 - 4.5 Nm 281 AB 28 372 •
RE 25, 20 W 108 GP 32, 0.75 - 6.0 Nm 273/276 AB 28 372 •
RE 25, 20 W 108 GP 32 S 301-303 AB 28 372 •
RE 25, 20 W 109 AB 28 372 105.8
RE 25, 20 W 109 GP 26/GP 32 270/272 AB 28 372 •
RE 25, 20 W 109 KD 32, 1.0 - 4.5 Nm 281 AB 28 372 •
RE 25, 20 W 109 GP 32, 0.75 - 6.0 Nm 273/276 AB 28 372 •
RE 25, 20 W 109 GP 32 S 301-303 AB 28 372 •
RE 30, 15 W 110 88.8
RE 30, 15 W 110 GP 32, 0.75 - 4.5 Nm 274 •
RE 30, 60 W 111 88.8
RE 30, 60 W 111 GP 32, 0.75 - 6.0 Nm 272-278 •
RE 30, 60 W 111 KD 32, 1.0 - 4.5 Nm 281 •
RE 30, 60 W 111 GP 32 S 301-303 •
RE 35, 90 W 112 91.7
RE 35, 90 W 112 GP 32, 0.75 - 8.0 Nm 272-279 •
RE 35, 90 W 112 GP 42, 3.0 - 15 Nm 283 •
RE 35, 90 W 112 GP 32 S 301-303 •
RE 35, 90 W 112 AB 28 372 124.3
RE 35, 90 W 112 GP 32, 0.75 - 8.0 Nm 272-279 AB 28 372 •
RE 35, 90 W 112 GP 42, 3.0 - 15 Nm 283 AB 28 372 •
RE 35, 90 W 112 GP 32 S 301-303 AB 28 372 •
Technical Data Pin Allocation Connection example
Supply voltage VCC 5 V ± 10% 1 N.C.
Encoder, Line Driver, DS26LS31

Line receiver
Output signal EIA Standard RS 422 VCC
2 VCC Recommended IC's:
driver used: DS26LS31 2 1 3 GND GND - MC 3486
4 N.C. - SN 75175
Phase shift Φ 90°e ± 45°e 5 Channel A
- AM 26 LS 32
Signal rise time 6 Channel A Channel A
(typically, at CL = 25 pF, RL = 2.7 kΩ, 25 °C) 180 ns 7 Channel B R

Signal fall time 8 Channel B Channel A


9 Channel I (Index)
(typically, at CL = 25 pF, RL = 2.7 kΩ, 25 °C) 40 ns 10 Channel I (Index)
Index pulse width 90°e Channel B

Operating temperature range -40…+100 °C


10 9 Pin type DIN 41651/ R
EN 60603-13 Channel B
Moment of inertia of code wheel ≤ 0.6 gcm2 flat band cable AWG 28
Max. angular acceleration 250 000 rad s-2
Channel I
Output current per channel min. -20 mA, max. 20 mA
R
Option 1000 Counts per turn, 2 Channels Channel I

The index signal Ι is synchronized with channel A or B. Terminal resistance R = typical 120 Ω

April 2014 edition / subject to change maxon sensor 327


A. Appendix: Datasheets

A.3. Current Filter Inductor

57
NT
IA
PL
CO
M High Current Chokes
HS
Ro

1130 Series
Special Features L (µH) DCR Dim. Dim.
• Very high current capacity Part ±20 % Ω I, dc* C D
• Low DCR Number @ 1 KHz Max. (A) Approx. Nom.
• Epoxy coated ferrite bobbin core 1130-1R0M-RC 1.0 0.003 21 0.80 0.081
• VW-1 rated shrink tubing to cover winding 1130-1R2M-RC 1.2 0.003 21 0.80 0.081
1130-1R5M-RC 1.5 0.003 21 0.80 0.081
• Self-leaded
1130-1R8M-RC 1.8 0.003 21 0.80 0.081
• Fixed lead spacing 1130-2R2M-RC 2.2 0.003 21 0.80 0.081
• Center hole for mechanical mounting 1130-2R7M-RC 2.7 0.003 21 0.80 0.081
• Dielectric withstanding voltage: 1130-3R3M-RC 3.3 0.003 21 0.80 0.081
2500 Vrms terminal to shrink tube cover; 1130-3R9M-RC 3.9 0.003 21 0.80 0.081
1000 Vrms terminal to core 1130-4R7M-RC 4.7 0.003 21 0.80 0.081
1130-5R6M-RC 5.6 0.003 21 0.82 0.081
• Operating temperature -55 to +105 °C
1130-6R8M-RC 6.8 0.004 21 0.82 0.081
1130-8R2M-RC 8.2 0.004 21 0.82 0.081
Notes ± 10 %
* Rated current to cause 50 °C max. temperature 1130-100K-RC 10 0.006 17 0.82 0.081
rise and 5 % max. inductance drop 1130-120K-RC 12 0.008 13.5 0.80 0.072
1130-150K-RC 15 0.009 13.5 0.80 0.072
1130-180K-RC 18 0.010 13.5 0.80 0.072
† RoHS Directive 2002/95/EC Jan 27 2003 1130-220K-RC 22 0.011 13.5 0.79 0.064
including Annex. 1130-270K-RC 27 0.012 13.5 0.79 0.064
1130-330K-RC 33 0.017 13.5 0.79 0.064
1130-390K-RC 39 0.022 11.4 0.79 0.057
1130-470K-RC 47 0.024 9 0.79 0.057
1130-560K-RC 56 0.026 9 0.79 0.057
1130-680K-RC 68 0.029 9 0.79 0.057
1130-820K-RC 82 0.032 9 0.79 0.051
1.1
1130-101K-RC 100 0.034 9 0.79 0.051
Max.
1130-121K-RC 120 0.046 7.2 0.79 0.051
1130-151K-RC 150 0.064 5.5 0.77 0.045
1130-181K-RC 180 0.072 5.5 0.77 0.045
0.84
Max. 1130-221K-RC 220 0.080 5.5 0.77 0.040
1130-271K-RC 270 0.110 4.5 0.77 0.040
1130-331K-RC 330 0.122 4.5 0.77 0.040
1130-391K-RC 390 0.169 4 0.77 0.036
0.5 Lead tinned 1130-471K-RC 470 0.187 4 0.77 0.036
to within 1/8" 1130-561K-RC 560 0.205 4 0.77 0.032
of body 1130-681K-RC 680 0.256 2.8 0.77 0.032
1130-821K-RC 820 0.288 2.8 0.77 0.032
1130-102K-RC 1000 0.426 2 0.75 0.029
C 1130-122K-RC 1200 0.426 2 0.75 0.029
1130-152K-RC 1500 0.518 2 0.75 0.025
1130-182K-RC 1800 0.705 1.6 0.75 0.025
1130-222K-RC 2200 1.02 1.3 0.75 0.025
1130-272K-RC 2700 1.14 1.3 0.75 0.023
1130-332K-RC 3300 1.27 1.3 0.75 0.020
D (Dia)
1130-392K-RC 3900 1.67 1 0.75 0.020
0.196 ± 0.016 1130-472K-RC 4700 1.86 1 0.75 0.020
0.236 ± 0.020
“-RC” suffix indicates RoHS compliance.
Note: Major diameter of #8 screw = 0.164 ”

Dimensions: Inches

Tel. (877) 426-8767 • Fax (951) 781-5006


REV. 05/08 [Link] 22.3
A. Appendix: Datasheets

A.4. H-bridge

59
RB-Pol-169

Pololu 20A, 5.5 - 50V Single Motor Controller

This discrete MOSFET H-bridge motor driver enables bidirectional control of one high-power DC
brushed motor. The compact 1.8×1.2-inch board supports a wide 5.5 to 50 V voltage range and is
efficient enough to deliver a continuous 20 A without a heat sink. This version outputs an analog
voltage proportional to the motor current, and an extra control input allows for coasting in addition to
the driving and braking offered by the other Pololu high-power motor drivers.

Overview
The Pololu high-power motor driver is a discrete MOSFET H-bridge designed to drive large DC
brushed motors. The H-bridge is made up of one N-channel MOSFET per leg, and most of the board’s
performance is determined by these MOSFETs (the rest of the board contains the circuitry to take user
inputs and control the MOSFETs). The MOSFET datasheet is available under the “Resources” tab. The
board has an absolute maximum voltage rating of 50 V; higher voltages can permanently destroy the
motor driver. Under normal operating conditions, ripple voltage on the supply line can raise the
maximum voltage to more than the average or intended voltage, so a safe maximum voltage is
approximately 44 V.

Note: Battery voltages can be much higher than nominal voltages when they are charged, so the
maximum battery voltage we recommend is 36 V unless appropriate measures are taken to limit the
peak voltage.

The versatility of this driver makes it suitable for a large range of currents and voltages: it can deliver
up to 20 A of continuous current with a board size of only 1.8" by 1.2" and no required heat sink. With
the addition of a heat sink, it can drive a motor with up to about 32 A of continuous current. The
module offers a simple interface that requires as few as two I/O lines while allowing for both sign-
magnitude and locked-antiphase operation, and an optional third control input unique to this board
allows for coasting. This board also features a current-sensing circuit that measures bidirectional motor
current with a magnitude up to 30 A and outputs an analog voltage.

Integrated detection of various short-circuit conditions protects against common causes of catastrophic
failure; however, please note that the board does not include reverse power protection or any over-
current or over-temperature protection. We recommend you use the integrated current sensor to keep
the driver from delivering more current than it can safely handle.

Using the Motor Driver

Connections
The motor and motor power connections are on one side of the board, and the control connections (5V
logic) are on the other side. The motor supply should be capable of delivering the high current the
motor will require, and a large capacitor should be installed between V+ and ground close to the motor
driver to decrease electrical noise. Two axial capacitors are included and one or both can be installed by
soldering them into the V+ and GND pins (labeled '+' and '-' on the bottom silkscreen) along the long
edges of the board. Such installations are compact but might limit heat sinking options; also, depending
on the power supply quality and motor characteristics, a larger capacitor might be required. There are
two options for connecting to the high-power signals (V+, OUTA, OUTB, GND): large holes on 0.2"
centers, which are compatible with the included terminal blocks, and pairs of 0.1"-spaced holes that can
be used with perfboards, breadboards, and 0.1" connectors.

Warning: Take proper safety precautions when using high-power electronics. Make sure you know
what you are doing when using high voltages or currents! During normal operation, this product can
get hotenough to burn you. Take care when handling this product or other components connected to it.

The logic connections are designed to interface with 5V systems (5.5 V max); the minimum high input
signal threshold is 3.5 V, so we do not recommend connecting this device directly to a 3.3 V controller.
In a typical configuration, only PWMH and DIR are required, but PWML can be used to enable
coasting if both PWML and PWMH are driven low. PWML is pulled high and PWMH is pulled low
internally. The two fault flag pins (FF1 and FF2) can be monitored to detect problems (see the Fault
Flag Table below for more details). The RESET pin, when held low, puts the driver into a low-power
sleep mode and clears any latched fault flags. The V+ pin on the logic side of the board gives you
access to monitor the motor’s power supply or pass it on to low-current devices (it should not be used
for high current). The board also provides a regulated 5V pin which can provide a few milliamps (this
is typically insufficient for a whole control circuit but can be useful as a reference or for very low-
power microcontrollers). This pin can be shorted to VCS to power the current sensor, or VCS can be
supplied with 5 V externally. If the 5V output pin is used to power VCS, it should not be used for any
other purpose as the current sensor will draw close to the limit of the current the 5V pin can supply.
When the current sensor is powered by applying 5 V to VCS, the CS pin outputs 66 mV/A for currents
between -30 and 30 A centered at 2.5 V (typical error is less than 1.5%).

Pinout

PIN Default State Description


This is the main 5.5 – 30 V motor power supply connection, which should
typically be made to the larger V+ pad. The smaller V+ pads along the long
V+ side of the board are intended for power supply capacitors, and the smaller V+
pad on the logic side of the board gives you access to monitor the motor’s
power supply (it should not be used for high current).
This regulated 5V output provides a few milliamps. It can be shorted to VCS
to power the current sensor. This output should not be connected to other
5V (out
external power supply lines. Be careful not to accidentally short this pin to
)
the neighboring V+ pin while power is being supplied as doing so will
instantly destroy the board!
VCS Connect 5 V to this pin to power the current sensor.
GND Ground connection for logic and motor power supplies.
CS ACS714 current sensor output (66 mV/A centered at 2.5 V).
OUTA A motor output pin.
OUTB B motor output pin.
Pulse width modulation input: a PWM signal on this pin corresponds to a
PWMH LOW
PWM output on the motor outputs.
Control input that enables coasting when both PWML and PWMH are low.
PWML HIGH
See the “motor control options” section below for more information.
Direction input: when DIR is high current will flow from OUTA to OUTB,
DIR LOW
when it is low current will flow from OUTB to OUTA.
The reset pin, when pulled low, puts the board into a low-power sleep mode
RESET HIGH
and clears any latched fault flags.
Fault flag 1 indicator: FF1 goes high when certain faults have occurred. See
FF1 LOW
table below for details.
Fault flag 2 indicator: FF2 goes high when certain faults have occurred. See
FF2 LOW
table below for details.

Included Hardware
A 20-pin straight breakaway male header, two 100 uF capacitors, and two 2-pin 5mm terminal
blocks are included with each motor driver. (Note: The terminals blocks are only rated for 15 A; for
higher power applications, use thick wires soldered directly to the board.) Connecting large capacitors
across the power supply is recommended; one way to do it is between the '+' and '-' holes, as shown
below. The four mounting holes are intended to be used with #2 screws (not included).

Motor Control Options


The motor driver can be used in several different modes:

• Sign-magnitude (drive-brake): With PWML disconnected or held high, apply a pulse-width-


modulated (PWM) signal to the PWMH pin. The duty cycle of the PWM controls the speed of the
motor and the DIR pin controls the direction. During the active (high) portion of the PWM, the motor
outputs drive the motor by putting the full V+ voltage across the motor in the direction determined by
the DIR pin; during the low portion of the PWM, the motor outputs brake the motor by shorting both
motor terminals to ground. This means that the motor alternates between drive and brake at the PWM
frequency with the percentage of the driving time determined by the duty cycle.

• Sign-magnitude (drive-coast): Connect the same PWM signal to both the PWMH and PWML
pins. The duty cycle of the PWM controls the speed of the motor and the DIR pin controls the
direction. During the active (high) portion of the PWM, the motor outputs drive the motor by putting
the full V+ voltage across the motor in the direction determined by the DIR pin; during the low portion
of the PWM, the motor outputs are disconnected and the motor is allowed to coast. This means that the
motor alternates between drive and coast at the PWM frequency with the percentage of the driving time
determined by the duty cycle. Drive-coast operation can draw less power than drive-brake operation,
but drive-brake operation can produce a more linear relationship between duty cycle and motor speed.

• Variable braking (brake-coast): With PWMH disconnected or held low, apply a PWM signal to
the PWML pin (the state of the DIR pin has no effect on this mode). During the active (high) portion of
the PWM, the motor outputs brake the motor by shorting both motor terminals to ground; during the
low portion of the PWM, the motor outputs are disconnected and the motor is allowed to coast. This
means that the motor alternates between brake and coast at the PWM frequency with the percentage of
the braking time determined by the duty cycle.

• Locked-antiphase: With PWML disconnected or held high and PWMH held high, apply a PWM
signal to the DIR pin. In locked-antiphase operation, a low duty cycle drives the motor in one direction
and a high duty cycle drives the motor in the other direction; a 50% duty cycle turns the motor off. A
successful locked-antiphase implementation relies on the motor inductance and PWM switching
frequency to smooth out the current (e.g. making the current zero in the 50% duty cycle case), so a high
PWM frequency might be required.
Motor Driver Truth Table
PWMH PWML DIR OUTA OUTB Operation
H H L GND V+ Forward
H H H V+ GND Backward
L H X GND GND Brake Low
H L X V+ V+ Brake High
L L X Z Z Coast

X = don’t care (same for input H or L); Z = high impedance (outputs disconnected)

PWM Frequency
The motor driver supports PWM frequencies as high as 40 kHz, though higher frequencies result in
higher switching losses in the motor driver. Also, the driver has a dead time (when the outputs are not
driven) of approximately 3 us per cycle, so high duty cycles become unavailable at high frequencies.
For example, at 40 kHz, the period is 25 us; if 3 us of that is taken up by the dead time, the maximum
available duty cycle is 22/25, or 88%. (100% is always available, so gradually ramping the PWM input
from 0 to 100% will result in the output ramping from 0 to 88%, staying at 88% for inputs of 88%
through 99%, and then switching to 100%.)

Real-World Power Dissipation Considerations

The motor driver can tolerate peak currents in excess of 200 A. The peak current ratings are for quick
transients (e.g. when a motor is first turned on), and the continuous rating of 20 A is dependent on
various conditions, such as the ambient temperature. The main limitation comes from heating and
power dissipation; therefore, at high currents, the motor driver will be extremely hot, and performance
can be improved by adding heat sinks or otherwise cooling the board. The driver’s printed circuit board
is designed to draw heat out of the MOSFETs, but performance can be improved by adding a heat sink.
The MOSFETs have a theoretical maximum continuous current of 90A at 25°C, but dissipating enough
heat to keep the MOSFET at this temperature is impractical for most applications; close to 35 A of
continuous current should be achievable without too extravagant of a heat sink. For more information
on power dissipation see the data sheet for the MOSFETs on the Resources tab.

Because there is no internal temperature limiting on the motor driver, the entire system should be
designed to keep the load current below the 20 A limit. An easy way to achieve this is to select a motor
with a stall current below that limit. However, because a good motor can have stall currents dozens of
times higher than the typical operating current, motors with stall currents that are hundreds of amps can
be used with this driver as long as the running current is kept low. For example, a motor with a 100 A
stall current might run well at 10 A, leaving a safe margin for the current to double for several minutes
at a time or to triple for several seconds. If the motor does stall completely for a prolonged period,
however, the motor or driver are likely to burn out.
Warning: This motor driver has no over-current or over-temperature shut-off. Either condition can
cause permanent damage to the motor driver. We recommend you use the current-sense output CS to
monitor your current draw if your application will put the driver close to its limits of operation.

Fault Conditions
The motor driver can detect three different fault states, which are reported on the FF1 and FF2 pins.
The detectable faults are short circuits on the output, under-voltage, and over-temperature. A short-
circuit fault is latched, meaning the outputs will stay off and the fault flag will stay high, until the board
is reset (RESET brought low). The under-voltage fault disables outputs but is not latched. The over-
temperature fault provides a weak indication of the board being too hot, but it does not directly indicate
the temperature of the MOSFETs, which are usually the first components to overheat. The fault flag
operation is summarized below.

Flag State
Fault Description Disable Outputs Latched Until Reset
FF1 FF2
L L No fault No No
L H Short Circuit Yes Yes
H L Over Temperature No No
H H Under Voltage Yes No

High-Power Motor Driver Versions


There are currently nine versions of the high-power motor driver. The three CS versions have the same
pinout, and the six non-CS versions have the same pinout. The following table provides a comparison
of the high-power motor drivers:

Pololu high-power motor drivers


Max nominal battery Max continuous current (A) w/o
Name
voltage (V) heat sink
High-power motor
18 25
driver 18v25 CS
High-power motor
18 25
driver 18v25
High-power motor
18 15
driver 18v15
High-power motor
28 23
driver 24v23 CS
High-power motor 28 20
driver 24v20
High-power motor
28 12
driver 24v12
High-power motor
36 20
driver 36v20 CS
High-power motor
36 15
driver 36v15
High
36 9
-power motor driver 36v9

Note: Please consider our Simple Motor Controllers as alternatives to these motor drivers. They have
very similar power characteristics and offer high-level interfaces (e.g. USB, RC hobby servo pulses,
analog voltages, and TTL serial commands) that make them much easier to use for many applications.

Dimensions

Size: 1.8" x 1.2"


Weight: 7 g1

General specifications

Motor channels: 1
Minimum operating voltage: 5.5 V
Maximum operating voltage: 50 V
Continuous output current per channel: 20 A2
Current sense: 0.066 V/A3
Maximum PWM frequency: 40 kHz4
Maximum logic voltage: 5.5 V
MOSFET on-resistance (max per leg): 4.8 mΩ
Reverse voltage protection?: N

Notes:
1 Without any connectors or through-hole capacitors.
2 Typical results with 100% duty cycle at room temperature.
3 Bidirectional centered at 2.5 V with VCS of 5 V.
4 Higher frequencies are possible, but duty cycle will be limited by dead time of approximately 3 μs
per cycle.
Bibliography
[1] HUMUSOFT, MF 634 Multifunction I/O Card: User’s Manual, 2013. [Online]. Available:
[Link]

[2] Mathworks, Simulink: Getting Started Guide, 2014.

[3] ——, Simulink: User’s Guide, 2014.

[4] ——, Real-Time Windows Target: User’s Guide, 2014.

67

You might also like