Rate limiter class.

Dependents:   BLDC_mainProgram L298N-Breakout-Test HBridgeDCMotor STMF302R8_MotorDrive ... more

Committer:
tbjazic
Date:
Wed Jan 14 08:49:46 2015 +0000
Revision:
0:d735360f91f9
Initial commit.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
tbjazic 0:d735360f91f9 1 #ifndef RATE_LIMITER_H
tbjazic 0:d735360f91f9 2 #define RATE_LIMITER_H
tbjazic 0:d735360f91f9 3
tbjazic 0:d735360f91f9 4 #include "mbed.h"
tbjazic 0:d735360f91f9 5
tbjazic 0:d735360f91f9 6 /** A rate limiter class.
tbjazic 0:d735360f91f9 7 *
tbjazic 0:d735360f91f9 8 * Author(s): TVZ Mechatronics Team
tbjazic 0:d735360f91f9 9 *
tbjazic 0:d735360f91f9 10 */
tbjazic 0:d735360f91f9 11 class RateLimiter {
tbjazic 0:d735360f91f9 12 public:
tbjazic 0:d735360f91f9 13 /** Default constructor */
tbjazic 0:d735360f91f9 14 RateLimiter ();
tbjazic 0:d735360f91f9 15 /** Constructor receives rising (R) and falling (F) rate limits,
tbjazic 0:d735360f91f9 16 * initial condition of the output and sample time in seconds. */
tbjazic 0:d735360f91f9 17 RateLimiter (float R, float F, float initialCondition, float sampleTime);
tbjazic 0:d735360f91f9 18 /** Setting the rate limits R and F. */
tbjazic 0:d735360f91f9 19 void setLimits (float R, float F);
tbjazic 0:d735360f91f9 20 void setLimits (float R, float F, float initialCondition, float sampleTime);
tbjazic 0:d735360f91f9 21 /** Calculating the output of the rate limiter for the given input. */
tbjazic 0:d735360f91f9 22 float out (float input);
tbjazic 0:d735360f91f9 23 /** Reset the output of the rate limiter to zero. */
tbjazic 0:d735360f91f9 24 void reset();
tbjazic 0:d735360f91f9 25 private:
tbjazic 0:d735360f91f9 26 float R, F, y0, y, T_d, rate;
tbjazic 0:d735360f91f9 27 };
tbjazic 0:d735360f91f9 28
tbjazic 0:d735360f91f9 29 #endif // RATE_LIMITER_H