Direct tags import from S7 PLC

The import routine of the driver permits to import S7 PLC tags from three types of file: “.s7p “, “.awl ” and “.SDF”.

Import variables directly from Siemens STEP7 projects

The driver can import the variables directly from a project STEP7, opening the “.s7p” file in the folder of the project STEP7.

If your project has multiple programs it is necessary to choose the program from which you want to import the variables.

The driver can import variables from the symbols file of the project (Merker, Input, Output) or variables defined in the Data Blocks (DB).

The importer will create variables in the supervisor with the same name defined in the s7 project and will assign the physical address to the variable’s property “I/O physical address”.

There are some STEP7’s data types that are not supported by the driver, and therefore cannot be imported. Non-supported types are:

  • “TIME”

  • “DATE”

  • “TIME_OF_DAY”

  • “DATE_AND_TIME”

  • “POINTER”

  • “ANY”

The variables of these data types will be ignored by the importer.

Import from files

Using the “Import from file” button permits to import PLC tags exported by CODESYS Workbench.

  • For CODESYS 2.3 select the file format “.sym” CODESYS files

  • For CODESYS 3 select the file format “.xml” CODESYS files

Array

Only one-dimensional arrays are managed. Multidimensional arrays are split in one-dimensional arrays. In this case the name of each one-dimensional array is formed by the name of the multidimensional array and a progressive index.

Structures and UDT (User Data Types)

For structures and UDT used in a DB, two cases must be distinguished: if they contain only members of basic data types (not strings, arrays, or other structures or UDT), they will be imported into the RealTimeDB of the supervisor as structure type variables, by creating their prototype structures; while for structures and UDTs containing complex data types such as arrays, strings or other structures or UDT, a variable structure will be created (along with its template) formed only by the contiguous simple data type elements. The rest of the structure or UDT will be split into individual variables.

For example, assuming we have a UDT composed as follows:

TYPE UDT 1
 STRUCT
     Var1 : BOOL;
     Var2 : WORD;
     Var3 : INT;
     Var4 : ARRAY  [0 .. 6 ] OF BYTE;
     Var5 : INT;
     Var6 : BYTE;
  END_STRUCT ;
END_TYPE

The importer will create a variable of type structure (and its prototype) composed by members Var1, Var2 and Var3, and then it will create three additional variables: the array UDT_1_Var4, the Sign Word UDT_1_Var5 and UDT_1_Var6 of type Byte.

When needing to decrease the number of variables to be imported, it would be a good rule of the thumb to create structures and UDT with composed data types (arry variable) in the last positions, after the simple data type (byte, word, etc.).

In order to import the .s7p file successfully, the driver requires that the “AGLink40.DLL” be present in the Movicon installation directory.

Import from file “.sdf” and “.awl”

These files can be easily produced using the “Export” function from the STEP7 Programming environment. In particular, an “.awl” file can be obtained selecting a block from the blocks list, creating a source with the “File/Generate source” menu, then exporting it to an .awl file with the “Edit/Export source” menu.

Please note the driver can not import from AWL files using symbolic addresses, but only absolute addresses. In S7 manager application, while using the ‘Generate Source’ function to create AWL file, be sure the ‘Absolute addresses’ option is selected.

Please note also that if an “.awl” file contains more than one data block, only the tags of the first data block are imported.

The format obtained from the S7 exporting for a “.sdf” file is the following:

“Symbol” “Address”

Where the “Symbol” field is related to the Variable Name, and the “Address” field is related to the address of the variable on the PLC. Any other information will be not considered.

The address field should be as Siemens standard.

Example

“PumpON” “M33.4”
“PumpStatus” “DB33.DBB46”

If the import file includes data whose type is unsupported by the driver, these data are skipped. Unsupported types are:

  • TIME

  • DATE

  • TIME_OF_DAY

  • DATE_AND_TIME

nevertheless their bytes occupation is taken into account to set the proper address for the following tags.

User Defined Data Types (UDT) are supported beginning from version 10.1.0.4. In the S7 manager application, while using the ‘Generate Source’ function to create the AWL file of a Data Block containing User Data Types, please, be sure that the ‘Include reference blocks’ option is selected.

UDT structures and arrays can be imported as supervisor structures and arrays starting from version 10.1.0.9. This kind of data are represented on a tree view with a +/- sign on their left, to expand or collapse them.

To import a structure or array as a supervisor structure or array, select it when collapsed and press the Import button. The corresponding prototype structure will be added to the supervisor tags database.

To import its members as single tags, select it when expanded and press the Import button.

If an UDT structure includes a string it can only be imported as split in its members, since the supervisor does not manage fixed length strings.

If an UDT structure includes an array or another structure, it can only be imported as split in its members, since the supervisor does not manage recursive structures.

Structures that are not UDT are imported as split in their members.

Arrays of basic types (Byte, signed/unsigned Word, signed/unsigned DWord, Float) are imported in the supervisor as arrays of the corresponding basic type.

Arrays of Bits or Strings are not supported in the supervisor, a tag is created in the supervisor tags database for any array’s member.

Arrays of UDT are split in the corresponding UDT members.

Arrays of non UDT structures can only be imported as split in their members.

Arrays’ elements are imported in the supervisor always starting from 0 index.

Notes:

S5TIME variables are imported as Dword data type in the supervisor, but they are addressed as word data type. These variables are managed as words on the PLC, where value and time format are stored. When they are converted to be shown in the supervisor, including milliseconds, they require dword data type.

STRING variables are imported keeping two bytes free before the starting address. As an example, if 0 is the first free address, the string variable is addressed starting from byte 2. i.e. DB1.DBB2:5 is a five characters string; bytes 2 to 7 are used for chars while two more bytes, byte 0 and 1, should be reserved for string management on the PLC.

Tag from Peripherals area are imported as Input type if address is PE, Output if address is PA, Input/Output if address is P.

The following is an example of a .awl file:

DATA_BLOCK DB 1
VERSION : 0.1
  STRUCT
   Bit_Var : BOOL ;    //bit tag
   Byte_Var : BYTE ; // byte tag
   Word_Var : WORD ; // word tag
   DWord_Var : DWORD ; // double word tag
   Int_Var : INT ; // integer tag
   DInt_Var : DINT ; // double int tag
   Real_Var : REAL ; // float tag
   S5Time_Var : S5TIME ; // s5 time tag
   Struct_Var : STRUCT // structure tag
    Bit_Var : BOOL ;
    Byte_Var : BYTE ;
    Word_Var : WORD ;
    DWord_Var : DWORD ;
    Int_Var : INT ;
    DInt_Var : DINT ;
    Real_Var : REAL ;
    S5Time_Var : S5TIME ;
   END_STRUCT ;
  END_STRUCT ;
BEGIN
   Bit_Var := TRUE;
   Byte_Var := B#16#0;
   Word_Var := W#16#0;
   DWord_Var := DW#16#0;
   Int_Var := 0;
   DInt_Var := L#0;
   Real_Var := 0.000000e+000;
   S5Time_Var := S5T#0MS;
   Struct_Var.Bit_Var := FALSE;
   Struct_Var.Byte_Var := B#16#0;
   Struct_Var.Word_Var := W#16#0;
   Struct_Var.DWord_Var := DW#16#0;
   Struct_Var.Int_Var := 0;
   Struct_Var.DInt_Var := L#0;
   Struct_Var.Real_Var := 0.000000e+000;
   Struct_Var.S5Time_Var := S5T#0MS;
END_DATA_BLOCK

The start address of each variable of the Data Block is automatically calculated by the import tool on the basis of the variable placement in the list, the data type and the Step 7 addresses assignment method.