Section 08 · Practice Questions

Timing, Counting & Sequencing

Nine problems on PLC timing and counting — pulse trains from cascaded TONs, a horn-then-oven start sequence, computing an iterative formula one scan at a time, edge-triggered enables, first-scan state capture, a 24-hour clock from three counters, and self-measuring frequency and scan-rate routines.

9Questions
9Worked Solutions
All practice sections

Timing problems become straightforward once you decide which event starts each timer and which timer’s done-bit feeds the next stage — sketch the timing diagram before writing the ladder.

Q1

A continuous 10-second pulse train from two timers

Using two timers — one ON-delay and one OFF-delay — write a program whose output produces a continuous pulse train with TON = 10 s and TOFF = 10 s. The program must stop when input I is OFF, where I is the ON switch and Q is the output.

ShowHide worked solution

Two cascaded TONs form a self-toggling loop. T1 runs while Q is OFF; when T1 finishes, Q seals on. T2 then runs while Q is ON; when T2 finishes, the seal breaks and Q goes off — restarting T1. When I goes OFF the whole chain de-energises.

Ladder program
Rung 1 — T1: 10 s ON-delay, runs while Q is OFF and I is ON:
|---[ I ]---[/Q]----(TON T1, PRE = 10 s)----|

Rung 2 — Q sets when T1 finishes; seals via Q with [/T2.DN]:
|---[ I ]---[ T1.DN ]----+----( Q )----|
|                        |
|---[ Q ]---[/T2.DN]-----+

Rung 3 — T2: 10 s timer runs while Q is ON:
|---[ I ]---[ Q ]----(TON T2, PRE = 10 s)----|

When T2.DN fires, the seal in Rung 2 drops, Q clears, T1 restarts — the cycle repeats forever while I is ON.

Timing diagram

I: ___|‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾|___ Q: _________|‾‾‾‾‾‾‾|_______|‾‾‾‾‾‾‾|_____ <10 s> <10 s ON> <10 s OFF> <10 s ON>
Final AnswerTwo TONs (one gated by /Q, the other by Q) feed into a self-seal on Q. Q toggles every 10 seconds while I is ON; when I drops, everything de-energises.
Q2

A start sequence: 10-second horn, oven, then 300-second fan tail

Write a PLC program: pressing Start seals in the Auto bit; Stop stops the system. When Auto first goes ON, a timer sounds a horn for 10 seconds for safety; the horn then stops and the oven begins heating. When the oven is switched OFF, the fan continues to run for a further 300 seconds (5 minutes).

ShowHide worked solution

An AUTO seal-in starts the whole sequence. A 10-second TON gates the safety horn; once T1.DN fires, the oven takes over. The fan rides on the OVEN output PLUS an off-delay-style timer T2 that keeps it running 300 seconds after the oven drops.

Ladder program
Rung 1 — Auto seal:
|---[/STOP]---[ START ]----+----( AUTO )----|
|                          |
|---[ AUTO ]---------------+

Rung 2 — 10-second horn timer:
|---[ AUTO ]----(TON T1, PRE = 10 s)----|

Rung 3 — horn ON during the first 10 seconds:
|---[ AUTO ]---[/T1.DN]----( HORN )----|

Rung 4 — oven starts after the horn:
|---[ AUTO ]---[ T1.DN ]----( OVEN )----|

Rung 5 — fan ON while oven is ON, plus 300 s after it drops:
|---[ OVEN  ]----+----( FAN )----|
|                |
|---[ T2.TT ]----+

Rung 6 — 300-s off-delay timer triggered by oven dropping:
|---[/OVEN]----(TON T2, PRE = 300 s)---|
Final Answer10-second safety horn (gated by /T1.DN), OVEN ON after the horn, FAN held ON via the parallel T2.TT for 300 seconds after the oven turns off.
Q3

Compute the series x = 2(n − 1) up to n = 100

Create a ladder program that begins when input A is turned ON and evaluates x = 2(n − 1). Starting from n = 1, the value of n increments on every scan of the ladder until n reaches 100. Any changes to A while the sequence is being incremented must be ignored. Use A = I/0, n = N7:70, and write the result to N7:71.

ShowHide worked solution

