2019 Lecture5 - MotorControl
2019 Lecture5 - MotorControl
www.freshwatersystems.com
K
• … Where does the gain value K come from?
K
• … Where does the gain value K come from?
– Calibration (example: PWM = 0, PWM = 255)
• Under what conditions will FF control work well?
– When the presented load is uniform and known
Feedback Control
• Feedback controller:
– output = FB(error)
– error = goal state - measured state
– controller attempts to minimise error
• Feedback control requires sensors:
– Binary (at goal/not at goal)
– Direction (less than/greater than)
– Magnitude (very bad, bad, good)
Example: Wall Following
• How would you use feedback control to
implement a wall-following behavior in a robot?
Feedback Sensor
• Error signal e(t) = SP-PV: error in the process
variable at time t, computed via Feedback
• Control signal u(t): controller output (value of
switch, voltage, PWM, throttle, steer angle, …)
*Set point is sometimes called the “Reference”
Bang-bang control
• Discrete on/off
• Furnace: goal
temp = 70
• when temp < 70
BANG! Heat;
• when temp >
70 BANG! Stop
the heat
Temperature Sensor
Example: Home Heating System
• Plant P: Boiler with on-off switch (1 = all on ; 0 = all off)
• Process Variable PV: Current home temperature
• Controller: Thermostat Sensor: Thermometer
• Set Point SP: Thermostat setting (desired temp.)
• Control signal: Boiler on-off switch u(t) ∈ {0, 1}
e(t) u(t)
SP - Thermostat Boiler PV
Temperature Sensor
Temperature Sensor
Encoder measurement
Motor Control: PID
• Control theory is the science that studies the
behavior of control systems
• CurrentState - DesiredState = Error
• Main types of simple linear controllers:
– P: proportional control
– PD: proportional derivative control
– PI: proportional integral control
– PID: proportional integral derivative control
Car Example
Proportional Control
• Suppose plant can be commanded by a
continuous, rather than discrete, signal
– Valve position to a pipeline or carburetor
– Throttle to an internal combustion engine
– PWM value to a DC motor
• What’s a natural thing to try?
– Proportional (P) Control: make the command signal
a scalar multiple of the error term: u(t) = KP e(t)
e(t) u(t)
SP - Controller Plant PV
Sensor
Example: Cruise Control (CC) System
• Plant P:
• Process Variable PV:
• Controller: Sensor:
• Set Point SP:
• Control signal:
e(t) u(t)
Vdesired - C-C System Engine Vactual
Speedometer
Example: Cruise Control (CC) System
• Plant P: Engine with throttle setting u ∈ [0..1]
• Process Variable PV: Current speed Vactual
• Controller: C-C system Sensor: Speedometer
• Set Point SP: Desired speed Vdesired
• Control signal: Continuous throttle value u ∈ [0..1]
e(t) u(t)
Vdesired - C-C System Engine Vactual
Speedometer
Set Delay
Point
Error (E)
Process
Variable
Step
input Error (E)
When E = 0, plant turns off, so E grows, so plant turns on, etc etc.
This reaches an equilibrium with a constant E.
Proportional Control and Error
• Can combat E by increasing KP (“the P gain”)
• This gives a faster response and lower E!
• But increasing the gain too much leads to
overshoot and instability
Higher KP
Step
Set input
Point
Low KP
Process
Variable Time
Combating Overshoot: The D Term
• Note the derivative of error in responses below
• Subtract it from output to counteract overshoot
• Then u(t) = KP e(t) + KD d [e(t)] / dt
– KD the “derivative” or “damping” term in PD controller
Step Higher KP
Set input
Damped response, KD > 0
Point
Low KP
Small derivative
Process Large derivative
Variable Time
KI
d/dt KD
e(t) u(t)
SP - Plant PV
KP
KI
KP KI KD
P 0.5KC
PI 0.45KC 1.2KP/TC
PID 0.5KC 2KP/TC KPTC/8
Z & N developed rule using Monte Carlo method
Rule useful in the absence of models
Critical Gain (Verge of instability)
Control summary
Control type Feedback Pro/Con
Bang- Simple
bang discrete yes /
Discrete
Open Simple/may
loop Control law no be
unrepeatable
Closed Continuous/
loop P, I, D yes Tune Gains
Velocity PID Controller