adapnex::core::TON

An on‐delay timer that delays the rising edge of a signal by a defined duration.

Synopsis

Declared in <adapnex/core/timer.h>

class TON;

Description

Output Q becomes true only after input IN has been true continuously for the duration PT. If IN goes false before PT elapses, the timer resets.

TON Timing Diagram

Parameter Type Direction Description

IN

bool

Input

Starts the timer with a rising edge and resets it with a falling edge.

PT

Duration

Input

The preset time that must pass before the output is set.

Q

bool

Output

Becomes true if IN is true and ET has reached PT.

ET

Duration

Output

The current elapsed time, incrementing up to PT while IN is active.

Common Use Case

Debouncing sensors or delaying a machine start sequence.

Example: Motor Start Delay

class MotorTask : public Task {
public:
    bool start_button = false;
    bool motor_on = false;

private:
    TON delay_timer;

    void Update() override {
        // If start_button is held for 2s, the motor turns on.
        delay_timer(start_button, 2s, motor_on);
    }
};

Timers maintain internal state across cycles and must be instantiated as member variables of a task rather than local variables within Update().

Member Functions

Name

Description

operator()

Function call operators

Data Members

Name

Description

ET

If IN is false, the ET output is 0. As soon as IN is true, the duration in ET is incremented until the value reaches PT. It then remains equal to PT.

IN

Input that starts the timer with a rising edge and resets the timer with a falling edge.

PT

Input defining the time that must pass before Q is set.

Q

Output that has a rising edge when the duration specified in PT has passed. Q is true, if IN is true and ET is equal to PT. Otherwise, Q is false.

Created with MrDocs