The “ignore further A changes” requirement is the key — latch a RUN bit on the rising edge of A, and let only that bit drive the iteration. RUN breaks itself when n reaches 100.

Ladder program
Rung 1 — latch RUN on A's rising edge; break when n reaches 100:
|---[OSR A]---+----( RUN )----|
|             |
|---[ RUN ]---[ N7:70 < 100 ]+

Rung 2 — initialise n = 1 on the same edge:
|---[OSR A]----(MOV 1, N7:70)----|

Rung 3 — compute x = 2(n − 1) and increment n each scan:
|---[ RUN ]----(SUB N7:70, 1, T)----|
|---[ RUN ]----(MUL T, 2, N7:71)----|
|---[ RUN ]----(ADD N7:70, 1, N7:70)----|

Rung 4 — stop when n reaches 100:
|---[ N7:70 ≥ 100 ]----(/RUN)----|
Final AnswerRUN latches on the rising edge of A and is broken when n reaches 100. Each scan: compute x = 2(n − 1), increment n. Changes to A during execution are ignored because of the seal-in.
Q4

Enable an input after three clock cycles

Write a program with the following behaviour: when I0.1 is high, the program produces an output Q; after three clock cycles have elapsed, it enables I0.0.

ShowHide worked solution

“Three clock cycles” — assume a 1 Hz system clock bit (CLK_1Hz), so three rising edges means three seconds. A small CTU on the clock counts the cycles while I0.1 is high; when its DN fires, the I0.0 enable bit goes true.

Ladder program
Rung 1 — Q follows I0.1 directly:
|---[ I0.1 ]----( Q )----|

Rung 2 — count clock edges while I0.1 is high:
|---[OSR CLK_1Hz]---[ I0.1 ]----(CTU C1, PRE = 3)----|

Rung 3 — enable I0.0 after 3 cycles:
|---[ C1.DN ]----( I0.0_ENABLE )----|

Rung 4 — reset on I0.1 going low:
|---[/I0.1]----(RES C1)----|
Final AnswerQ tracks I0.1 directly; a counter on rising 1 Hz edges fires after 3 ticks, enabling I0.0 in dependent logic.
Q5

Capture an input’s state only on the first scan

Write a program that monitors the state of an input I/1 — whether it is pressed or released — and uses that state to disable a portion of the program. After the initial detection, any further presses or releases of I/1 must have no effect on the disabled lines.

ShowHide worked solution

The first-scan bit (S:1/15 on Allen-Bradley SLCs) is true only on the very first PLC scan after power-up. Use it to sample I/1 into a latch L exactly once; from then on the dependent rungs gate on L, not on the live I/1.

Ladder program
Rung 1 — capture I/1 on the very first scan only:
|---[ S:1/15 ]---[ I/1 ]----(L S/1)----|
   (if I/1 was low on the first scan, L stays clear forever)

Rung 2 — downstream rung disabled while L is set:
|---[/L]---[ other_conditions ]----( SOME_OUTPUT )----|
Final AnswerUse the first-scan bit to sample I/1 once into a latch L; gate downstream rungs on [/L]. After power-on, L never changes regardless of I/1.
Q6

A 24-hour clock from three cascaded counters

Construct a ladder program that uses three counters together with flag M1013 (a 1-second clock-pulse generator) to implement a 24-hour clock displaying seconds, minutes and hours.

ShowHide worked solution

Cascade three CTUs: each done-bit resets its own counter and increments the next. The final hour counter rolls over at 24, completing the 86 400-second day.

Ladder program
Rung 1 — seconds counter, preset 60:
|---[ M1013 ]----(CTU C_SEC, PRE = 60)----|

Rung 2 — reset seconds at 60, increment minutes:
|---[ C_SEC.DN ]----(RES C_SEC)----|
|---[ C_SEC.DN ]----(CTU C_MIN, PRE = 60)----|

Rung 3 — reset minutes at 60, increment hours:
|---[ C_MIN.DN ]----(RES C_MIN)----|
|---[ C_MIN.DN ]----(CTU C_HR, PRE = 24)----|

Rung 4 — reset hours at 24:
|---[ C_HR.DN ]----(RES C_HR)----|

