IAE Academy

FOR CORE AND IT JOBS · CHAPTER 4 OF 7

Timers, counters and sequences

This chapter explains how a PLC measures time, counts events and runs a machine through ordered steps. You need it whenever a process must wait, count parts or do things in a set order.

Updated 30 Oct 2026

What you will be able to do

You will read how on-delay, off-delay and pulse timers behave from a timing table. You will count with up, down and up-down counters, using an edge so that each event counts once. You will write a sequence as a step table and then as ladder rungs.

Before you start

  1. Chapter 3, Ladder logic

  2. Boolean AND and NOT, written (A AND B) and (NOT A)

  3. Whole numbers and the inequalities ≥, ≤ and <

Timers: on-delay, off-delay and pulse

A PLC runs its program in scans: it reads the inputs, runs the rungs from top to bottom, writes the outputs, and starts again. A timer turns a duration into a bit. It has an input IN, a preset PT (the time to wait), an elapsed time ET updated every scan, and an output Q, written T1.Q for a timer named T1. In a rung, a timer is a box in place of a coil: the contacts before it drive IN, and T1.Q can be used as a contact in any rung. Addresses are in IEC style (%I0.0 an input bit, %Q0.0 an output bit, %M0.0 a memory bit); some PLC families write them differently.

ON-DELAY TIMER (TON)

IN and Q are bits; PT and ET are in seconds. While IN = 1, ET rises from 0 and stops at PT; when IN = 0, ET returns to 0 at once. So Q turns on PT seconds after IN rises, if IN stays 1 that long, and off when IN falls.

OFF-DELAY TIMER (TOF)

Symbols and units as for TON. While IN = 1, ET = 0. When IN falls, ET runs from 0 and Q stays 1 until ET reaches PT; then Q = 0 and ET holds at PT until IN rises. At power-on, before IN first rises, Q = 0 and ET = 0.

PULSE TIMER (TP)

Symbols and units as for TON. A rising edge (IN going from 0 to 1) starts ET from 0, and Q = 1 for PT seconds whatever IN does; edges during the pulse are ignored. Then Q = 0, and ET holds at PT while IN = 1 and returns to 0 once IN = 0.

The table feeds one input to all three timers, each with PT = 2 s. IN is 1 from 1 s to 2 s and from 5 s to 10 s. Each cell gives ET in seconds, then Q; "0 to 1" means ET rises from 0 s to 1 s.

Time (s)

IN

TON ET / Q

TOF ET / Q

TP ET / Q

0 to 1

0

0 / 0

0 / 0

0 / 0

1 to 2

1

0 to 1 / 0

0 / 1

0 to 1 / 1

2 to 3

0

0 / 0

0 to 1 / 1

1 to 2 / 1

3 to 4

0

0 / 0

1 to 2 / 1

0 / 0

4 to 5

0

0 / 0

2 / 0

0 / 0

5 to 7

1

0 to 2 / 0

0 / 1

0 to 2 / 1

7 to 10

1

2 / 1

0 / 1

2 / 0

10 to 12

0

0 / 0

0 to 2 / 1

0 / 0

after 12

0

0 / 0

2 / 0

0 / 0

WORKED EXAMPLE

A start switch %I0.0 is closed from t = 2 s to t = 9 s. A TON named T1 has IN = %I0.0 and PT = 5 s, and one rung drives the motor: %Q0.0 = T1.Q. When does the motor run? When would it run if the switch opened at 6 s instead?

Solution
  1. IN rises at 2 s, so T1 starts timing: ET = t - 2 s while the switch stays closed.

  2. ET reaches PT = 5 s at t = 7 s, so T1.Q turns on, and the rung turns the motor on with it.

  3. At 9 s IN falls, and a TON then sets ET and Q to 0 at once, so the motor stops.

  4. Opening at 6 s, ET reaches only 4 s, below PT, before returning to 0, so Q never turns on.

Answer: The motor runs from 7 s to 9 s. If the switch opened at 6 s, it would not run at all.

Counters and edge detection

