SlewRateLimiter

class SlewRateLimiter @JvmOverloads constructor(var positiveRateLimit: Double, var negativeRateLimit: Double, initialValue: Double = 0.0)(source)

A class that limits the rate of change of an input value. Useful for implementing voltage, setpoint, and/or output ramps. A slew-rate limit is most appropriate when the quantity being controlled is a velocity or a voltage.

Parameters

positiveRateLimit

The rate-of-change limit in the positive direction, in units per second. This is expected to be positive.

negativeRateLimit

The rate-of-change limit in the negative direction, in units per second. This is expected to be negative.

initialValue

The initial value of the input.

Constructors

Link copied to clipboard
constructor(positiveRateLimit: Double, negativeRateLimit: Double, initialValue: Double = 0.0)
constructor(rateLimit: Double)

Creates a new SlewRateLimiter with the given positive rate limit and negative rate limit of -rateLimit.

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun calculate(input: Double, timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow()): Double

Filters the input to limit its slew rate.

Link copied to clipboard
fun reset(value: Double, timestamp: ComparableTimeMark = TimeSource.Monotonic.markNow())

Resets the slew rate limiter to the specified value; ignores the rate limit when doing so.