# Pulse throttle

Process

Suppresses repeated pulses within a configurable discard period. The first pulse passes through and starts a cooldown window during which subsequent pulses are dropped. Useful for debouncing noisy signals or rate-limiting pulse outputs.

Pulse throttle
I
O

# Inputs

IDAbbrevNameTypeDefaultDescription
inputIInputBOOLEANfalsePulse signal. Only rising edges that arrive outside the discard period are forwarded.

# Outputs

IDAbbrevNameTypeDefaultDescription
outputOOutputBOOLEANfalseThrottled pulse output. Mirrors the forwarded pulse shape.

# Configuration

IDNameTypeDefaultUnitDescription
discard_periodDiscard periodNUMBER0sCooldown window in seconds after forwarding a pulse. Pulses arriving during this window are dropped. Set to 0 to disable throttling.

Details:

≥ 0

# State

IDNameTypeDefaultUnitDescription
prev_inputPrevious input stateBOOLEANfalseStores the previous state of the input to detect rising and falling edges.
discardingDiscardingBOOLEANfalseWhether the block is currently in the cooldown window.

# Source Code

View Volang source
channel = input::channel()
value = input::value()

extern fn onCallback(v) {
    state::set("discarding", false)
}

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

    if (value and !prev_input) {
        discarding = state::get("discarding")
        if (!discarding) {
            output::set("output", true)

            discard_ms = math::round(config::get("discard_period") * 1000)
            if (discard_ms > 0) {
                state::set("discarding", true)
                callback::set(discard_ms, "onCallback", 0)
            }
        }
    }

    if (!value and prev_input) {
        output::set("output", false)
    }

    state::set("prev_input", value)
}
Suppresses repeated pulses within a configurable discard period. The first pulse passes through and starts a cooldown window during which subsequent pulses are dropped. Useful for debouncing noisy signals or rate-limiting pulse outputs.