A counter holds a whole number, the count CV, and compares it with a preset PV. Its inputs are CU (count up), CD (count down), R (reset to 0) and LD (load the preset). CU and CD react to edges, not levels. A rising edge is a scan in which a signal is 1 and was 0 in the previous scan; a falling edge is the opposite. A part that blocks a sensor for many scans gives one rising edge, so it is counted once.

EDGE DETECTION

All are bits. CLK is the signal in this scan; is its value in the previous scan, kept in a memory bit. Q is 1 for one scan per edge, since by the next scan has caught up. The IEC blocks R_TRIG and F_TRIG do this; their Q can be used as a contact.

UP COUNTER (CTU)

is the count after scan k; R and the edge of CU are read in the next scan. CV and PV are whole numbers. A reset wins over a count in the same scan. Q = 1 while CV ≥ PV, and CV keeps rising past PV up to the largest value the counter can hold.

DOWN COUNTER (CTD)

Symbols as for CTU. LD = 1 puts PV into CV and wins over a count; each rising edge of CD then lowers CV by one. Q = 1 while CV ≤ 0. Further edges take CV below 0, so act on Q, not on CV = 0.

UP-DOWN COUNTER (CTUD)

This formula applies only when R = 0 and LD = 0. R = 1 sets CV to 0 and wins over LD; LD = 1 sets CV to PV. [x] is 1 when x is true, else 0, so rising edges on CU and CD in one scan cancel.

Sequences: steps, transitions and rungs

Here a sequence is a machine that is in exactly one step at a time. Write it first as a step table: each step, its outputs, and the transition (the condition) that moves it on. Then each step becomes one memory bit, and each transition one rung that sets the next step's bit and resets its own. The plant is a conveyor with a sorting gate. In the rung table, NO and NC are normally open and normally closed contacts.

  1. Conveyor motor, output %Q0.0: 1 runs the belt.

  2. Gate cylinder, output %Q0.1: 1 pushes a box off the belt.

  3. Start push button, input %I0.0, normally open.

  4. Box sensor at the gate, input %I0.1: 1 while a box is there.

Step

State

Bit

Outputs on

Transition

Next

S0

Idle

%M1.0

none

%I0.0 (start)

S1

S1

Belt runs

%M1.1

%Q0.0

%I0.1 (box at gate)

S2

S2

Gate pushes

%M1.2

%Q0.1

T1.Q (2 s elapsed)

S1

STEP TRANSITION RULE

is the bit of the active step, the transition condition that leaves it, the bit of the step it leads to; ← means a set or reset coil. If all step bits are 0, as at power-on, the last rung sets S0, so after the first scan exactly one step bit is 1.

Rung

Element

Type

Address

Meaning

1

1

NO

%M1.1

in S1

1

2

NO

%I0.1

box here

1

3

set coil

%M1.2

set S2

1

4

reset coil

%M1.1

clear S1

2

1

NO

%M1.2

in S2

2

2

NO

T1.Q

2 s done

2

3

set coil

%M1.1

set S1

2

4

reset coil

%M1.2

clear S2

3

1

NO

%M1.0

in S0

3

2

NO

%I0.0

start

3

3

set coil

%M1.1

set S1

3

4

reset coil

%M1.0

clear S0

4

1

NO

%M1.2

in S2

4

2

TON, PT = 2 s

T1

times S2

5

1

NO

%M1.2

in S2

5

2

coil

%Q0.1

gate on

6

1

NO

%M1.1

in S1

6

2

coil

%Q0.0

belt on

7

1

NC

%M1.0

not S0

7

2

NC

%M1.1

not S1

7

3

NC

%M1.2

not S2

7

4

set coil

%M1.0

set S0

Boolean equations: (1) %M1.1 · %I0.1 sets %M1.2 and resets %M1.1; (2) %M1.2 · T1.Q sets %M1.1 and resets %M1.2; (3) %M1.0 · %I0.0 sets %M1.1 and resets %M1.0; (4) T1.IN = %M1.2; (5) %Q0.1 = %M1.2; (6) %Q0.0 = %M1.1; (7) NOT %M1.0 · NOT %M1.1 · NOT %M1.2 sets %M1.0. Each rung sees the bits as the rungs above left them. Rungs 2 and 3 set S1 after rung 1 has tested it, and in the scan where rung 1 sets S2, T1.Q is still 0, so no step is passed through in one scan.

