06 · TK-101 · Projects
Structured Text control exercises on CODESYS: timers, interlocks and sequential start
A set of small ST programs on a simulated PLC: timer and counter blinkers, up/down control with end limits, a two-input interlock, a four-output sequential start with CASE, and a motor and valve sequence with a level sensor.

The problem
Before larger systems, the language itself needs practice on the control patterns that recur in every plant: timing, counting, preventing opposing motions, and sequencing.
Solution and data flow
Each program handles one pattern:
- One-second timer blinker: a
TONofT#1Stoggles an LED on each pulse. - Counter blinker: a counter increments each cycle and the state toggles when the remainder
MOD 2is zero. - Delay timer: a
TONofT#5Son a start input, with trials ofTOF,TPand aCTUcounter. - Up/down control: UP, DOWN and STOP inputs with end limits L1 and L2; STOP or a limit switch stops both outputs.
- Interlock: the first input drives one LED, the second another, and when both are on an error output lights.
- Sequential start: on START a
TONofT#3Ssteps aCASEthat switches four breakers in order. - Motor and valve sequence with a level sensor: START, PROX, EX and level inputs start the motor and hand over to the valve according to the level sensor.
Implementation and challenges
All are CODESYS V3.5 projects in Structured Text only, on CODESYS Control Win V3 with a 20 ms cyclic task, some with a WebVisu screen. The point of attention is ordering conditions so two opposing outputs are never on in the same cycle. These are simulation exercises; the code was recovered from the projects' editing history and does not represent a field installation.
Skills developed
TON, TOF and TP timers, counters, end-limit control, interlocks, sequencing with CASE and simple WebVisu screens.