0

I have been trying to implement a controller for a plant with a Cortex M3 microcontroller.

On the road to implementing a digital controller, some questions have come up that I couldn't answer from the books and papers.

First and foremost, when they are about to calculate the actuation, why do they forget to add the previous actuation?

I mean that they use the following formulation:

$$I[k] = I_f*I[k-1]+e[k]$$ $$u[k]=K_p⋅e[k]+K_i.I[k]+K_d(e[k]−e[k−1])$$

Instead of this one:

$$u[k]=u[k-1]+K_p⋅e[k]+K_i.I[k]+K_d(e[k]−e[k−1])$$

Where \$I_f\$ is the forgetting factor, by which I mean when someone uses the first formulation, he or she neglects that if the actuation is omitted, why should an actuator work?

The second problem is system model identification.

Nearly 99.99 percent of the plants on Earth are not supposed to be LTI but NLTV, so dynamic model calculation should be in order.

Suppose that one can measure the output by sensors and that one knows the actuation that forced to the actuator, what remains is the actuator input calculation. The same scenario of the previous problem happened to me. Almost all of the text I have found tried to calculate the output instead of the calculation of the actuator input. I don't understand why they don't consider the case when the states are measurable. No matter what is the type of controller (PID, MPC, adaptive, robust, non-linear.)

In the case of PID, suppose previous input and output data are available. One uses LS or RLS on each time interval regardless of being converged and finds a model as follows:

$$ y(k) = z^T(k)\theta(k) + \zeta(k)$$

In another formulation:

$$ A(z)Y(z)=B(z)U(Z)$$

How should the formulation be changed in other to use the controller? Moreover, how should the controller coefficient be calculated?

What I mean is to avoid a large calculation since the computation power is not as much as when using Matlab with power to calculate matrices.

JRE
  • 67,678
  • 8
  • 104
  • 179
V.Ajall
  • 69
  • 4
  • @jay About the first one, both of them could be used with or without \$(1-I_f)\$ term, but the one with seems more logical. About the second one, the controller task is to calculate the actuator or driver input value. It is not to only calculate the difference of actuation. What or who should accumulate the difference of activation on two-time steps of one after another? – V.Ajall Oct 05 '21 at 17:08
  • 1
    Never hear of If - forgetting factor on integral part, but the 1st implementation may work, while the 2nd is totally wrong. You can read some my answers, you'll find that actually there are many types of implementation. https://electronics.stackexchange.com/a/486632/82111 and https://electronics.stackexchange.com/a/550762/82111 I don't fully understand the rest of your question. – Marko Buršič Oct 05 '21 at 17:17
  • "[]=[−1] + " is an accumulator / Integrator. People does generate a differential format, Mv', not Mv, for that. So, u[k] = u[k-1] + Mv'. "actuator or driver input value" is often called "manipulation value" and denoted "Mv". It is convenient to consider the "scaling" outside of the algorithm. Thus, people often use "normalized" scale, like 0.0 to 1.0, or 0% to 100%. – jay Oct 05 '21 at 17:21
  • @MarkoBuršič I thought that, too, a little hesitated to ask. I had my own algorithm with "forget factor" for decades, but it has been private, never went to a paper. – jay Oct 05 '21 at 17:23
  • @jay Thank you for your clarification, not behind the system of the plant, will check the suggestion the first time I reach the plant. I am familiar with the term manipulation value, but I think the U itself should be called the manipulation value. – V.Ajall Oct 05 '21 at 17:28
  • @MarkoBuršič Integral part is more tended to make the system unstable since it may result in divergence and furthermore, it adds inertia to the plant. So the integral part of control should forget as soon what it had seen. – V.Ajall Oct 05 '21 at 17:33
  • 1
    @V.Ajall , I suppose Marko would disagree, about the integral part, will leave it to Marko. However, your statements are not correct. Integral part works the other way around. Whatever it is, the "forget factor" I have been using is different, why I did not mention. I wonder where you picked up that "forget factor". Would you, please & please, tell? – jay Oct 05 '21 at 17:38
  • 1
    @jay It returns back to the time I was studying the BS(5 years ago) and the master at that time told us there should be a forgetting factor. The course was "Digital control systems, analysis, and design". – V.Ajall Oct 05 '21 at 18:00
  • Thanks V.Ajall, meantime, back from the lunch break, I realized I was less right.. to totally incorrect, about the (1 - If). as @MarkoBuršič said, it is fine as you wrote. I am terribly sorry. Momentarily, I was thinking of an IIR filter, I think. So, I am deleting that embarrassing comment up there. – jay Oct 05 '21 at 19:10
  • 1
    @jay I can easily see why you were thinking of an IIR. First thing I thought of when reading "forgetting factor." – jonk Oct 05 '21 at 19:23
  • @jonk...Ow.. So, the moment of timing, I post the last comment, and you were in that "forgetting factor" -> IIR? thoughts.. :-) Thanks!! – jay Oct 05 '21 at 19:28
  • 3
    "forget factor" is an awful idea by someone who does not understand the purpose of integral term, which is to provide **stable state offset**. For example to counteract thermal plant's heat loses, or vane effect of cross wind on a helicopter. If you keep forgetting previously integrated value you basically allow an error to creep in again to replenish the term, thus causing oscillations for no reason – Maple Dec 18 '21 at 06:54

1 Answers1

1

So after some experiments, it would be helpful for others here to share the experience. If someone is to implement a PID controller, he or she has three options. The first is to drive the system continuously in analog with opamps, resistors, and capacitors. The second is to drive the system in quasi-continuous with the first formulation in the question, and the third is to drive the system fully digital with the following formulation. $$out(z^{-1}) = (K_p+K_i.\frac{1}{1-z^{-1}}+K_d.\frac{z^{-1}}{1-z^{-1}})e(z^{-1})$$ $$u[k]=u[k−1]+K_p⋅(e[k]−e[k−1])+K_i.e[k]+K_d.e[k-1]$$ In this case the forgetting factor is nonsense.

If it is considered to implement a P controller the formula will be $$u[k]=K_p.e[k]$$

V.Ajall
  • 69
  • 4