# Hysteresis
Hysteresis
V
O
# Eingänge
| ID | Kürzel | Name | Typ | Standard | Beschreibung |
|---|---|---|---|---|---|
value | V | value | NUMBER | 0 |
# Ausgänge
| ID | Kürzel | Name | Typ | Standard | Beschreibung |
|---|---|---|---|---|---|
output | O | output | BOOLEAN | false |
# Konfiguration
| ID | Name | Typ | Standard | Einheit | Beschreibung |
|---|---|---|---|---|---|
mode | mode | ENUM | 0 | Details: Werte: Midpoint + Hysteresis, Threshold (On/Off) | |
midpoint | midpoint | NUMBER | 50.0 | Details: Sichtbar wenn mode = Midpoint + Hysteresis | |
hysteresis | hysteresis | NUMBER | 5.0 | Details: Sichtbar wenn mode = Midpoint + Hysteresis> 0 | |
value_on | value_on | NUMBER | 55.0 | Details: Sichtbar wenn mode = Threshold (On/Off)neq value_off | |
value_off | value_off | NUMBER | 45.0 | Details: Sichtbar wenn mode = Threshold (On/Off)neq value_on |
# Quellcode
Volang-Quellcode anzeigen
value = input::get("value")
output = output::get("output")
mode = config::get("mode") // 0=midpoint+hysteresis, 1=threshold
new_output = false
if (mode == 0) { // Midpoint + Hysteresis
midpoint = config::get("midpoint")
hysteresis = config::get("hysteresis")
threshold_on = midpoint + hysteresis
threshold_off = midpoint - hysteresis
if (value >= threshold_on) {
new_output = true
} else if (value <= threshold_off) {
new_output = false
} else {
// In hysteresis range, maintain current state
new_output = output
}
} else if (mode == 1) { // Threshold (On/Off)
value_on = config::get("value_on")
value_off = config::get("value_off")
if (value_on > value_off) {
// Standard hysteresis: on when high, off when low
if (value >= value_on) {
new_output = true
} else if (value <= value_off) {
new_output = false
} else {
// In hysteresis range, maintain current state
new_output = output
}
} else {
// Inverted hysteresis: on when low, off when high (value_off > value_on)
if (value <= value_on) {
new_output = true
} else if (value >= value_off) {
new_output = false
} else {
// In hysteresis range, maintain current state
new_output = output
}
}
}
output::set("output", new_output)
