What's the point of creating discrete control laws for analog processes?

349 Views Asked by At

Assume that we have a state space model of a real system e.g mass-spring system.

$$\dot x = Ax + Bu$$

Then we want to implement this in a micro controller. The controller has a sampling rate of $h = 1$. So we turn our state model to a discrete one.

$$x(k+1) = A_d x(k) + B_d u(k)$$

Then we find our control law $L$:

$$u = -Lx(k) + r$$

Where $r$ is our reference vector.

Let's do this in an example. I going to use only MATLAB-code with Matavecontrol library.

First I create my model and discrete model.

sys = ss(0, [0 1; -2 -0.5], [0; 1], [1 0]); % SS-model with delay 0
h = 1; % Sampling rate
sysd = c2d(sys, h); % Discrete SS-model
Q = [1 0; 0 2];
R = 1; 

Then I create a discrete state feedback and do a step simulation.

Ld = lqr(sysd, Q, R); % Find the control law
sysdlqr = reg(sysd, Ld); % Create the state feedback system 
step(sysdlqr, 20); % Simulate the system with a step signal

The result looks like:

enter image description here

Quite good!

Not I will use that control law the the time continuous model.

syslqr1 = reg(sys, Ld); % Use the same control law but with the SS-model
figure(2); 
step(syslqr1, 20); % Do a nother step simulation

The result looks like:

enter image description here

Not so good. To much over shoot.

Now I will create a control law from the time continuous model.

Ls = lqr(sys, Q, R); % Create a time continous control law
syslqr2 = reg(sys, Ls); % Use the control law with the SS-model
figure(3); 
step(syslqr2, 20); % Do a nother step simulation

enter image description here

Very good. Looks like the discrete one.

Question

What's the point of creating a discrete control law for time continuous process? I can buy the argument to use a discrete control law with a time continuous process if it's going to handle about Model Predictive Controller - they need a discrete model to predict the future.

Today, micro controllers are really fast. So tell me why I should use discrete control laws when time continuous control law works good too?

3

There are 3 best solutions below

6
On BEST ANSWER

Usually when actuating a continuous system with a digital controller the control input $u$ is constant between sample times (this is also what c2d assumes if the method of discretization is not specified). So even though at the start of the sampling time the same state information is available to both controller, the discrete controller effectively considers the effect of keeping that input constant during one sampling period, while for the continuous state feedback it assumes that the control input also changes continuously.

But if during one sample time the state does not change much, they are roughly equivalent. This happens when the closed and open-loop poles are significantly above the sample frequency. This also holds for other discretization methods as well. For example when considering your continuous system and cost matrices $Q$ and $R$, then in the figure below you can see the 2-norm of the difference between the $K$ matrices obtained from continuous and discrete LQR for different discretization methods as a function of the sample frequency. From that figure you can see that the 2-norm goes to zero as the sample frequency goes to infinity (or the sample time goes to zero) for all used methods with the exception of the matched poles method.

enter image description here


Another way of comparing continuous and discrete systems is to use the same $K$ matrix and quadratic Lyapunov function for both and compare the resulting derivative of the Lyapunov function. So find a stabilizing $K$ for the continuous system, for example with LQR or pole placement, and a Lyapunov $V(x) = x^\top P\,x$ function which satisfies

$$ P\,(A - B\,K) + (A - B\,K)^\top P = -Q, $$

with $Q$ semi-positive definite. The derivative of the Lyapunov function for the continuous system is then simply $\dot{V}(x) = -x^\top Q\,x$. For the discretized system the derivative of the Lyapunov function can be approximated with

$$ \dot{V}(x) \approx x^\top \underbrace{\left[\frac{(A_d - B_d\,K)^\top P\,(A_d - B_d\,K) - P}{h}\right]}_{-Q_d}\,x. $$

Using again your system then the resulting 2-norm of $Q - Q_d$ for different discretization methods as a function of the sample frequency can be seen in the figure below. From that figure you can again see that the 2-norm goes to zero as the sample frequency goes to infinity for all used methods with again the exception of the matched poles method.

enter image description here

5
On

Of course this is just a ultra-simple model and you cannot see advantages.

In a bit more sophisticated system, advantages of digital vs. analog would come from the possibility to easily implement filters / particular transfer functions, read from digital transducers, memorize the input / output etc.

And, also consider that sampling (appropriately) over a non-small $\Delta t$ is a filtering in itself.

0
On

To complement the other answers, your evaluation of the discrete and continous plant is not correct.

Matlab or any software while evaluating the simulation values uses the discretized plant. Hence what you are seeing is the sampled version of the same not quite good response with half sample delay.

Even if your system is continuous, the sensors and actuators are still discrete and if you are not careful you destabilize your system with a too slow sampling rate. Especially c2d command leads to unstable plants since it uses zoh by default which is not stability invariant. Thus you have to make sure that you have discretized things properly before comparing them.