# Edge detector

Verarbeitung
Edge detector
I
O

# Eingänge

IDKürzelNameTypStandardBeschreibung
inputIinputBOOLEANfalse

# Ausgänge

IDKürzelNameTypStandardBeschreibung
outputOoutputBOOLEANfalse

# Konfiguration

IDNameTypStandardEinheitBeschreibung
directiondirectionENUM0

Details:

Werte: Rising, Falling, Both
pulse_durationpulse_durationNUMBER0.1s

Details:

> 0
startup_delaystartup_delayNUMBER0s

Details:

≥ 0

# Zustand

IDNameTypStandardEinheitBeschreibung
prev_inputprev_inputBOOLEANfalse
initializedinitializedBOOLEANfalse

# Quellcode

Volang-Quellcode anzeigen
channel = input::channel()
value = input::value()

extern fn onPulseEnd() {
    output::set("output", false)
}

if (channel == "input") {
    prev_input = state::get("prev_input")
    initialized = state::get("initialized")

    if (!initialized) {
        state::set("prev_input", value)
        state::set("initialized", true)
        return
    }

    startup_delay = config::get("startup_delay")
    if (startup_delay > 0 and time::uptime() < startup_delay) {
        state::set("prev_input", value)
        return
    }

    direction = config::get("direction") // 0=Rising, 1=Falling, 2=Both
    edge_detected = false

    if (direction == 0) {
        edge_detected = value and !prev_input
    } else if (direction == 1) {
        edge_detected = !value and prev_input
    } else {
        edge_detected = (value and !prev_input) or (!value and prev_input)
    }

    state::set("prev_input", value)

    if (edge_detected) {
        callback::clear()
        output::set("output", true)
        pulse_ms = math::round(config::get("pulse_duration") * 1000)
        callback::set(pulse_ms, "onPulseEnd")
    }
}
Erfahren Sie, wie der Logikbaustein Edge detector funktioniert, wann Sie ihn einsetzen und wie Sie ihn in Ihrer Voldeno Smart-Home-Automatisierung konfigurieren.