summaryrefslogtreecommitdiff
path: root/src/hal/components/integ.comp
blob: 3b8c3d2b48da9dd9ae126684bc9427a24737b457 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
component integ "Integrator with gain pin and windup limits";
pin in float in;
pin in float gain = 1.0;
pin out float out "The discrete integral of 'gain * in' since 'reset' was deasserted";
pin in bit reset "When asserted, set out to 0";
pin in float max_ =  1e20;

pin in float min_ = -1e20;
function _;
license "GPL";
;;
FUNCTION(_) {
    if(reset) out = 0;
    else out = out + gain * in * fperiod;
    if (out > max_) out = max_;
    if (out < min_) out = min_;
}