Back to examples

Program notes

Lighting Off-Delay

TOF holds the lighting output on for a delay after its command clears.

1. What the Program Does

This example delays switching lighting off. While Light_Command is active, Light_Output is on. When the command clears, a TOF timer holds the output TRUE for a preset number of scans.

The same pattern can delay stopping a lamp, fan, siren, or auxiliary mechanism after its command ends.

Light_Command → TOF_Light_Delay → Light_Output

2. Example Signals

SignalTypePurpose
Light_CommandInputLighting on command
TOF_Light_DelayBlockOff-delay timer
Light_OutputOutputFinal lighting output

3. Main Logic

TOF is an off-delay timer. Light_Command TRUE makes Q TRUE immediately. When the command becomes FALSE, Q stays TRUE until the preset delay has elapsed.

This example uses PT_SCANS = 100.

4. Testing in the Simulator

  • Activate Light_Command: Light_Output immediately becomes TRUE.
  • Clear Light_Command: Light_Output remains TRUE during the delay.
  • Observe successive scans while the output is held.
  • Reactivate Light_Command before the delay expires: the timer returns to its active state.
  • Let the complete off-delay expire: the output becomes FALSE.

5. What to Watch For

TON delays turning on; TOF delays turning off. This program needs TOF because lighting should turn on immediately and turn off after a delay.

Real systems usually specify delays in milliseconds or seconds. This JSON stores a number of logical scans for deterministic simulator behaviour.

Check in editor

Open the ready-made FBD diagram, toggle inputs, and compare the simulation behavior with the program notes. The JSON is also available as a direct download.