For beginners, learning indirect addressing is often not understood, a little confused, and the next article will give you a detailed explanation to easily take you to solve this trouble.Instruction explained
1.Create a pointer.
To use indirect addressing, you must first create a pointer, so how do you create a pointer? Use the mov dw command to store the pointer address into the variable of the out output, isn't mov dw an ordinary 32-digit transmission instruction, how is it a pointer?
In fact, when the in pin of the mov dw command uses &vbxxx, &ibxxx, &mbxxx, &qbxxx, it is the format of the pointer to create. As shown in Figure 1, &vb0 is the creation pointer pointing to vb0, where & is the symbol of the creation pointer, vb is the byte of the v storage area, 0 indicates that the pointing address starts from byte 0, the pointer address is placed in the out output variable address, and vd100 is the pointer address where the creation pointer is stored.
Figure 1
2.Reference pointers.
As shown in Figure 2, *vd100 represents a reference pointer and transmits data from vd0 to vd200.
Figure 2: How do you determine whether the address you are pointing to uses bytes, words, or double words? In fact, it has something to do with instructions. As shown in Figure 3, if you place the cursor at the instruction block for about 2 seconds, a data type used by the instruction block pin instruction will pop up.
Here you can see in:dword, the input is the 32-bit data type of dword, that is, double words, then the reference is vd0, the pointer has not been offset, or points to the vb0 address to start, the instruction uses double words, so the reference is the data in the vd0 address, and the vd0 is assigned to vd200.
Figure 3
3.Pointer offset.
When a beginner uses a pointer, the understanding of pointer offset is the most confusing. Pointer offset is a new pointer address obtained by calculating the address where the pointer is stored.
As shown in Figure 4, press M00 puts the pointer address of vb0 in vd100, if i0 is not connected at this time0, then segment 3 will send the data from vd0 to vd200, if i0 is connected0, then segment 3 will send data from vd4 to vd200.
The amount of the pointer address is how much it is offset upward, and it can also be subtracted by an offset, generally the byte offset is 1, the word offset is 2, and the double word offset is 4. As shown in the program section 2 in Figure 4, the pointer address vd100+4=vd100, the first pointer created in the program segment is to vb0, and after pointer +4, the pointer is offset to vb4.
Figure 4
Case application
Case 1 is shown in Table 1 and press m00 button to send the assignment data to the assignment address, e.g. the first time vb0 is sent to vb100, and after the fourth time, press m00 button, the pointer points back to vb0 to start over.
Table 1 program is written as shown in Figure 5, the address difference between bytes is 1, and the operation program of vd1000+1=vd1000 is written, and each time it is offset upwards by 1.
Figure 5
Case 2 is shown in Table 2 and press m00 button to send the assignment data to the assignment address, e.g. the first time to send vw0 to vw100, after the fourth time, press m00 button, the pointer points back to vb0 to start over.
Table 2 program is written as shown in Figure 6, the address difference between words is 2, and the operation program of vd1000+2=vd1000 is written, and each time it is offset by 2.
Figure 6
Case 3 is shown in Table 3 and press m00 button to send the assignment data to the assignment address, e.g. the first time to send vd0 to vd100, when the fourth time, press m00 button, the pointer points back to vb0 to start over.
Table 3 program is written as shown in Figure 7, the address difference between the double word and the double word is 4, and the operation program of vd1000+4=vd1000 is written, and the address difference between the two characters is 4.
Figure 7
Case 4 is shown in Table 4 and press m00 button to send the assignment data to the assignment address, e.g. the first time to send vd0 to vd100, when the fourth time, press m00 button, the assignment address is cleared to zero, and then the assignment is restarted next time.
Table 4 shows that both input and output can be indirectly addressed by pointers, and addresses that cannot be reached can be assigned through address offset.
FIGURE 8
Summary
This article gives an example of simple in and out indirect addressing, there are many ways to use indirect addressing, which can be used in form parameter subroutines, such as finding the average value of multiple values, using for loops and indirect addressing can easily solve this problem that requires multiple operations, now Siemens 200smart v2The CPU of 8 supports average instructions, so you don't need to write your own program.
The above is the content of the entire Siemens S7-200Smart indirect addressing method, if there is any error in the content of the article or there is no problem with the problem, please contact us.
Article**: Original of Jicheng Training Network, Author: Zou Zhirui; Unauthorized prohibition**, offenders will be prosecuted!
Tips: Attention, ** is the greatest encouragement! Thank you for your support! If you want to know more exciting content, come and pay attention to the training network
Example: How to Synchronize Recipe Data Records in Portal WinCC? Wonderful panel import and export "recipe data logging" functionMCGS Pro and S7-200 Smart Ethernet communication (** structured) PLC custom time countdown program design is so simple? The master will teach you how to realize the configuration king communication of S7-1200 PLC.