/ src / hal / components / integ.comp
integ.comp
 1  component integ "Integrator with gain pin and windup limits";
 2  pin in float in;
 3  pin in float gain = 1.0;
 4  pin out float out "The discrete integral of 'gain * in' since 'reset' was deasserted";
 5  pin in bit reset "When asserted, set out to 0";
 6  pin in float max_ =  1e20;
 7  
 8  pin in float min_ = -1e20;
 9  function _;
10  license "GPL";
11  ;;
12  FUNCTION(_) {
13      if(reset) out = 0;
14      else out = out + gain * in * fperiod;
15      if (out > max_) out = max_;
16      if (out < min_) out = min_;
17  }