Menu
CoddyTech

TOF and TP in Text

Part of the Structured Text section of Coddy's PLC Programming journey. Lesson 7 of 17.

The other two timers are called the same way, with IN and PT. Only the type changes:

  • TOF: Q turns on with IN and stays on for PT after IN turns off (off-delay).
  • TP: a rising IN starts a pulse; Q stays on for exactly PT, however long IN is held.
VAR
    RunOn : TOF;
    Beep : TP;
END_VAR

RunOn(IN := PB1, PT := T#3s);
Amber := RunOn.Q;

Give each timer its own name. One instance is one timer: it holds its own time between scans, so two jobs need two instances.

challenge icon

Challenge

Easy
  • Amber lights with PB1 and stays lit 3 s after it is released.
  • Each press of PB2 sounds Horn for exactly 1 s, short tap or long hold.

Try it yourself

VAR
    RunOn : TOF;
    Beep : TP;
END_VAR

// The run-on for Amber

// The beep for Horn

All lessons in Structured Text

Practice on your own: PLC playground