Skip to content

PID controller pre-calculated Ki_Ts not possible ? #12

Description

@lole-elol

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 ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions