Attention
IronPLC supports IEC 61131-3 Structured Text excluding I/O mapping.
Connecting to Hardware¶
So far, your doorbell program uses regular variables with no connection to physical hardware. On a real PLC, variables are mapped to specific input and output pins. In this chapter, you will learn how to make that connection.
Directly Represented Variables¶
IEC 61131-3 uses the AT keyword to bind a variable to a physical
I/O address. Open main.st and update the variable declarations:
PROGRAM main
VAR
Button AT %IX1 : BOOL;
Buzzer AT %QX1 : BOOL;
PulseTimer : TON;
END_VAR
PulseTimer(IN := NOT Button, PT := T#500ms);
Buzzer := PulseTimer.Q;
END_PROGRAM
What Changed¶
We added AT addresses to the Button and Buzzer variables:
Button AT %IX1 : BOOL— a Boolean input variable. TheImeans input,Xmeans single bit, and1is the address number. On a real PLC,%IX1corresponds to a digital input pin connected to the button.Buzzer AT %QX1 : BOOL— a Boolean output variable. TheQmeans output. On a real PLC,%QX1corresponds to a digital output pin connected to the buzzer.
These are called directly represented variables because they are tied to specific hardware I/O points. The address format follows a pattern:
%I— input,%Q— output,%M— memoryX— single bit,B— byte,W— word (16-bit),D— double word (32-bit)The number is the address within that region
Check the Program¶
You can verify the updated program is correct:
ironplcc check main.st config.st
The IronPLC checker validates the hardware addresses and ensures the program is well-formed.
Note
The IronPLC compiler does not yet support compiling programs with
directly represented variables to bytecode. You can check these
programs for correctness, but compiling and running them requires a
future release. For now, remove the AT addresses to compile
and run in the virtual machine.
What You Have Learned¶
Over the course of this tutorial, you have:
Installed IronPLC and the development environment extension.
Learned the sense-control-actuate cycle that drives PLC programs.
Written a doorbell program with boolean logic and a timer.
Run the program directly from the editor.
Configured the application with a task schedule.
Organized the code across multiple files.
Connected variables to hardware I/O addresses.
Where to Go from Here¶
Explanation — deepen your understanding of IEC 61131-3 concepts.
How-to guides — practical guides for specific tasks.
Compiler reference — full command and language reference.