Skip to content
Tutorials Center
My learning

Topics

Lesson 8 of 37 ยท Automation Basics

PLC Memory, Addressing and Tags

Learn how PLC memory is organized, absolute addresses (%I0.0, %Q0.0, %MW10) versus symbolic tags, retentive data, bit and word access, and good naming conventions.

Every value in a PLC program lives somewhere in memory: an input bit, an output bit, a flag, a counter, a setpoint. How you name and find that memory shapes how readable and maintainable your program is. Old programs used cryptic numbers; modern ones use meaningful tags.

This lesson explains memory areas, the absolute address notation used by IEC 61131-3, symbolic tags, retentive memory and naming conventions, and models addressing in C.

Memory areas

Area IEC prefix Meaning
Inputs %I The input image (from sensors)
Outputs %Q The output image (to actuators)
Memory / flags %M General internal storage
Data blocks / variables (named) Structured storage by name

Different brands show the same areas with different letters. Siemens uses I, Q, M; Rockwell uses tags such as Local:1:I.Data.0; Mitsubishi uses X, Y, M, D. The idea is the same.

Absolute addresses

An IEC address has a prefix, a size letter and numbers:

  • %I0.3: input, byte 0, bit 3
  • %Q2.0: output, byte 2, bit 0
  • %IW4: input word at byte 4 (16 bits, commonly an analog input)
  • %MW20: memory word 20
  • %MD100: memory double word (32 bits)

Size letters: X (or none) is a bit, B is a byte, W a word (16 bit), D a double word (32 bit), L a long word (64 bit).

C Stand-in: address a bit inside a byte (C)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

The problem with absolute addresses

%I0.3 tells you nothing. Is it the Start button or a guard? When a program has hundreds of such numbers, nobody can read it. Worse, moving a wire changes the address everywhere.

Symbolic tags

Modern IDEs let you give each address a name in a table, and write the program with names only:

TEXT
Start_Button   AT %I0.0 : BOOL;
Guard_Closed   AT %I0.1 : BOOL;
Motor_Contactor AT %Q0.0 : BOOL;

Motor_Contactor := Start_Button AND Guard_Closed;

If the wire moves to another terminal, you change one line in the table. The logic stays unchanged. Some platforms hide addresses entirely and just allocate memory for each tag.

Good tag names

Meaning first Conv1_Motor_Run
Consistent Same pattern everywhere
No mystery Avoid Temp1, Flag7

Names are documentation

1 / 2

Naming conventions

Pick a convention and stick to it. A common pattern is Area_Device_Function:

Tag Meaning
Conv1_Motor_Run Output that runs conveyor 1
Conv1_Motor_Fault Input from the motor overload
Tank2_Level_PV Process value of tank 2 level
Tank2_Level_SP Setpoint
Pump3_Auto Pump in automatic mode

Avoid spaces, start with a letter, and write the unit in a comment or the name (Temp_C).

Arrays and structures

Instead of 10 separate tags, group related data:

TEXT
TYPE Motor : STRUCT
    Run      : BOOL;
    Fault    : BOOL;
    Speed_Hz : REAL;
END_STRUCT END_TYPE

Motors : ARRAY[1..10] OF Motor;

A structure keeps a device's data together; an array lets one piece of logic serve many identical devices through a loop. See user-defined types.

C Stand-in: a struct array of motors (C)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Retentive memory

When power is lost and restored, non-retentive variables return to their initial values, and retentive variables keep their last values. Use retentive memory for counters of produced parts, recipe selections and setpoints; do not use it for run commands, because a machine that restarts by itself after a power cut is dangerous.

C Stand-in: power cycle with retentive and normal data (C)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with scanf or fgets), it gets the next line from this box.

Documentation habits

Comment why, not what. Document each tag's unit and range, keep a cross-reference of where tags are used, and keep the I/O list in step with the program. A well-named, well-documented program is the cheapest troubleshooting tool you can give your future self.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. What does %Q0.2 refer to?

    %Q is the output area, then byte 0, bit 2.
  2. 2. What is the main benefit of symbolic tags over absolute addresses?

    Meaningful names make programs readable and decouple logic from terminals.
  3. 3. Which data should usually be retentive?

    Counters and settings should survive a power cycle; run commands should not.
  4. 4. What does the W in %MW10 mean?

    W is the size prefix for a 16-bit word.

Summary

  • Memory is organized in input, output and internal areas, addressed by prefix, size and position.
  • Use symbolic tags with a consistent naming convention.
  • Group related data in structures and arrays.
  • Make only the data that must survive a power cycle retentive.

Next: Ladder Logic Basics