Rungs 5–7 — copy accumulators to display registers:
|---[ ALWAYS ]----(MOV C_SEC.ACC, DISPLAY_S)----|
|---[ ALWAYS ]----(MOV C_MIN.ACC, DISPLAY_M)----|
|---[ ALWAYS ]----(MOV C_HR.ACC,  DISPLAY_H)----|
Final AnswerCascade three CTUs (60, 60, 24). Each done-bit resets its counter AND increments the next. The hour counter rolls over at 24, completing the full day.
Q7

Delayed latch with a 10-second press lockout and 3-press cutoff

Develop a ladder program that latches output B ON 20 seconds after input A is energised. Once A has been pressed, A must be ignored for 10 seconds before it can act again. After A has been pressed three times, output B must be turned OFF.

ShowHide worked solution

Three independent mechanisms in one program: a counter to count A presses (preset 3), a 10-second TON that holds off any subsequent press while it’s running, and a 20-second TON whose done-bit sets B. The DN of the counter clears B at the third press.

Ladder program
Rung 1 — count A presses (gated by the 10-s lockout):
|---[ A ]---[/LOCKOUT.TT]----(CTU C1, PRE = 3)----|
|---[ A ]---[/LOCKOUT.TT]----(TON LOCKOUT, PRE = 10 s)----|

Rung 2 — 20-second timer starts on the first press of A:
|---[ A ]---(TON T_B, PRE = 20 s)----|

Rung 3 — set B after 20 s, until the counter reaches 3:
|---[ T_B.DN ]---[/C1.DN]----+----( B )----|
|                            |
|---[ B ]----[/C1.DN]--------+

Rung 4 — clear B after 3 presses:
|---[ C1.DN ]----(/B)----|
Final AnswerCounter (PRE = 3) counts A presses, gated by a 10-s lockout TON. A 20-s TON sets B; C1.DN at count = 3 clears B.
Q8

Measuring an unknown frequency

Implement a PLC ladder program that measures and displays an unknown frequency. Frequency is the number of complete cycles per second, where each cycle is a high (positive) pulse plus a zero pulse. The program must detect the positive pulses, reset itself when the measurement is complete, and display the result.

ShowHide worked solution

The clean approach is a self-restarting 1-second window. A counter counts rising edges of the input pulse during the window; at the end of each window, the count is the frequency in Hz, copied to the display register, then both timer and counter are reset for the next window.

Ladder program
Rung 1 — self-restarting 1-second window:
|---[ ALWAYS ]----(TON T_WIN, PRE = 1 s)----|
|---[ T_WIN.DN ]----(RES T_WIN)----|

Rung 2 — count rising edges of PULSE during the window:
|---[OSR PULSE]---[/T_WIN.DN]----(CTU C_F)----|

Rung 3 — at window end, store the count and reset:
|---[ T_WIN.DN ]----(MOV C_F.ACC, FREQ_HZ)----|
|---[ T_WIN.DN ]----(RES C_F)----|
Final AnswerSelf-restarting 1-s timer + edge-counter on the input pulse. At each window’s end, the accumulator value is the frequency in Hz; the counter is then reset for the next window.
Q9

Measuring the scan cycle (scans per second)

Implement a PLC ladder program that continuously measures the scan cycle, defined as the number of scans per second (Scans/Sec).

ShowHide worked solution

Mirror image of the frequency measurement. Increment a counter every scan; at each 1-second window expiry, copy the count to the display register and zero the counter. The number stored is “scans per second” — a live measure of the controller’s load.

Ladder program
Rung 1 — count every scan:
|---[ ALWAYS_TRUE ]----(ADD N7:0, 1, N7:0)----|

Rung 2 — self-restarting 1-second window:
|---[ ALWAYS ]----(TON T_WIN, PRE = 1 s)----|
|---[ T_WIN.DN ]----(RES T_WIN)----|

Rung 3 — at window end, copy count to display and reset:
|---[ T_WIN.DN ]----(MOV N7:0, SCANS_PER_SEC)----|
|---[ T_WIN.DN ]----(MOV 0, N7:0)----|
Final AnswerIncrement a counter every scan; at each 1-s window expiry, copy the count to the display register and zero the counter. The result is the scan rate in scans per second.