How do you address securely and indirectly in STEP 7 (TIA Portal)?
Using this method you can reduce the programming required and make your program more flexible. Usually, the access addresses are known when the program is created. How to make indirect addressing more flexible and more secure:
- Use the "Array" data type for combined data of the same data type.
- For different areas, use the index via which access to the variable concerned is made in each case.
In the following example access is made to three variables with different memory areas. The following table shows the access list of the three variables that are each assigned to one index:
|Index||Access to variable||Memory area|
Create a function and declare an input variable with the data type "Int". Also define the return value with the same data type. Fig. 1 shows an example for programming the "AccessGroupInt" function, in which indirect access is declared and returned by means of the index. You can use the indirect access directly in the program, for example with the instruction #TempValue:= "AccessGroupInt"(#Index);. This method of programming is now
- Traceable, because you can use the cross-reference list.
- Secure, because you use only the pre-defined memory area.
- Universal, because you can use it for standard as well as for optimized data areas.
In the following example data is read and written from/to three different optimized data blocks. The three data blocks "Silo_Water", "Silo_Sugar" and "Silo_Milk" each contains the same variable declarations:
- DB variable 1: "MyBool" of the Bool data type.
- DB variable 2: "MyInt" of the Int data type.
- DB variable 3: "MyWord" of the Word data type.
The PLC data type "SiloUDT" is created for addressing the DB variables with the different data types. Reading out is done with the return value of the "AccessGroupSiloRead" function, which is defined with the PLC data type "SiloUDT". On this basis you can program the indirect access in an FB, for example with the instruction shown in Fig. 03:
- "Silo_Handling_OnlyReading"("AccessGroupSiloRead"(Index:= #Silo_Index));
The screens in this FAQ response were created with STEP 7 (TIA Portal) V15.
- You have a technical question / problem: Ask the Technical Support
- You want to discuss in our forum and exchange experiences with other users
- You want to create CAx data for one or more products
- You would like to send us feedback on this Entry