⏱️ Timers & Counters0%
⏱️ The Suspiciously Fun PLC Series · Cross-brand

Timers & Counters:
the heartbeat of every machine.

Almost nothing on a machine happens instantly. You clamp THEN drill, run the pump for 30 seconds, blink the light, stop after 500 parts, and fault if a move takes too long. All of that is timers and counters, the two most-used function blocks in all of PLC programming, and nearly every codebase leans on them every scan. They also hide a subtlety that trips up beginners and shows up in every interview: a PLC can't simply 'wait', because the scan never stops. This module teaches the non-blocking way to do it with TON/TOF/TP, CTU/CTD/CTUD and edge detection, plus the patterns and pitfalls that separate clean timing code from the kind that flickers and miscounts.

A PLC can't sleep

⏳ in normal code you'd write wait(5s). In a PLC that would freeze the whole machine, because the scan has to finish in milliseconds. A timer counts elapsed time across many scans without ever blocking, and that idea is the whole game.

Count edges, not levels

📈 the #1 timing bug: a counter that jumps by hundreds on a single button press, because it counted every scan the button was held. The fix is edge detection, a five-minute idea that saves you a lifetime of miscounts.

🌐
Vendor-neutral: TON, TOF, TP, CTU, CTD, CTUD and R_TRIG/F_TRIG are standard IEC 61131-3 blocks. The names and faces are identical across TwinCAT 3, TIA Portal (where they're also IEC timers), Studio 5000, CODESYS and the rest.
A true fundamental. It sits early, right after PLC Programming Essentials, and every later module assumes you know these cold.