CSCI1600: Embedded and Real Time Software Lecture 28: Verification I Steven Reiss, Fall 2015.
CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback...
-
Upload
christine-gregory -
Category
Documents
-
view
215 -
download
0
Transcript of CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback...
![Page 1: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/1.jpg)
CSCI1600: Embedded and Real Time SoftwareLecture 12: Modeling V: Control Systems and Feedback
Steven Reiss, Fall 2015
![Page 2: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/2.jpg)
Control Systems Desired output value: target value
Actual output value: measured value
Actuator input: controls the plant’s behavior
Error: desired - actual
![Page 3: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/3.jpg)
Control Variables
The actuator input can be binary or continuous Amount of heat, turn, gas, …
Turn left/right, turn on heat, accelerate
The outputs (and error) can be a vector or a scalar Optimize for a single factor (speed, temperature, …)
Optimize for multiple factors (temp + humidity, …)
![Page 4: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/4.jpg)
On-Off Control
Suppose we do the simple thing for a heater If actual temp < target then turn on heater, else off
What is going to happen to the temperature Overshoot
Time to heat up (undershoot)
Oscillation
![Page 5: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/5.jpg)
Smarter On-Off Control
A little more sophisticated temp < target – delta1 : HEAT ON
temp >= target – delta2 : HEAT OFF
temp > target + delta3 : COOL ON
temp <= target + delta4 : COOL OFF
What’s going to happen here What is it is very cold (hot) outside
![Page 6: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/6.jpg)
Proportional Control
Suppose we have control over the actuator Can give it a range of values (low/high, continuous, …)
Acceleration in a car, heater with low/high flame (emergency mode), variable speed fan
What would we want to do in that case
![Page 7: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/7.jpg)
Proportional Control
Make the actuator input proportional to the error Large error -> large input (accelerate fast)
Small error -> small input (accelerate slow)
No error -> do nothing
Assume doing nothing drives system the other way
Or that there is a corresponding input on the other side
Actuator = Kp * Error
![Page 8: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/8.jpg)
Problem: What should Kp be
Should be > 0
Actual value depends on the system
How could you determine the value? Modeling
Mathematics
Experimentation
![Page 9: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/9.jpg)
Is This Sufficient
Will it eliminate overshoot, oscillation, slow rise time Depends on the actual system
If the system is not perfectly linear or the actuator is not immediate, then probably not
We can do better
![Page 10: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/10.jpg)
Proportional-Derivative Control
A and B are two situations leading to point T
What should the output be for each?
![Page 11: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/11.jpg)
Proportional-Derivative Control
Want to take the rate of change into account Fast rate – slow down the response
Slow rate – speed up the response
Actuator = Kp * error - Kd * deriv deriv = the derivative of the error
deriv = change in error over time
deriv = change in error from last time to this
![Page 12: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/12.jpg)
Choosing Kp and Kd
Now we have two parameters to determine How could you do this
Generally Kd is > Kp Note the Kd is subtracted, but stated as positive
![Page 13: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/13.jpg)
Is This Sufficient
Steady state error How could this occur
![Page 14: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/14.jpg)
Determining Steady State Error
Look at the sum of the error In the past
Not necessarily full past
Or constrain in bounds
This is the integral of the error How might you compute this
![Page 15: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/15.jpg)
Computing Integral of Error
Approximate with sum integ = integ + error;
if (integ > MAX) integ = MAX;
else if (integ < MIN) integ = MIN
Actuator = Kp*error – Kd*deriv + Ki*integ
Ki now needs to be chosen Typically much smaller than Kp
![Page 16: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/16.jpg)
Issues in Controllers
Actual input might have a limit range/set of values Set the actuator to the nearest value
Off/on based on threshold
Sampling rate affects the computation Might want to average the derivative
Computations are typically non-integer
![Page 17: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/17.jpg)
Understanding PID
http://demonstrations.wolfram.com/PIDControlOfATankLevel
http://sites.google.com/site/fpgaandco/pid
![Page 18: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/18.jpg)
PID Tuning
Set Ki=0, Kd=0, Kp=1
Increase Kp until the actual oscillates with a constant amplitude Let U = this Kp
Let P = oscillation period (in seconds)
Set Kp = U/1.7, Ki = (Kp*2), Kd = (Kp*P)/8
![Page 19: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/19.jpg)
PID Tuning
In general requires a bit of sophistication Control theory
Control system design
Control engineers
![Page 20: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/20.jpg)
For More Information
Wikipedia : PID
http://www.embedded.com/design/embedded/4211211/PID-without-a-PhD
![Page 21: CSCI1600: Embedded and Real Time Software Lecture 12: Modeling V: Control Systems and Feedback Steven Reiss, Fall 2015.](https://reader036.fdocuments.us/reader036/viewer/2022062423/5697bf841a28abf838c871e7/html5/thumbnails/21.jpg)
Homework
Design a SIMON game https://www.youtube.com/watch?v=4YhVyt4q5HI
What are the tasks
What types of models are appropriate
Develop appropriate models (of at least one task)
Be prepared to show and explain models for the tasks
Be prepared to hand in the models