adapnex::core::HysteresisWithDelay
Switches a boolean output based on analog thresholds and an on‐delay filter.
Synopsis
Declared in <adapnex/core/hysteresis.h>
template<typename T>
class HysteresisWithDelay;
Description
Combines hysteresis switching with a time delay filter on both transitions. The input IN must cross and remain beyond the threshold for the duration PT before the output OUT switches state.
The block automatically adapts its logic based on the relationship between SET and RESET:
-
Direct (e.g. Cooling/High‐Alarm): If
SET > RESET,OUTbecomestruewhenINrises aboveSETforPT, andfalsewhenINfalls belowRESETforPT. -
Inverse (e.g. Heating/Low‐Alarm): If
SET <= RESET,OUTbecomestruewhenINfalls belowSETforPT, andfalsewhenINrises aboveRESETforPT.
| Parameter | Type | Direction | Description |
|---|---|---|---|
|
|
Input |
The signal to evaluate. |
|
|
Input |
Sets |
|
|
Input |
Resets |
|
|
Input |
The delay duration required to confirm a state change. |
|
|
Output |
The filtered switching result. |
Common Use Case
Liquid level control in a tank with surface turbulence where splashing must not trigger false switching.
Example: Tank Refill Control
class RefillTask : public Task {
public:
double tank_level = 0.0;
bool valve_open = false;
private:
HysteresisWithDelay<double> level_switch;
void Update() override {
// SET < RESET implies low threshold logic (refill).
// Level must remain beyond threshold for 2 seconds (PT) to ignore waves.
level_switch(tank_level, 10.0, 90.0, 2s, valve_open);
}
};
|
Both SET > RESET and SET < RESET are allowed. The implementation adapts the comparisons accordingly. |
|
Hysteresis blocks maintain state across cycles and must be instantiated as member variables of a task rather than locally within Update(). |
Data Members
Name |
Description |
Input value that is evaluated. |
|
Output that switches between true and false depending on the input value, thresholds and delay. |
|
Input duration that delays the effect of crossing the thresholds. |
|
Input threshold that resets the output OUT to false when crossed for a duration defined by PT. |
|
Input threshold that sets the output OUT to true when crossed for a duration defined by PT. |
Created with MrDocs