owntech-foundation / control_library

control and dsp algorithms for owntech converters
GNU Lesser General Public License v2.1
0 stars 2 forks source link

Documentation of PID Controller: minor discrepancies compared to implementation #12

Open pierre-haessig opened 1 month ago

pierre-haessig commented 1 month ago

Hello,

I've found minor discrepancies between:

First, the filtered derivative is claimed to be implemented by the "exact" (using exp(-Ts/τ)) discretization of the low pass filter of time constant τ=Td/N (and by the way, τ is not documented). However, it is the backward Euler (as said in the doc) which is implemented. Here is a simplified copy of the code:

tau = Td / N;
b1_filter = Ts / (Ts + tau );
a1_filter = - tau / (Ts + tau);
filtered_deriv = b1_filter * deriv - a1_filter * previous_f_deriv;

Second, there is a special case for the integral when the controller output (the command) is saturated, see L109.

Now, I can make a PR to update the docs to reflect most of these things. Only, I'm not familiar with anti-windup schemes for integral feedback. So I would need some textbook/wikipedia reference to document this aspect.

pierre-haessig commented 1 month ago

I've notice that a similar discrepency applies to the fi

The doc says that the filter coefficients comes from exp(-Ts/τ). However, the implementation uses the Taylor series truncated to the 2nd order.