-
Notifications
You must be signed in to change notification settings - Fork 0
/
333QVII.txt
58 lines (39 loc) · 2.03 KB
/
333QVII.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
1
ME333 Introduction to Mechatronics
Name: Alex P. Sharper
2022 Quiz 7: PID control
1. Give pseudocode for a basic PID controller (without integrator anti-windup).
There are functions get_ref() and get_sensor() to call, and you can make others if you want.
There are already global variables, and you can add more:
static volatile float eint = 0;
static volatile float eprevious = 0;
static volatile float edot = 0; // initialize derivative control
static volatile int counter = 0; // counter variable
sendControl(); // a function to send our updated control signal
The ISR is already setup to run at 1kHz:
__ISR(timer at 1kHz) {
// your code here:
s = get_sensor(counter);
r = get_ref(counter);
e = r - s; // error is difference between reference signal and sensor output
edot = e - eprevious; // edot is error difference
eint = eint + e; // eint is the sum of error over time
u = Kp*e + Kd*edot + Ki*eint; // control signal
sendControl(u); // send updated control
eprevious = e; // eprevious is for next interrupt is now the current error
counter = counter ++; // update counter
2. Explain what integrator anti-windup is:
Integrator anti-windup is essentially a bound on integral error that prevents eint from
growing to an absurd amount. This prevents oscillation that would otherwise be generated by the
control signal attempting to get rid of the integrated error.
3. You have picked Kp, Ki, and Kd gains.
a. The response has too much overshoot. Which gain could you increase to reduce the
overshoot?
// Kd should be increased to decrease overshoot.
b. The response has too much overshoot. Which gain could you decrease to reduce the
overshoot?
// Kp could be decreased to reduce overshoot.
c. The response has the right overshoot and settling time characteristics, but too much
steady-state error. Which gain could you increase to reduce the steady-state error?
Increasing Kp could decrease steady state error, but might add too much overshoot and oscillation.
Increasing Ki could reduce steady state error.