Skip to content

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.

Illustration: six Structured Text control exercises covering timers, interlocks and sequential start
Stack
CODESYS V3.5Structured TextTON · TOF · TPCTUCASEInterlocksCODESYS Control Win V3

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 TON of T#1S toggles an LED on each pulse.
  • Counter blinker: a counter increments each cycle and the state toggles when the remainder MOD 2 is zero.
  • Delay timer: a TON of T#5S on a start input, with trials of TOF, TP and a CTU counter.
  • 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 TON of T#3S steps a CASE that 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.