Siemens PLC indirect addressing is a powerful feature used in the Siemens S7-300 PLC system. This technique allows you to dynamically access memory locations by using pointers rather than hard-coded addresses. The method discussed here is specifically relevant for the S7-300 model. In the S7-300 PLC, when working with indirect addressing, the highest bit (bit 31) of the address pointer determines whether it's an internal or cross-area reference. If the highest bit is 0, it indicates that the address is within the same memory area. In this case, the area identifier (rrr) is also set to 0, and the address format is similar to standard memory indirect addressing. For example: - `LP#5.0` – Load the indirect address pointer into accumulator 1. - `LAR1` – Move the contents of accumulator 1 to address register AR1. - `AM[AR1, P#2.3]` – Access the bit at position M7.3 by adding the offset P#2.3 to the base address P#5.0. - `= Q[AR1, P#0.2]` – Store the result in Q5.2, which is the sum of P#5.0 and P#0.2. The brackets in the address indicate the operand’s location, which is calculated as the base address plus the offset specified after the comma. For instance, `M[AR1, P#2.3]` refers to the address P#7.3, which corresponds to M7.3. When the most significant bit (bit 31) of the address pointer is set to 1, it indicates that the address crosses different memory areas. An example of this would be: - `LP#M 6.0` – Load the double-word address of M6.0 into accumulator 1. - `LAR1` – Transfer the value from accumulator 1 to AR1. - `LW [AR1, P#20.0]` – Read the word at MW26. The binary representation of `P#M6.0` is `2#1000 0011 0000 0000 0000 0000 0011 0000`. Since the address already includes the area information (rrr = 2#011 represents the M area), there's no need to specify the area again in subsequent instructions. It's important to note that when reading or writing bytes, words, or double words using an address pointer, the bit number after the decimal point must be zero. Otherwise, the system will generate an error. This ensures that the address is aligned correctly with the data type being accessed. Understanding and properly implementing indirect addressing can greatly enhance the flexibility and efficiency of your PLC programs, especially in applications requiring dynamic data handling or variable memory access.
Wenzhou Hesheng Electronic Co., Ltd. , https://www.heshengelec.com