Basics: Memory Areas in PLC

Опубликовано: 24 Июль 2026
на канале: Ahmed Elkholy
340
7

the reference is "https://bit.ly/3bxR7Xx"
Sway presentation "https://sway.office.com/UDt11RiMCecKK..."
Memory Areas of S7 CPUs
The memory of an S7 CPU can be divided into three areas (see figure below):
• The load memory is used for user programs without symbolic address assignments or comments (these remain in the memory of the programming device). The load memory can be either RAM or EPROM.
• The work memory (integrated RAM) contains the parts of the S7 program relevant for running your program. The program is executed only in the work memory and system memory areas.
• The system memory (RAM) contains the memory elements provided by every CPU for the user program, such as the process-image input and output tables, bit memory, timers, and counters. The system memory also contains the block stack and interrupt stack.



1. Load Memory and Work Memory
When you download the user program from the programming device to the CPU, only the logic and data blocks are loaded in the load and work memory of the CPU.
The symbolic address assignment (symbol table) and the block comments remain on the programming device.
Dividing Up the User Program
To ensure fast execution of the user program and to avoid unnecessary load on the work memory that cannot be expanded, only the parts of the blocks relevant for program execution are loaded in the work memory.
Parts of blocks that are not required for executing the program (for example, block headers) remain in the load memory.
The following figure shows a program being loaded in the CPU memory.



2. System Memory
The system memory of the S7 CPUs is divided into address areas (see table below). Using instructions in your program, you address the data directly in the corresponding address area.
Address Area Access via Units of
Following Size S7 Notation
(IEC) Description
Process image input table Input (bit) I At the beginning of the scan cycle, the CPU reads the inputs from the input modules and records the

3. Process-Image Input/Output Tables
If the input (I) and output (Q) address areas are accessed in the user program, the program does not scan the signal states on the digital signal modules but accesses a memory area in the system memory of the CPU and distributed I/Os. This memory area is known as the process image.
1. Updating the Process Image

• One of the internal tasks of the operating system (OS) is to read the status of inputs into the process image input table (PII).
• the user program is executed with all blocks that are called in it.
• The cycle ends with writing the process image output table (PIQ) to the outputs for the modules.
reading in the process image input table and writing the process image output table to the outputs for the modules is all independently controlled by the operating system.


Advantages of the Process Image

Compared with direct access to the input/output modules, the main advantage of accessing the process image is that the CPU has a consistent image of the process signals for the duration of one program cycle. If a signal state on an input module changes while the program is being executed, the signal state in the process image is retained until the process image is updated again in the next cycle. The process of repeatedly scanning an input signal within a user program ensures that consistent input information is always available. Access to the process image also requires far less time than direct access to the signal modules since the process image is located in the internal memory of the CPU.

2. Interrupt Stack
If program execution is interrupted by a higher priority OB, the operating system saves the current contents of the accumulators and address registers, and the number and size of the open data blocks in the interrupt stack.
Once the new OB has been executed, the operating system loads the information from the I stack and resumes execution of the interrupted block at the point at which the interrupt occurred.
When the CPU is in STOP mode, you can display the I stack on a programming device using STEP 7. This allows you to find out why the CPU changed to STOP mode