Hi Pieter,
first, thanks for your great article and deep introduction to this topic.
However, I cannot quite follow you in one point, in the provided Implementation for the PID controller you are using Ki already multiplied by Ts.
For the integral, you provided the following expression:
$$e_i[k] = e_i[k-1] +T_s e[k-1] $$
In the code, the integral is computed as
int32_t newIntegral = integral + error
and then added to the PID algorithm as
bool backward = false;
int32_t calcIntegral = backward ? newIntegral : integral; // will always evaluate to integral
int_32_t output = kp* error + ki_ts * integral,
integral = newIntegral;
I don't understand how this implementation corresponds to the mathematical expression.
From my point of view, it should be implemented as follows
int32_t newIntegral = integral + error * Ts
int_32_t output = kp* error + ki * integral,
integral = newIntegral;
Maybe I'm overlooking something, could someone help me out here ?
Hi Pieter,
first, thanks for your great article and deep introduction to this topic.
However, I cannot quite follow you in one point, in the provided Implementation for the PID controller you are using Ki already multiplied by Ts.
For the integral, you provided the following expression:
$$e_i[k] = e_i[k-1] +T_s e[k-1] $$
In the code, the integral is computed as
int32_t newIntegral = integral + errorand then added to the PID algorithm as
I don't understand how this implementation corresponds to the mathematical expression.
From my point of view, it should be implemented as follows
Maybe I'm overlooking something, could someone help me out here ?