Garage Door Control

Sequential Function Chart (SFC) Implementation

IEC 61131-3 compliant

Closed
Closed
Opening
Open
Stopped
Closing
Error
%IX0.0IN_PB
%IX0.1IN_DOOR_OPEN (F=fully open)
%IX0.2IN_DOOR_CLOSED (F=fully closed)
%QX0.0OUT_MOTOR_FWD
%QX0.1OUT_MOTOR_REV
%QX0.2OUT_ERROR_LED

User Requirement Specification

I want to program a control system to control a garage door.

The user controls the garage door with a momentary contact push button that starts and stops the motor.

The motor automatically stops when the door hits the open or closed indicator switch.

If the garage door is closed, it opens on a push-button pulse.

If the garage door is moving, it stops on a push-button pulse.

If the garage door is stopped while it was moving, the next push-button pulse closes the garage door.

If the garage door is in the fully open position, a push-button pulse closes the garage door.

Door position digital inputs:

Door Open

Open circuit when the door is fully open, and

Closed circuit when closed or moving.

Door Closed

Open circuit when the door is fully closed, and

Closed circuit when open or moving.

Error state:

In case both door position switches are open circuit: the motor is stopped, an error LED is illuminated on the motor casing, and all further push-button pulses are ignored until one of the door position switches is closed.

IEC 61131-3 Controller Source Code

The controller logic is implemented in Structured Text (ST), a high-level, Pascal-like language and one of the five languages defined in the IEC 61131-3:2025 international standard for Programmable Logic Controllers.

Structured Text is natively supported by all major PLC platforms:

  • Siemens TIA Portal (S7-1200 / S7-1500)
  • Rockwell Automation Studio 5000 (ControlLogix / CompactLogix)
  • Beckhoff TwinCAT 3
  • Schneider Electric EcoStruxure Control Expert
  • Any CODESYS-based PLC runtime
  • OpenPLC Runtime (Raspberry Pi and Linux)
View Structured Text source

Opens in a new tab. Place it alongside the simulator to follow the code as you operate the controller.