Instructions: Variables with structured data types are saved with transit parameters (IN_OUT) of the FB as reference with a 6-byte POINTER (48 bits) in the instance DB. This means that there is not a value, but a six-byte POINTER in the instance DB. This POINTER indicates the actual parameter; therefore, it is imperative that it is connected. STEP 7 identifies the following structured data types: "Date_and_Time", "String, Array", "Struct" and "UDT".
Fig. 01 contains an example of how to program indirect access to the first byte of this data type. This procedure as described in this example is for data backup.
 ( 8 KB ) Fig. 01
The 6-byte POINTER is loaded via the IN_OUT variable "Symbol_des_InOut". The number of the data block is then transferred from the 6-byte POINTER into a temporary variable "DB_Num". The DB is opened with this saved DB number via the statement "AUF DB[#DB_Num]" and then the address is loaded into address register 1.
The statement "L B[AR1,P#0.0]" provides you with the saved data and correct address. If you were to use the statement "L Symbol_des_InOut[1]" instead of this example, then you would not load the saved data from the address register, but the data directly from the IN_OUT parameter, the values of which might have change however. Please also refer here to the relevant information in the STEP 7 Online Help under
- "Avoiding errors when calling blocks".
Note: The example described is valid only for DB areas, because otherwise the CPU goes into "STOP". Numbering with 0 (DB0) is not permitted.
The "InOutvar.zip" file includes a STEP 7 project with two S7 stations for the sample program served above:
- Station: "Beispiel in deutsch" with German comments
- Station: "Example in English" with English comments
InOutvar.zip ( 356 KB )
IMPORTANT The sample program is freeware. Any user can use, copy and forward this program FREE OF CHARGE. The authors and owners of this program take no responsibility whatsoever for the functionality and compatibility of this software. Use of the software is at the user's own risk. Since this software is free of charge, there is no warranty, nor entitlement to error correction and hotline support. |