CODESYS Data Type + Symbol Addressing Guide
Data Type Real-Life Use Case Declaration Symbol / Memory AddressUsage
BOOL Start/Stop button, sensor MotorStart: BOOL; %IX0.0 / %QX0.0 IF MotorStart THEN Motor := TRUE;
INT Position in mm StrokePos: INT; %IW0 / %MW0 StrokePos := %IW0;
DINT Piece counter, ms timer TotalPieces: DINT; %MD100 TotalPieces := TotalPieces + 1;
LINT Lifetime log time UptimeMS: LINT; %ML100 Used for uptime tracking
UINT Speed (RPM) MotorSpeed: UINT; %IW2 / %MW2 MotorSpeed := %IW2;
UDINT Energy reading, barcode Energy_Wh: UDINT; %MD10 From Modbus register
ULINT Big count log LifetimeCount: ULINT; %ML20 Used in long lifecycle systems
REAL Temperature, flow TempSensor: REAL; %IW4 → converted TempSensor := INT_TO_REAL(%IW4) * 0.1
LREAL High-precision sensor LabValue: LREAL; Internal Scientific calculation
WORD VFD status StatusWord: WORD; %MW6 IF StatusWord.0 THEN Fault := TRUE;
DWORD SCADA flags Flags: DWORD; %MD12 Flags := Flags OR 16#00010000
LWORD Diagnostic packets Diag64: LWORD; %ML30 Used in buffer systems
STRING Operator/BATCH ID OperatorName: STRING[50];Internal OperatorName := 'AUG25B1'
TIMER Delay logic Delay1: TON; No symbol, FB-based Delay1(IN := Start, PT := T#5s);
COUNTER Item counting BoxCounter: CTU; No symbol, FB-based BoxCounter(CU := Sensor, PV := 24);
FUNCTION BLOCK
Reusable logic FB_MotorControl: MOTOR_BLK;
Internal FB_MotorControl(Start := TRUE);