The term "addressing mode" refers to the CPU's method of locating the physical address corresponding to the variable address in the program. The Siemens S7 series PLC supports various addressing modes, providing considerable flexibility for program development. In this article, we will discuss how the S7 series PLC (300/400/1200/1500) performs addressing.
The addressing modes of the S7 series PLC can be categorized into direct addressing and indirect addressing.
Direct addressing refers to accessing the CPU's memory directly within the program. The memory areas involved include Input/Output image area (I/O), bit storage area (M), timers (T), counters (C), data blocks (DB), and function blocks (FB/FC), among others. Direct addressing can further be classified into absolute addressing and symbolic addressing.
Absolute addressing involves using the physical address of the memory area in the program. For example: I0.0, Q1.0, M2.0, and so on.
The physical address alone does not convey its meaning intuitively. For instance, seeing "I 1.0" in the program doesn't indicate which button's input it represents or which proximity switch's input it is. This addressing method hinders program readability, writing, and later maintenance. To enhance program readability and maintainability, symbolic addressing is employed.
Symbolic addressing involves assigning a symbol (name) related to the function to the physical address. In the previous example of "I 1.0," we assign the symbol "Start ON" to it, making it clear that it represents the power-on button. Symbolic addressing supports all memory areas (I, O, M, C, T, DB, L), enhancing program readability and maintainability, making it a common addressing method in large program development.
Both of the aforementioned addressing modes fall under direct addressing. In advanced program development, another type of addressing comes into play: indirect addressing.
Indirect addressing is accomplished using pointers or address registers, allowing dynamic modification of instruction addresses during program execution by changing the pointer or address register values. Indirect addressing involves 16-bit and 32-bit pointers, addressing modes include memory indirect addressing and register indirect addressing. It offers powerful functionality but can pose some difficulty for beginners to comprehend. This article will initially focus on memory indirect addressing.
Memory indirect addressing utilizes 16-bit and 32-bit pointers. The 16-bit address pointer is used for addressing timers (T), counters (C), program blocks (FB/FC), and data blocks (DB). It accesses data in word format, with the 16-bit pointer acting as an unsigned number (0 to 65535), representing the corresponding memory's identifier.
Addressing format: Area Identifier [16-bit Address Pointer];
For example: Decrement Counter Instruction CD C[MW20]; "C" is the counter area identifier, and "MW20" represents the address pointer. Let's examine the following code snippet: