# Math::Random

Process

Generates a pseudo-random number in the range [0.0, 1.0) on each rising edge of the trigger.

Math::Random
T
O

# Inputs

IDAbbrevNameTypeDefaultDescription
triggerTTriggerBOOLEANfalseRising edge generates a new random number.

# Outputs

IDAbbrevNameTypeDefaultDescription
outputOOutputNUMBER0Random number in the range [0.0, 1.0).

# State

IDNameTypeDefaultUnitDescription
prev_triggerPrevious triggerBOOLEANfalsePrevious trigger value for rising edge detection.

# Source Code

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

if (channel == "trigger") {
    prev_trigger = state::get("prev_trigger")
    if (value and !prev_trigger) {
        output::set("output", math::random())
    }
    state::set("prev_trigger", value)
}
Generates a pseudo-random number in the range [0.0, 1.0) on each rising edge of the trigger.