WORKED EXAMPLE

Use the conveyor sequence above. The start button is pressed at t = 1 s and released at 1.5 s. The first box reaches the sensor at t = 6 s, and the gate pushes it clear of the sensor before t = 8 s. Give the step and outputs over time, to within one scan.

Solution
  1. Before 1 s: rung 7 set %M1.0 in the first scan, and rungs 5 and 6 see %M1.2 = 0 and %M1.1 = 0, so both outputs are off.

  2. At 1 s rung 3 sees %M1.0 · %I0.0 = 1, so it sets S1 and resets S0; rung 6 then turns the belt on. Releasing the button changes nothing, because rung 3 also needs %M1.0, now 0.

  3. At 6 s rung 1 sees %M1.1 · %I0.1 = 1, so it sets S2 and resets S1. Rung 4 starts T1, rung 5 turns the gate on and rung 6 turns the belt off.

  4. At 8 s T1.Q = 1, so rung 2 returns the machine to S1; rung 4 resets T1, the gate turns off and the belt runs. The box is clear, so rung 1 waits for the next box.

Answer: S0 until 1 s; S1 from 1 s to 6 s (belt on); S2 from 6 s to 8 s (gate on, belt off); S1 again from 8 s.

Check yourself

CHECK YOURSELF 1

A TON has PT = 4 s. IN is 1 from t = 0 to 3 s, 0 from 3 s to 4 s, 1 from 4 s to 12 s, and 0 after 12 s. During which interval is Q equal to 1?

  1. (A)

    0 to 3 s, and 8 s to 12 s

  2. (B)

    8 s to 12 s

  3. (C)

    4 s to 12 s

  4. (D)

    4 s to 8 s

Answer and solution

Answer: (B)

  1. The first pulse lasts 3 s, less than PT = 4 s, so ET returns to 0 before reaching PT and Q stays 0.

  2. IN rises again at 4 s, so ET starts from 0 and reaches 4 s at t = 8 s.

  3. Q is 1 from 8 s until IN falls at 12 s.

CHECK YOURSELF 2One or more options are correct

A TOF has PT = 5 s. IN has been 1 for some time, then falls to 0 at t = 10 s and stays 0. Which statements are true?

  1. (A)

    Q is 1 at t = 12 s

  2. (B)

    Q is 0 at t = 14 s

  3. (C)

    ET equals 5 s at t = 20 s

  4. (D)

    Q becomes 0 at t = 10 s

Answer and solution

Answer: (A), (C)

  1. After the fall at 10 s, ET = t - 10 s and Q stays 1 while ET < 5 s.

  2. At 12 s, ET = 2 s, so Q is 1: A is true. At 14 s, ET = 4 s, so Q is still 1: B is false.

  3. Q turns off at 15 s, not 10 s: D is false. ET then holds at PT = 5 s while IN stays 0: C is true.

CHECK YOURSELF 3

A CTU has PV = 10 and starts at CV = 0. CU has 7 rising edges, then R is 1 for one scan, then CU has 6 more rising edges. R is 0 except for that one scan. What is CV at the end?

Answer and solution

Answer:

  1. After 7 edges, CV = 7.

  2. The reset sets CV to 0.

  3. Six more rising edges give CV = 6.

CHECK YOURSELF 4

Each scan takes 20 ms. A sensor contact turns true at the start of one scan and false at the start of the scan 0.6 s later. A rung adds 1 to a count in every scan in which the contact is true (no edge detection). How many counts does one part add?

Answer and solution

Answer:

  1. The contact is true in the scans that start at 0 s, 0.02 s, and so on up to 0.58 s.

  2. That is 0.6 / 0.02 = 30 scans, so 30 is added.

  3. With a rising-edge bit in place of the contact, the part would add 1.