adapnex::core::Hysteresis
Switches a boolean output based on two analog thresholds.
Synopsis
Declared in <adapnex/core/hysteresis.h>
template<typename T>
class Hysteresis;
Description
Implements hysteresis to prevent rapid switching when an input signal fluctuates near a threshold.
The block automatically adapts its logic based on the relationship between SET and RESET:
-
Direct (e.g. Cooling/High‐Alarm): If
SET > RESET,OUTbecomestruewhenINrises aboveSET, andfalsewhenINfalls belowRESET. -
Inverse (e.g. Heating/Low‐Alarm): If
SET <= RESET,OUTbecomestruewhenINfalls belowSET, andfalsewhenINrises aboveRESET.
| Parameter | Type | Direction | Description |
|---|---|---|---|
|
|
Input |
The signal to evaluate. |
|
|
Input |
Crossing this threshold sets |
|
|
Input |
Crossing this threshold resets |
|
|
Output |
The switching result based on the hysteresis logic. |
Common Use Case
Thermostat controlling a cooling fan or heating system to prevent short cycling.
Example: Temperature Control
class CoolingSystem : public Task {
public:
float current_temp = 0.0f;
bool fan_active = false;
private:
Hysteresis<float> temp_switch;
void Update() override {
// SET > RESET implies high threshold logic (turn ON at 30.0, turn OFF at 25.0).
temp_switch(current_temp, 30.0f, 25.0f, fan_active);
}
};
|
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 and thresholds. |
|
Input threshold that resets the output OUT to false when crossed. |
|
Input threshold that sets the output OUT to true when crossed. |
Created with MrDocs