Let's do now a simple exercise on the discrete time controller.
We need to have all the information that we have seen for a feedback controller.
In particular, we need to have the set point.
And let's say that it is 200.
We have the proportional, integral, and derivative gains.
These are equal to 2.
And then we have the sampling rate, given that this is a discrete time controller, which
is equal to 1 second.
And let's say that we have the first 3 sensor readings.
x1 is equal to 205.
x2 is equal to 204.
And x3 is equal 198.
So the question is, what is the control at time 3, u3?
In order to calculate this, we need then to apply the formula of the discrete
time PID controller.
This is equal to the proportional gain multiplied by
the error at time 3, plus the integral gain multiplied by the sampling rate Delta t,
multiplied by the sum of all the errors.
From time one to three.
And finally we have the derivative term.
The derivative gain multiplied by the error
at time 3 minus the error at time 2 divided by the sampling
rate.
Delta t.
Let's do the partial calculation of the error terms.
The error at time one is equal to the state at time 1 minus the set point.
This is equal to 205 - 200, which is equal to five.
Similarly for e2, we have that 204 minus the set point, 200, equal to 4.
And e3 is equal to 198 minus 200.
This is equal to minus 2.
Now we have all these values that we can plug in in our formula.
The proportional gain is 2, the error at time three is minus 2.
The integral gain is again 2, multiplied by Delta t which is 1.
And we have the sum of all the errors, so 5 + 4 + (-2).
We have finally the derivative term: 2 multiplied by (-2 - 4) divided by Delta T, which is equal
to 1.
Making all the calculations, the control at time 3 is equal to minus 2.