introduction to control systemsrhabash/k-ecs lab manual_ control_systems… · introduction to...
TRANSCRIPT
Introduction to Control Systems
Laboratory Experiment Manual
Version 1.2.6
March 2013
Copyright © 2013 Kylowave Inc.
All rights reserved. No part of this publication may be reproduced, in any form or by any
means, without the prior written permission of Kylowave Incorporated.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 2 of 31
Terms of Use
Kylowave is disclosing this User Guide, Manual, Release Note, and/or Specification (the "Documentation") to you solely
for use in the development of designs to operate with Kylowave hardware devices. You may not reproduce, distribute,
republish, download, display, post, or transmit the Documentation in any form or by any means including, but not limited
to, electronic, mechanical, photocopying, recording, or otherwise, without the prior written consen t of Kylowave.
Kylowave expressly disclaims any liability arising out of your use of the Documentation. Kylowave reserves the right, at
its sole discretion, to change the Documentation without notice at any time. Kylowave assumes no obligation to correct
any errors contained in the Documentation, or to advise you of any corrections or updates. Kylowave expressly disclaims
any liability in connection with technical support or assistance that may be provided to you in connection with the
Information.
THE DOCUMENTATION IS DISCLOSED TO YOU “AS-IS” WITH NO WARRANTY OF ANY KIND. KYLOWAVE MAKES
NO OTHER WARRANTIES, WHETHER EXPRESS, IMPLIED, OR STATUTORY, REGARDING THE DOCUMENTATION,
INCLUDING ANY WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
NONINFRINGEMENT OF THIRD-PARTY RIGHTS. IN NO EVENT WILL KYLOWAVE BE LIABLE FOR ANY
CONSEQUENTIAL, INDIRECT, EXEMPLARY, SPECIAL, OR INCIDENTAL DAMAGES, INCLUDING ANY LOSS OF
DATA OR LOST PROFITS, ARISING FROM YOUR USE OF THE DOCUMENTATION.
2012 Kylowave, Inc. All rights reserved.
KYLOWAVE, the Kylowave logo, the K-ECS Universal Energy Conversion System, K-ECS AM256, and other designated
brands included herein are trademarks of Kylowave, Inc. All other trademarks are the property of their respective
Owners
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 3 of 31
Table of Contents
1 Introduction ......................................................................................................................................................................... 6
2 Experiment 1: Introduction to digital control systems ........................................................................................................ 7
2.1 Purpose and Goals ........................................................................................................................................................ 7
2.2 Apparatus required ................................................................................................................................................... 7
2.3 Pre-lab Assignment .................................................................................................................................................. 8
2.4 Procedure ................................................................................................................................................................. 8
2.5 Study Questions ..................................................................................................................................................... 11
3 Experiment 2: Identification of a DC motor system ......................................................................................................... 12
3.1 Purpose and Goals ...................................................................................................................................................... 12
3.2 Apparatus required ................................................................................................................................................. 13
3.3 Pre-lab Assignment ................................................................................................................................................ 13
3.4 Procedure ............................................................................................................................................................... 14
3.5 Study Questions ..................................................................................................................................................... 17
4 Experiment 3: Speed Control of DC motor ...................................................................................................................... 18
4.1 Purpose and Goals ...................................................................................................................................................... 18
4.2 Apparatus required ................................................................................................................................................. 19
4.3 Pre-lab Assignment ................................................................................................................................................ 19
4.4 Procedure ............................................................................................................................................................... 20
4.5 Study Questions ..................................................................................................................................................... 22
5 Experiment 4: Position Control of DC motor.................................................................................................................... 23
5.1 Purpose and Goals ...................................................................................................................................................... 23
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 4 of 31
5.2 Apparatus required ................................................................................................................................................. 23
5.3 Pre-lab Assignment ................................................................................................................................................ 23
5.4 Procedure ............................................................................................................................................................... 23
5.5 Study Questions ..................................................................................................................................................... 23
6 Experiment 5: Full State Feedback Control of DC motor ................................................................................................ 24
6.1 Purpose and Goals ...................................................................................................................................................... 24
6.2 Apparatus required ................................................................................................................................................. 24
6.3 Pre-lab Assignment ................................................................................................................................................ 24
6.4 Procedure ............................................................................................................................................................... 24
6.5 Study Questions ..................................................................................................................................................... 24
7 APPENDIX 1: PIN Descriptions........................................................................................................................................ 25
7.1 Single-phase and three-phase rectifiers ................................................................................................................. 25
7.2 DCDC Converter ..................................................................................................................................................... 25
7.3 Digital control interface ........................................................................................................................................... 26
7.4 Three-phase inverter .............................................................................................................................................. 27
7.5 Current sensors ...................................................................................................................................................... 27
7.6 Analog sensors ....................................................................................................................................................... 27
8 APPENDIX 2: Additional readings .................................................................................................................................... 28
9 APPENDIX 3: Contact Kylowave ..................................................................................................................................... 29
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 5 of 31
Revision History
Date Version Description Contributor 03/01/2013 1.0.0 Original Document
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 6 of 31
1 Introduction
The experiments proposed in this Laboratory Manual are realized using Kylowave K-ECS (Universal
Energy Conversion System) model AM256. K-ECS AM256 includes an Arduino Mega 2560 controller. This
manual includes five experiments that introduce the students to the Arduino Integrated Development
Environment (Arduino IDE), the basic topologies of digital control systems and the principles used to design
these systems.
The experiments are introduced in a progressively increasing order of complexity and such that the
following experiment builds on the knowledge gained during the previous one. Upon completing all the
experiments, the student will understand the differences between each topology, will have learned how to
design and implement controllers using those topologies, and will have developed the knowhow to best
assess the more appropriated technique as a function of the characteristics of the process to be controlled.
For advanced students, the laboratory instructor may choose to propose the use of more advanced control
algorithms such as μ-control, H∞, adaptive control, etc. Therefore, the same training platform can be used
by beginners as well as last year students or even graduate level ones. Throughout the manual, students
will learn all the steps involved in the development flow of modern digital controller, some of the most
important metrics related to the proper functioning of those circuits, and how to use a microcontroller to
implement the required functions.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 7 of 31
2 Experiment 1: Introduction to digital control systems
2.1 Purpose and Goals
Digital controllers are found in practically all aspects of modern life such as CD/DVD audio systems, battery
charging systems, automobile assembling robots, hybrid electric vehicles and remotely-operated surgical
medical devices to just name a few. The wide spread of digital controllers compared to the analog
controllers (also called continuous-time controllers) used in the past is due to their improved sensitivity to
signal noise, lower dependency to physical variables (power supply voltage, operating temperature,
manufacturing process, etc.), higher flexibility to be reconfigured and reasonably lower cost. These benefits
come at the expense of relatively lower closed-loop bandwidth compared to the analog controllers.
Figure 2.1 shows the high level architecture of a digital control system. The main objective of this
experiment is to introduce the student to the sampled-data sub-systems available in the K-ECS and explain
how to: i) use them to acquire data from various types of sensors; ii) and show how to use the existing
PWM modulators and low-pass filters to implement DACs which can be used as interface to actuators.
Specifically, the objective of this experiment is to:
Familiarize the student with the Kylowave K-ECS (“Energy Conversion System”), the Arduino and
its free IDE (“Integrated Development Environment”)
Demonstrate techniques to read and generate analog and digital I/Os using the Arduino IDE
libraries.
Introduce the PWM (“Pulse Width Modulation”) technique as a mean to generate analog signals to
control external actuators. Introduce the Arduino bit-banging PWM technique and understand its
advantages and limitations.
Introduce the Kylowave library and understand its performance compared to the standard Arduino
IDE library.
Demonstrate techniques to read and generate analog and digital I/Os using the Kylowave library.
2.2 Apparatus required
K-ECS, Oscilloscope, Multimeter, potentiometer, resistor, and a LED.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 8 of 31
Analog to Digital
Converter
Microprocessor
Digital to Analog
Converter
CorrectionElement
Process
Sampling TimeClock
Generation
Feedback Sensor System
D D AA
A: Analog
D: Digital
DC-DC
ConverterDC Motor
Optical Encoder
Figure 2.1: Digital control system general architecture
2.3 Pre-lab Assignment
In this Pre-lab the student is required to learn about Arduino.
The student can find very useful information at the Arduino official webpage at www.arduino.cc.
Specifically, the student should study the Blink and the ReadAnalogVoltage examples in the Arduino
Tutorial Webpage (http://arduino.cc/en/Tutorial/HomePage). In addition, get familiarized with the Arduino
programming language at its reference website (http://arduino.cc/en/Reference/HomePage).
Before start working on this experiment pre-lab assignment, we suggest you should study the following
Arduino functions (http://arduino.cc/en/Reference/HomePage): setup(), loop(), pinMode(), digitalWrite(),
digitalRead(), analogRead(), map(), delay() and delayMicroseconds().
For each Arduino sketch example below, look at the respective sketch code available online in the Arduino
webpage and answer the following questions:
1. Blink sketch – This sketch is also available in the Arduino IDE through the following command
sequence: File -> Examples -> 0.1Basics -> Blink. What is the blinking frequency of the original
Blink sketch? How can we make the LED blink at about 10 seconds rate?
2. Fade sketch – This sketch is also available in the Arduino IDE through the following command
sequence: File -> Examples -> 0.1Basics -> Fade. Propose a way to slow down the fading rate to
50% of the original fading rate. Propose a code change to make the maximum LED brightness to
be about 50% of the original maximum brightness.
3. Knob example in the Arduino servo library (File -> Examples - Servo -> Knob). In this example,
explain the maximum possible value that analogRead() can achieve. Explain the purpose of using
the map() function. In the Fade example, if the “val” variable after the map() function assignment is
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 9 of 31
used as the second parameter of analogRead() (instead of brightness), would the LED be able to
achieve its maximum brightness? Explain.
4. Look at steps 6 and 7 of section 2.4 and think how you would realize it. Hint: Consider how the
commands used in the three examples above can help.
5. Complete the four procedure in experiment #1 by writing an Arduino sketch and results.
6. Answer study questions #1 and #2.
Write a pre-lab report (maximum of 3 pages).
2.4 Procedure
The experiment procedure is as follows:
1. Assemble the Analog sensor test circuit as shown in the diagram of Figure 2.3.
2. Set up the potentiometer as shown in Figure 2.3, connect its central connection to K-ECS pin
AnalogIO_0 (ANALOG SENSOR connector, pin #30), and adjust the potentiometer such that the
multimeter reads the following values: 0, 1, 2, 3 and 4. Note: AnalogIO_0 is a 0 to 5V(Max)
analog input pin.
3. Write an Arduino sketch (this is how the Arduino community calls an Arduino program) to read the
voltage value on the K-ECS analog input AnalogIO_0 and print it to the serial monitor. Check that
the printed value matches the value you would expect to see.
4. Using the Arduino map() function, scale the digital value read at step 2 to the range [0, 100] such
that the digital value 0 corresponds to 0V and 100 corresponds to +5 V.
5. Assemble the PWM test circuit as shown in the diagram of Figure 2.4.
6. Using the Arduino PWM bit banging technique, add code to the sketch created in step 3 to
generate a 1 kHz PWM signal on K-ECS pin DacPwm_1 0 (DIGITAL CONTROL connector, pin
#29). The PWM modulation index should be the digital value produced at step 4. Write your code
to ensure that the PWM carrier frequency does not change with changes of the modulation index.
7. For each voltage in step 2, read the PWM signal duty cycle using the oscilloscope. Then, build a
table showing the voltage measured by the Multimeter, duty cycle, the digital number read from pin
#30 (step 3) and the digital number resulting form the map() function (step 4).
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 10 of 31
2
1
DIGITAL CONTROL
3 5 7
4 6 8 24
23 25 27 29
26 28 30
DG
ND
+5
V
SP
I_S
CL
K
SP
I_S
DO
SP
I_S
S
SP
I_S
DI
PW
MIn
v_
BH
PW
MIn
v_
AH
DA
CP
WM
_0
PW
MIn
v_
BL
PW
MIn
v_A
L
DA
CP
WM
_1
2
1
ANALOG SENSORS
3 5 7
4 6 8 24
23 25 27 29
26 28 30
+3
.3V
DG
ND
AV
DD
AG
ND
+5
V
AG
ND
Res
erv
ed
Sen
sVin
_0
An
alo
gIO
_0
Res
erv
ed
Sen
sVin
_1
An
alo
gIO
_1
Figure 2.2: Lateral View of K-ECS DIGITAL CONTROL and ANALOG SENSORS 30-pin connectors
AVDD
AnalogIO_0
AGND
4704K7
VDC
GND
AN
AL
OG
SE
NS
OR
S
29
28
30
27
26 25
6 5
4 3
2 1
0 – 5V
WARNING: pins #2 and #6 MUST
be connected at all times
5V
Multimeter
Figure 2.3: Analog sensor test circuit
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 11 of 31
DACPWM_1
DGND
470
DIG
ITA
L C
ON
TR
OL
2
3
1
4
5 6
25 26
27 28
29 30
0 – 5V
LED
Oscilloscope
Figure 2.4: PWM test circuit
2.5 Study Questions
1. Consider the table built in section 2.4. Explain any differences between digital values measured
from pin #30 AnalogIO_0 and the expected values calculated from the DC values measured by the
Multimeter. What is the average ratio value between the number returned by
analogRead(AnalogIO_0) and the respective value measured by the multimeter? Hint: This is the
Arduino A/D converter scaling gain.
2. What is the number of bits and maximum values of the Arduino A/D converter? What value would
have to be applied at pin AnalogIO_0 in order to obtain the maximum value for the Arduino A/D
converter?
3. What is the maximum PWM carrier frequency that the Arduino can achieve when using the bit
banging technique? Hint: change the code written in section 2.4 step 6 to experimentally determine
the maximum value.
4. What happens to the LED of Figure 2.4 when the potentiometer is used to change the voltage
value on pin 30: AnalogIO_0? Explain the observed behavior.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 12 of 31
3 Experiment 2: Identification of a DC motor system
3.1 Purpose and Goals
Identification is defined as the process of determining the transfer function of a system G(s) from a
collection of measured data where neither the form nor the parameters of G(s) are known. If the form of the
transfer function is already known, then problem of identifying the parameters of G(s) is called parameter
identification. In general, model identification is a much more complex problem than parameter estimation.
Especially, if there is noise in the sampled data set.
The objective of this experiment is to identify the parameters of a DC motor of Figure 3.1 including the
motor itself, a load on its shaft and possibly gears. In this experiment, we will identify the parameters of a
first-order and a second-order model. The first-order model is suitable for armature control of DC motors.
The second-order model is normally used for torque and speed control of DC motors.
The objective of the identification experiment is to:
Introduce the DC motor first-order and second-order models.
Introduce the concept of parameter estimation and obtain the first-order model of a DC motor.
Validate the models through Matlab/Simulink simulations against the measured data set.
Introduce MegunoLink as an open source visualization tool:
http://www.blueleafsoftware.com/Resources/EmbeddedSand/MegunoLink.
Load
Va
Ra La
VbT
q
Armature Circuit
VfIa
IfRf
Lf
Field Circuit
VD
C
GN
D
Optical
Encoder
Figure 3.1: DC Motor Electrical Circuit
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 13 of 31
3.2 Apparatus required
Matlab/Simulink, K-ECS, Oscilloscope, Multimeter and a DC motor kit with load (and possibly gears).
3.3 Pre-lab Assignment
In general and as shown in figure 3.2, the first two steps in the development of a motor control system
consists in identifying the motor parameters, build an equivalent model and simulate it to ensure the model
and identified parameters fit the expected physical results. In this Pre-lab the student is required to do a
theoretical analysis of the DC motor shown in Figure 3.1.
IdentificationModeling
&Simulation
DesignSimulation
&Validation
ImplementationPrototype
Testing
Figure 3.2: DC Motor Controller Development Flow
Let Ra and La be the armature resistance and inductance, J be the total moment of inertia (load, shaft, the
rotor of the motor, etc.), f be the total viscous friction coefficient (bearing and shaft), Kt is the torque
constant such that T(t) = Kt . ia(t), and Kb is the back electromagnetic force such that vb(t) = Kb . d(t)/dt,
then the angular speed transfer function of the armature controlled DC motor is shown in Figure 3.3 and is
mathematically given by:
In many practical applications, the armature inductance is much smaller than the armature resistance.
Thus, we can approximate the previous second-order transfer function by the first-order transfer function
below:
Where
,
and
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 14 of 31
Kt
Ra + s La
TVa
1
s J + f
1
s
Kb
w=dq/dtq
Second
Order
Km
1 + s tmVa
1
s
w=dq/dtq
First
Order
Figure 3.3: DC Motor Models
Considering the DC motor model of figure 3.1 and the motor parameters previously defined in this section,
answer the following questions:
1. Starting from the DC motor electrical and mechanical equations, derive a continuous-time second
order model for the motor.
2. Assuming the time constant of the motor electrical subsystem (given by Ra and La) is much
smaller than the time constant of the motor mechanical subsystem (given by J and f), derive an
approximated first-order model.
3. Considering the experiment should use a symmetrical PWM controlled Buck DC-DC converter,
explain the need for non overlapping time zone (also called dead zone) in a symmetrical PWM
signal.
4. Explain the difference between a step-down Buck DC-DC converter and a half-bridge DC-DC
converter.
5. Write an Arduino sketch to generate a symmetrical PWM signal on K-ECS DC-DC converter
control signals (PWMDCC_H and PWMDCC_L). The PWM carrier frequency should be set to 2
kHz and the non overlapping to about 10 microseconds (5 microseconds on each edge of the
PWM signal).
Write a pre-lab report (maximum of 5 pages).
3.4 Procedure
Consider the DC motor of Figure 3.1. The procedure below will show how to determine the parameters of
the transfer function of the first-order model. As shown in figure 3.4, the basic idea is to use a V(in) DC
voltage power supply and a PWM controlled Buck DC-DC converter to generate an output V(ou) DC
voltage that is proportional to the PWM duty cycle and the DC voltage source such that: V(out) = D x V(in),
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 15 of 31
where D in the PWM duty cycle. Because the duty cycle can theoretically vary between 0.0 and 1.0 (0 to
100%), the output voltage can be adjusted to almost any value between 0 and V(in).
K-ECS includes a DC-DC converter module can be configured to implement various DC-DC converter
topologies. The connection mapping of table 3.1 shows how to configure it to implement the step-down
converter shown in figure 3.4. This converter can be operated in step-down Buck mode by driving logic “0”
to DIGITAL CONTROL pin PwmDCC_L and driving a PWM signal to PwmDCC_H. The converter can also
be operated in half-bridge mode by simultaneously driving a symmetrical PWM signal to pins PwmDCC_H
and PwmDCC_L.
The input power (positive of the DC power supply V(in)) should be connected to pin DCDC_In. The scaled
output voltage V(out) (V(out) = D x V(in)) comes out on pin DCDC_Out. DGND is the common ground and
should be connected to the negative terminal of the DC power supply and the DCDC_Ref pin.
Configuration Pins I/O Pins
DCDC_S1 DCDC_In
DCDC_S2 DCDC_Ref
DCDC_S3 DCDC_Out
Table 3.1: K-ECS DC-DC Converter Buck Connection Mapping
Load
Tq
Optical
Encoder
PWMDCC_H
PWMDCC_L
V(in)
DGND
DCDC_Out
DCDC_InStep-Down DC-DC Converter
DCDC_Ref
Figure 3.4: DC Motor Controlled by a Half Bridge DC-DC Converter
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 16 of 31
The experiment procedure is as follows:
1. Talk to your TA to obtain the motor kit specification and fill up table 3.2.
2. Assemble the test circuit as shown in the diagram of Figure 3.5. WARNING: connect the system
ground to just ONE point and connect the single point ground to DGND pin of the DCDC
CONVERTER connector as shown in figure 3.4. This centralized ground connection is a best
practice that should be adopted in all power electrics applications. It prevents creating circulating
currents that can flow through ground loops which can couple noise to various parts of the circuit
and in many cases can prevent the circuit to work or even worse permanently damage the circuit
and the equipment involved. NOTE: The power supply should be set to a voltage level smaller than
or equal to the motor maximum terminal voltage (ask your TA for the voltage level to be used).
3. Write a sketch to drive a symmetrical PWM signal to K-ECS DC-DC converter pins PWMDCC_L
and PWMDCC_H (DIGITAL CONTROL connector, pins #21 and #22) to operate K-ECS DC-DC
converter in half-bridge mode.
4. Add code to the previous sketch to measure the motor shaft angular speed in rad/s. Note: See
appendix 8.
5. Choose a reasonable duty cycle to apply a voltage of known magnitude Va and measure the final
shaft speed and the time from applying the voltage up to 50% of the final shaft speed.. Suggestion:
choose duty cycle such that the average voltage Va is about 50% of the motor nominal speed. Set
up the duty cycle such that the average voltage Va is 25% and 75% of the motor nominal voltage,
and redo the measurements.
6. Develop the expression for the gain constant of the first-order model as a function of the final shaft
speed and the armature voltage Va. Using this expression, calculate the estimated value of the
gain constant.
7. Develop the expression for the first-order time constant as a function of the final shaft speed, the
shaft speed at time t0 (In our case, the time measured in step 3) and time t0 itself. Using this
expression, calculate the estimated value of the first-order time constant.
8. Using the parameters identified in step 7, build a Matlab/Simulink model, apply a step input to the
model and record the simulated output speed. Simulate the model to the following scenarios: Va
values of step 5. Note: the step input signal should have a value equal to the averaged Va signal
value.
Parameter Specification Unit
Nominal Voltage V
Nominal Current A
Gear Rateio
Nominal Speed Rad/s
Maximum SPeed Rad/s
Table 3.2: DC Motor Kit Specification
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 17 of 31
3-PHASE RECTIFIER
1 2 3 4 5 6
DCDC CONVERTER
1 2 3 4 5 6
DC
DC
_S1
DC
DC
_In
Optical
Encoder
Tq
DC Power Supply
DC Motor
Note: The voltage of the DC power
supply should be set to a voltage level
smaller than or equal to the motor
maximum terminal voltage
To PWMDCC_H
Current
Measurement
DC
DC
_S2
DC
DC
_Ou
t
DC
DC
_Ref
DG
ND
DC
DC
_S3
Ground
Input
Output
+
-
DIGITAL CONTROL
1 2
21 22
29 30
PWMDCC_HPWMDCC_L
19 20 DIGITAL_0DIGITAL_1To DIGITAL_0
Figure 3.5: DC Motor Parameter Estimation Test Circuit
3.5 Study Questions
1. If the moment of inertia of the load and the viscous friction coefficient were doubled, what would be
the new transfer function? Do the time and gain constants equal half of those of the first transfer
function?
2. Write the first-order transfer function from the applied voltage Va(t) to the angular displacement
(t)? What is its unit-step response? What is (∞)? What does it mean physically?
3. Compare the measured results of steps 4 and 5 to simulated results of step 8. Explain any
differences.
4. Explain the coupling mechanism responsible for the ground loop circulating current effect. In power
electronics applications, which parasitic effects contribute the most to increase its effects? Parasitic
resistance, capacitance, or inductance? Explain.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 18 of 31
4 Experiment 3: Speed Control of DC motor
4.1 Purpose and Goals
Some of the objectives of feedback control is to reduce the effect of disturbances on a system, make the
system more insensitive to parameter variations and create a well defined input-output relationship.
Nevertheless, careful design of the feedback controller is required as the feedback can unintentionally
make a stable open-loop system to become unstable in closed-loop operation.
Initially, most feedback controllers were implemented using analog electronics such operation amplifiers.
Presently, the vast majority of feedback controllers are implemented using a digital processor
(microcontroller, DSP, FPGA, etc.). Analog controllers are used almost exclusively in applications that
require a high closed-loop bandwidth that can not attained by digital controllers. During the last three
decades, many different topologies of feedback controllers have been developed, but the popular PI
(Proportional-Integral) and PID (Proportional-Integral-Derivative) structures are still used in most industrial
applications. This is due to the of their analysis and design process, reduced resource utilization, and
reasonable performance to many important industrial applications. In general, PID controllers produce
higher performance than PI controller. However, the additional derivative action makes the controller more
sensitive to noise or fast transients in the feedback control loop. Usually, PI controllers are used on speed
control applications because of the potential noisy signal related to the motor shaft speed measurement.
The integral relationship between the position and the speed of the motor shaft causes the position sensor
signal to be much smoother than the speed measurement signal. Thus, PID controllers are often used for
position control systems.
The objective of this experiment is to develop a digital feedback PI controller for the DC motor of Figure 3.1.
The student will design a PI (Proportinal-Integral) controller to regulate the speed of the group motor-gear-
disc. During the experiment, the student will:
Design a PI controller to meet the given specification.
Simulate the system dynamics (PI controller and DC motor group).
Investigate the effect of integral windup in the system performance.
Implement the PI controller in an Arduino to control the actual system
IdentificationModeling
&Simulation
DesignSimulation
&Validation
ImplementationPrototype
Testing
Figure 4.1: DC Motor Controller Development Flow
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 19 of 31
4.2 Apparatus required
Matlab/Simulink, K-ECS, Oscilloscope, Multimeter and a DC motor kit with load (and possibly gears).
4.3 Pre-lab Assignment
In this Pre-lab the student is required to do a theoretical analysis of the speed controller of Figure 4.2. The
plant is the DC motor shown in Figure 3.1 and identified in the previous section. The student is required to
design the controller “by hand”. You must use a simulation tool such as Matlab/Simulink to interactively
tune the parameters Kp and Ki to achieve the requirements of table 4.1.
Use Figure 3.3b to create a first-order DC motor model in Matlab/Simulink, and use the Km and values
identified in the previous experiment. Using the diagram of Figure 4.2, design a continuous-time PI
controller to meet the specification of Table 4.1. Afterwards, discretize the continuous-time PI controller to
produce a discrete-time controller that meets all the requirements of Table 4.1, implement it in
Matlab/Simulink using the discrete-time transfer function block. Re-simulate the speed control system with
discrete-time controller and compare the results against the continuous-time controller. Hint: Look for the
attachInterrupt() function in the Arduino webpage and understand how it works. Consider using this
interrupt mechanism to implement an accurate sampling time step for the PI controller control loop.
w=dq/dtq
Km
1 + s tm
1
sKi
s
Kp
wrefVcontVerr
Kv
1 + s tv
Low-Pass Filter
DC Motor Model
PI Controller+
+
+
-
Vcont= (Kp + Ki/s) * Verr
Figure 4.2: DC Motor Speed Controller
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 20 of 31
Parameter Specification
Overshoot Minimal overshoot of 5% or less
Rise Time Rise time greater than 2s but less than 2.5s.
Settling Time Settling time greater than 4s but less than 4.5s.
Reference Signal The reference signal should be a square wave with amplitude 50 RPM and 100 RPM. And a period of 10 seconds. This will
Saturation Saturate the PI controller output with a Simulink saturation block so that the PWM duty cycle stays in the 20% to 80% range.
Discretization Method
Backward Euler
Sampling Frequency
To be chosen by the student such that the difference between the continuous-time and discrete-time closed loop overshoot is less than 1% (it must be bigger than 100 Hz).
Table 4.1: Requirements of the DC Motor Speed Controller
4.4 Procedure
Consider the DC motor group of Figure 3.1 and the speed controller of Figure 4.2. The speed controller
design process can be summarized as follows:
Design a continuous-time controller using one of the design techniques such as ad-hoc, optimal
controller, robust controller, full state and full observer, etc. We suggest you should use the
interactive ad-hoc tuning method. Start with a large value for Kp that do not cause the system to
become unstable. Then, increase the Ki gain to reduce the overshoot. Iterate tuning the Kp and Ki
gains until you meet all the requirements. Quiz: reference 8.7 (available online at
http://eprints.gla.ac.uk/3817/1/IEEE3.pdf), explain the independent effect of each PID gain in the
controller closed loop response.
Add sampled-data system elements such as analog to digital converters (SFCs), digital to analog
converters (DACs), pulse width modulators (PWMs), antialiasing filter, etc.
Choose an appropriated sample period. As a rule of thumb, the sampling period should be at least
10 times the closed loop frequency such that Ts = 1 / (10 * fB), where Ts is the smapling period and
fB is the closed-loop frequency (fB = B / (2 * π), B is the closed loop bandwidth).
Digitize the continuous-time control law using an appropriated discretization rule such as: backward
Euler, Tustin, fisrt-order hold, second-order hold, zero-pole placement, etc.
Verify the digital controller performance using discrete-time model simulation (ex.: Matlab/Simulink)
If the performance does not meet the requirements, fine tune the digital controller as necessary,
until the requirements are met.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 21 of 31
The procedure below will show how to design, implement and test a PI controller to implement a DC motor
speed control system.
1. Assemble the test circuit as shown in the diagram of Figure 4.3
2. Choose the number of bits and appropriate sampling frequency to implement your controller.
Notice that the Arduino is a 8-bit microcontroller running at a master clock frequency of 16 MHz.
3. Discretize your PI controller using the Backward Euler discretization rule and the chosen sampling
frequency. Quantize the PI controller constants to minimize the additional error introduced by
quantization compared to the continuous-time controller.
4. Write an Arduino sketch to implement the PI controller. We suggest that you try to complete the
sketch before your lab period so that you will have more time to test the PI controller on the actual
motor.
Read the angular speed reference value.
Read the optical encoder position on the DIGITAL CONTROL pin #8 and calculate the
estimated shaft angular speed. Attach an interrupt to this pin such that the code does not
need to consume CPU time to monitor the pin.
Filter out the calculated speed using a low-pass digital filter and write the filtered value to
DACPWM_1 pin.
In the code, create a loop that steps the shaft speed from 50 RPM to 100 RPM and back,
within a period of 10s.
Use the filtered speed value to calculate the error signal to be used by the PI controller.
Calculate the control signal value and use it to drive the DC-DC PWM control inputs.
Measure the control effort. Send the duty cycle value between the PI controller output and
the DC-DC converter control signal to DACPWM_0 and observe the signal coming out at
DacFlt_0.
Sample the estimated raw speed, the filtered speed and the control signal at the output of
the PI controller. Store these values in an internal memory array.
5. After the controller is correctly working, store the DC motor speed response in open-loop and in
closed-loop for the following scenarios: i) speed step signal applied to the reference input; ii) motor
shaft is running at steady state speed than it is locked; iii) motor shaft is released.
6. Send the stored values to MegunoLink to be plotted. Report the measured results in your Lab
report.
7. Compare the steady state and transient responses for the open-loop and closed-loop test
scenarios.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 22 of 31
3-PHASE RECTIFIER
1 2 3 4 5 6
DCDC CONVERTER
1 2 3 4 5 6
DG
ND
DC
DC
_RefD
CD
C_S
1
DC
DC
_In
DC
DC
_S2
DC
DC
_S3
DC
DC
_Ou
t
AGND (6)
Optical Encoder
DIGITAL CONTROL
(MAX: 5.5V)
2
3
1
4
5 6
25 26
27 28
29 30
Tq
DacFlt_0 (10)
DCDC_In (28)
ANALOG SENSORS
29
28
30
27
26 25
6 5
4 3
2 1
(27) DCDC_Out
(30) Control SignalEstimated Speed (29)
(9) DacFlt_1(8) Optical Encoder
Figure 4.3: DC Motor Speed Controller Test Circuit
4.5 Study Questions
1. Using the data acquired during the experiment, plot the data acquired in section 4.4 item ___.
Upload the data to Matlab and compare it against the simulated results.
2. Explain the problem caused by the optical encoder rollover. How can it be corrected?
3. Explain the issue of integral windup. How can it be solved?
4. Explain the advantages and inefficiencies of a purely proportional or purely integral digital controller
5. Explain the methodology used to choose the sampling frequency. What would happen if the
sampling frequency was five times smaller or five times bigger than the chosen value?
6. BONUS question 1: Additional bonus points will be granted to implementations that avoid complex
mathematical operations such as floating point, multiplication, division, etc. These operation cause
the controller algorithm to run at a much smaller sampling frequency.
7. BONUS question 2: Keeping the same integral gain and DC motor group, what is the maximum
proportional gain where the closed-loop system is still marginally stable?
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 23 of 31
5 Experiment 4: Position Control of DC motor
5.1 Purpose and Goals
NOTE: ask to design a PID to control the DC motor. Ask to compare the results with the Ziegler-Nichols
and the Robust design method proposed in the Lecture 8 and Lecture 6 (Optimum Control).
.
The objective of the ________ experiment is to:
.
5.2 Apparatus required
.
5.3 Pre-lab Assignment
Using integration in the Laplace domain, derive the transfer function for motor position from the
velocity transfer function obtained in Experiments 2 and 4.
.
Verify the design with the instructor, then:
1. .
5.4 Procedure
1. .
5.5 Study Questions
1.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 24 of 31
6 Experiment 5: Full State Feedback Control of DC motor
6.1 Purpose and Goals
NOTE: use full state feedback in series with full state observer. Compare results with experiment 4. Use
method presented in Lecture 6.
.
The objective of the _________ experiment is to:
.
6.2 Apparatus required
.
6.3 Pre-lab Assignment
.
1.
.
Verify the design with the instructor, then:
1. .
6.4 Procedure
.
1. .
6.5 Study Questions
1.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 25 of 31
7 APPENDIX 1: PIN Descriptions
7.1 Single-phase and three-phase rectifiers
K-ECS External Connector
PIN K-ECS Signal Detailed Description
1-PHASE RECTIFIER connector
1-Phase Rectifier 1 Rect1Ph Single-phase rectifier input AC phase voltage
1-Phase Rectifier 2 RectRef1Ph Single-phase rectifier input AC reference voltage
1-Phase Rectifier 3 DC1Ph+ Single-phase rectifier positive output DC voltage
1-Phase Rectifier 4 DC1Ph- Single-phase rectifier negative output DC voltage
1-Phase Rectifier 5 DC3Ph+ Three-phase rectifier positive output DC voltage
1-Phase Rectifier 6 DC3Ph- Three-phase rectifier input output DC voltage
3-PHASE RECTIFIER connector
3-Phase Rectifier 1 Rect3Ph_A Three-phase rectifier phase A input AC voltage
3-Phase Rectifier 2 Rect3Ph_B Three-phase rectifier phase B input AC voltage
3-Phase Rectifier 3 Rect3Ph_C Three-phase rectifier phase C input AC voltage
3-Phase Rectifier 4 RectRef3Ph Three-phase rectifier input AC reference voltage
3-Phase Rectifier 5 DCDC_S4 DC-DC converter 5: DCDC_S4 signal
3-Phase Rectifier 6 DCDC_S3 DC-DC converter 6: DCDC_S3 signal
7.2 DCDC Converter
K-ECS External Connector
PIN K-ECS Signal Detailed Description
3-PHASE RECTIFIER connector
3-Phase Rectifier 5 DCDC_S4 DC-DC converter 5: DCDC_S4 signal
3-Phase Rectifier 6 DCDC_S3 DC-DC converter 6: DCDC_S3 signal
DCDC CONVERTER connector
DC-DC Converter 1 DCDC_S1 DC-DC converter 2: DCDC_S1 signal
DC-DC Converter 2 DCDC_S2 DC-DC converter 2: DCDC_S2 signal
DC-DC Converter 3 DCDC_In DC-DC converter positive output DC voltage
DC-DC Converter 4 DCDC_Out DC-DC converter negative output DC voltage
DC-DC Converter 5 DCDC_Ref DC-DC converter reference voltage
DC-DC Converter 6 DGND Power ground and Digital Ground
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 26 of 31
7.3 Digital control interface
K-ECS External Connector
PIN K-ECS Signal Detailed Description
DIGITAL CONTROL connector
Digital Control 1 DGND Digital Ground
Digital Control 2 +5V +5V DC Power Supply
Digital Control 3 SPI_SS General Purpose Digital Signals + 3: SPI_SS (Slave Select) – used by Ethernet card
Digital Control 4 SPI_SCLK General Purpose Digital Signals + 4: SPI_SCLK (Serial Clock) – used by Ethernet card
Digital Control 5 SPI_SDI General Purpose Digital Signals + 5: SPI_SDI (Master Out Slave In) – used by Ethernet card
Digital Control 6 SPI_SDO General Purpose Digital Signals + 6: SPI_SDO (Master In Slave Out) – used by Ethernet card
Digital Control 7 Reserved not connected
Digital Control 8 Reserved not connected
Digital Control 9 Digital_11
Digital Control 10 Digital_10
Digital Control 11 Digital_9 General purpose I/O digital signal
Digital Control 12 Digital_8 General purpose I/O digital signal
Digital Control 13 Digital_7 General purpose I/O digital signal
Digital Control 14 Digital_6 General purpose I/O digital signal
Digital Control 15 Digital_5 General purpose I/O digital signal
Digital Control 16 Digital_4 General purpose I/O digital signal
Digital Control 17 Digital_3 General purpose I/O digital signal
Digital Control 18 Digital_2 General purpose I/O digital signal
Digital Control 19 Digital_1 General purpose I/O digital signal
Digital Control 20 Digital_0 General purpose I/O digital signal
Digital Control 21 PWMDCC_L DC-DC converter PWM input high
Digital Control 22 PWMDCC_H DC-DC converter PWM input low
Digital Control 23 PWMInv_CL Three-phase inverter phase C PWM input high
Digital Control 24 PWMInv_CH Three-phase inverter phase C PWM input low
Digital Control 25 PWMInv_BL Three-phase inverter phase B PWM input high
Digital Control 26 PWMInv_BH Three-phase inverter phase B PWM input low
Digital Control 27 PWMInv_AL Three-phase inverter phase A PWM input high
Digital Control 28 PWMInv_AH Three-phase inverter phase A PWM input low
Digital Control 29 DACPWM_1 PWM input to a second order Sallen-Key low pass filter with output at 10: DACFlt_0 of analog connector
Digital Control 30 DACPWM_0 PWM input to a second order Sallen-Key low pass filter with output at 9: DACFlt_1 of analog connector
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 27 of 31
7.4 Three-phase inverter
K-ECS External Connector
PIN K-ECS Signal Detailed Description
3-PHASE INVERTER connector
3-Phase Inverter 6 DGND Digital Ground
3-Phase Inverter 5 Inv3Ph_DC- DC power supply negative voltage terminal
3-Phase Inverter 4 Inv3Ph_DC+ DC power supply positive voltage terminal
3-Phase Inverter 3 Inv3Ph_C Phase C AC signal
3-Phase Inverter 2 Inv3Ph_B Phase B AC signal
3-Phase Inverter 1 Inv3Ph_A Phase A AC signal
7.5 Current sensors
K-ECS External Connector
PIN K-ECS Signal Detailed Description
CURRENT SENSORS connector
Current Sensors 6 Inp0+ General purpose current sensor #0 input current
Current Sensors 5 Inp0- General purpose current sensor #0 output current
Current Sensors 4 Inp1+ General purpose current sensor #1 input current
Current Sensors 3 Inp1- General purpose current sensor #1 output current
Current Sensors 2 Reserved not connected
Current Sensors 1 VSupply Main DC power supply from power connector
7.6 Analog sensors
K-ECS External Connector
PIN K-ECS Signal Detailed Description
ANALOG SENSORS
Analog Sensors 30 AnalogIO_0 General Purpose analog input to Arduino (0 to 5V)
Analog Sensors 29 AnalogIO_1 General Purpose analog input to Arduino (0 to 5V)
Analog Sensors 28 SensVIn_0 General purpose analog input to the voltage sensor (0 to 48V)
Analog Sensors 27 SensVIn_1 General purpose analog input to the voltage sensor (0 to 48V)
Analog Sensors 26 Reserved not connected
Analog Sensors 25 Reserved not connected
Analog Sensors 24 Reserved not connected
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 28 of 31
K-ECS External Connector
PIN K-ECS Signal Detailed Description
ANALOG SENSORS
Analog Sensors 23 Reserved not connected
Analog Sensors 22 SensVOut_C Analog output from three-phase inverter phase C voltage sensor (22: SensVOut_C = 3: Inv3Ph_C / 10)
Analog Sensors 21 SensVOut_D Analog output from three-phase inverter phase D voltage sensor (21: SensVOut_D = 4: Inv3Ph_DC+/ 10)
Analog Sensors 20 SensVOut_A Analog output from three-phase inverter phase A voltage sensor (20: SensVOut_A = 1: Inv3Ph_A / 10)
Analog Sensors 19 SensVOut_B Analog output from three-phase inverter phase B voltage sensor (19: SensVOut_B= 2: Inv3Ph_B / 10)
Analog Sensors 18 SensVOut_GP0 Analog output from the general purpose voltage sensor (18: SensVOut_GP0 = 28: SensVIn_0 / 10)
Analog Sensors 17 SensVOut_GP1 Analog output from the general purpose voltage sensor (SenseV1 = 27: SensVIn_1 / 10)
Analog Sensors 16 SensIOut_C Analog output from three-phase inverter phase C current sensor (16: SensIOut_C = 1.65V + 0.175 * IPhaseC) (3)
Analog Sensors 15 SensIOut_D Analog output from three-phase inverter phase D current sensor (15: SensIOut_D = 1.65V + 0.175 * Isupply)
Analog Sensors 14 SensIOut_A Analog output from three-phase inverter phase A current sensor (14: SensIOut_A = 1.65V + 0.175 * IPhaseA) (3)
Analog Sensors 13 SensIOut_B Analog output from three-phase inverter phase B current sensor (13: SensIOut_B = 1.65V + 0.175 * IPhaseB) (3)
Analog Sensors 12 SensIOut_GP0 Analog output from the general purpose current sensor (12: SensIOut_GP0 = 1.65V + 0.175 * 6: Inp0+)
Analog Sensors 11 SensIOut_GP1 Analog output from the general purpose current sensor (11: SensIOut_GP1 = 1.65V + 0.175 *4: Inp1+)
Analog Sensors 10 DACFlt_0 Analog output of the second order Sallen-Key filter 30: DACPWM_0
Analog Sensors 9 DACFlt_1 Analog output of the second order Sallen-Key filter 29: DACPWM1
Analog Sensors 8 Reserved spacing
Analog Sensors 7 Reserved spacing
Analog Sensors 6 AGND Analog ground
Analog Sensors 5 AGND Analog ground
Analog Sensors 4 AVDD Analog VDD (can be set up to +5V or +3.3V)
Analog Sensors 3 +5V +5V DC Power Supply
Analog Sensors 2 DGND Digital Ground
Analog Sensors 1 +3.3 V +3.3V DC power supply
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 29 of 31
8 APPENDIX 2: Useful Formulae
8.1 Position and Speed Conversion Formulae
(8.1)
(8.2)
(8.3)
8.2 Position and Speed Calculation Formulae
The optical disk shown in the figure can be used to convert the circular
motion into a sequence of digital pulses that can be processed by a digital
controller. Digital pulses are produced every time a radial line in each
track interrupts the beam between a photo emitter-detector pair. By
counting these pulses the information can be converted to a relative or
absolute angular position or angular speed.
Consider an optical disk with N radial lines. The angular displacement of each radial line can be calculated
by equation (8.4). If the digital controller counts n pulses, than the motor shaft connected to the optical
encoder disk would have turned an angular distance given by equation (8.5).
(8.4)
(8.5)
As shown in equation (8.6), the angular speed can be measure by counting the number of pulses p
produced by the optical encoder, multiplying this number by the angular displacement of one radial line
and dividing by the time in seconds passed between the first and last pulses ( . This
method is easier to implement and can produce very accurate measurements if the number of pulses is
large enough. However, in case the motor shaft is turning at low speed it may take a long period of time to
measure the angular speed. The uncertainty in one measurement is given by ξ(%) = 100 / p, where p is the
number of pulses.
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 30 of 31
(8.6)
Another method that produces faster measurements (generally at the expense of lower accuracy) consists
in using a high frequency clock f(clk) and counting the number of this high frequency pulses P between the
beginning and the end of one optical encoder pulse (or a few pulses). The angular speed can be calculated
by equation (8.7). Note that the uncertainty now depends on the frequency of the fast clock signal and the
ability to synchronize the measurements to the edge of the optical encoder pulses.
(8.7)
9 APPENDIX 3: Additional readings
1. Nise, Norman S., Control Systems Engineering, 6th Edition, Wiley & Sons, 2011.
2. Dorf, Richard C. and Bishop, Robert H., Modern Control Systems, 11th Edition, Prentice Hall, 2008.
3. Chen, Chi-Tsong, Analog and Digital Control System Design: Transfer-function, State-Space and
Algebraic Methods, Oxford University Press, 2006.
4. Franklin, Gene F., Powell, J. David and Emami-Naeni, Abbas, Feedback Control of Dynamic
Systems, 6th Edition, Prentice Hall, 2009.
5. Batarseh, Issa, Power Electronic Circuits, 2004.
6. Kazimierczuck, Marian K., Pulse-Width Modulated DC-DC Power Rashid, Muhammad H., Power
Electronics: Circuits, Devices and Applications, 3rd ed., 2004.
7. Ang, K. H. and Chong, G. and Li, Y., “PID Control System Analysis, Design, and Technology,”
IEEE Trans. On Control Systems, Vol. 13, No. 4, July 2005.
10 APPENDIX 4: Contact Kylowave
Kylowave Inc (613) 454-1437 www.kylowave.com K-ECS Technical Support
Copyright © 2013 Kylowave Inc. May not be reproduced without permission from Kylowave Inc.
February 2013, Version 1.2.6 Page 31 of 31
K-ECS Order Information