• No results found

Displaying Shared or Local Symbols

Call Hierarchy in the User Program

Alternative 2: Create Software First

7.3 Displaying Shared or Local Symbols

You can distinguish between shared and local symbols in the code section of a program as follows:

Symbols from the symbol table (shared) are shown in quotation marks "..".

• Symbols from the variable declaration table of the block (local) are preceded by the character "#".

You do not have to enter the quotation marks or the "#". When you enter your program in Ladder, FBD, or STL the syntax check adds these characters automatically.

If you are concerned that there may be some confusion because, for example, the same symbols are used in both the symbol table and the variable declaration, you must code the shared symbol explicitly when you want to use it. Any symbols without the respective coding are interpreted as block-specific (local) variables in this case.

Coding shared symbols is also necessary if the symbol contains blanks. When programming in an STL source file the same special characters and

guidelines for their use apply. Code characters are not added automatically in free- edit mode, but they are still necessary if you wish to avoid confusion.

Note

Using the menu command View > Display > Symbolic Representation you can toggle the display between the declared shared symbolic and the absolute addresses.

7.4

Symbol Table for Shared Symbols

7.4.1 Symbol Table for Shared Symbols

Shared symbols are defined in the symbol table.

An (empty) symbol table (”Symbols" object) is created automatically when you create an S7 or M7 program.

7.4.2 Structure and Components of the Symbol Table

Structure of the Symbol Table

Table Edit Insert

Symbol Editor - Project/SIMATIC300 Station(1)/CPU314(1)/.../Symbols

View Window Help

Symbol Address Data Type Comment

1

Project/SIMATIC300 Station(1)/CPU314(1)/.../Symbols

O M C

O/M/C Columns

The columns O/M/C shows whether a symbol was assigned special object properties:

• O means that the symbol can be operated and monitored with WinCC.

• M means that a symbol-related message (SCAN) was assigned to the symbol.

• C means that the symbol is assigned communication properties (can only be selected with NCM).

Symbol

The symbolic name must not be longer than 24 characters. A symbol table can contain a maximum of 16380 symbols.

You cannot assign symbols in the symbol table for addresses in data blocks (DBD, DBW, DBB, DBX). Their names are assigned in the data block declaration.

For organization blocks (OB) and some system function blocks (SFB) and system functions (SFC) predefined symbol table entries already exist which you can import into the table when you edit the symbol table of your S7 program. The import file is stored in the STEP 7 directory under ...\S7data\Symbol\Symbol.sdf.

Address

An address is the abbreviation for a particular memory area and memory location. Example: Input I 12.1

The syntax of the address is checked as it is entered. A check is also made to see whether the address may be assigned the specified data type.

Data Type

You can choose between a number of data types available in STEP 7. The data type field already contains a default data type which you may change, if

necessary. If the change you make is not suitable for the address and its syntax is incorrect, an error message appears as you exit the field.

Comment

You can assign comments to all symbols. The combination of brief symbolic names and more detailed comments makes creating programs more effective and makes your program documentation more complete. A comment can be up to 80 characters in length.

Converting to C Variables

You can select symbols in the symbol table for an M7 program and convert them to corresponding C variables in conjunction with the ProC/C++ software option.

7.4.3 Addresses and Data Types Permitted in the Symbol Table

Only one set of mnemonics can be used throughout a symbol table. Switching between SIMATIC (German) and IEC (English) mnemonics must be done in the SIMATIC Manager using the menu command Options > Customize in the "Language" tab.

IEC SIMATIC Description Data Type Value Range

I E Input bit BOOL 0.0 to 65535.7

IB EB Input byte BYTE, CHAR 0 to 65535

IW EW Input word WORD, INT, S5TIME 0 to 65534

ID ED Input double word DWORD, DINT, REAL, TOD, TIME

0 to 65532

Q A Output bit BOOL 0.0 to 65535.7

QB AB Output byte BYTE, CHAR 0 to 65535

QW AW Output word WORD, INT, S5TIME 0 to 65534

QD AD Output double word DWORD, DINT, REAL, TOD, TIME

IEC SIMATIC Description Data Type Value Range

PQB PAB Peripheral output byte BYTE, CHAR 0 to 65535

PIW PEW Peripheral input word WORD, INT, S5TIME 0 to 65534 PQW PAW Peripheral output word WORD, INT, S5TIME 0 to 65534 PID PED Peripheral input double word DWORD, DINT, REAL, TOD,

TIME

0 to 65532 PQD PAD Peripheral output double

word

DWORD, DINT, REAL, TOD, TIME 0..65532 T T Timer TIMER 0 to 65535 C Z Counter COUNTER 0 to 65535 FB FB Function block FB 0 to 65535 OB OB Organization block OB 1 to 65535

DB DB Data block DB, FB, SFB, UDT 1 to 65535

FC FC Function FC 0 to 65535

SFB SFB System function block SFB 0 to 65535

SFC SFC System function SFC 0 to 65535

VAT VAT Variable table 0 to 65535

UDT UDT User-defined data type UDT 0 to 65535

7.4.4 Incomplete and Non-Unique Symbols in the Symbol Table

Incomplete Symbols

It is also possible to store incomplete symbols. You can, for example, enter only the symbol name first and then add the corresponding address at a later date. This means you can interrupt your work on the symbol table at any time, save the interim result, and complete your work another time. When you come to use the symbol for creating software (without an error message appearing), you must have entered the symbolic name, the address, and the data type.

How Non-Unique Symbols Occur

Non-unique symbols occur when you insert a symbol in the symbol table whose symbolic name and/or address was already used in another symbol row. This means both the new symbol and the existing symbol are non-unique.

This happens, for example, when you copy and paste a symbol in order to change the details in the copy slightly.

Marking Non-Unique Symbols

In the symbol table, non-unique symbols are identified by highlighting them graphically (color, font). This change in their representation means they still require editing. You can either display all symbols or filter the view so that only unique or non-unique symbols are displayed.

Making Symbols Unique

A non-unique symbol becomes unique when you change the component (symbol and/or address) which caused it to be non-unique. If two symbols are non-unique and you change one of them to make it unique, the other one also becomes unique.

7.5

Entering Shared Symbols

7.5.1 Entering Shared Symbols

There are three methods of entering symbols that can be used for programming at a later stage:

• Via Dialog Box

You can open a dialog box in the window where you are entering a program and define a new symbol or redefine an existing symbol. This procedure is recommended for defining individual symbols, for example, if you realize that a symbol is missing or you want to correct one while you are writing the program. This saves you displaying the whole symbol table.

• Directly in the Symbol Table

You can enter symbols and their absolute addresses directly in a symbol table. This procedure is recommended if you want to enter a number of symbols and for when you create the symbol table for a project because you have the symbols which were already assigned displayed on the screen, making it easier to keep an overview of the symbols.

• Import Symbol Tables from Other Table Editors

You can create the data for the symbol table in any table editor you are comfortable with (for example, Microsoft Excel) and then import the file you created into the symbol table.

7.5.2 General Tips on Entering Symbols

To enter new symbols in the symbol table, position the cursor in the first empty row of the table and fill out the cells. You can insert new empty rows before the current row in the symbol table using the menu command Insert > Symbol. You can copy and modify existing entries using the commands in the Edit menu. Save and then close the symbol table. You can also save symbols which have not been completely defined.

When you enter the symbol properties in the table, you should note the following points:

Column Note

Symbol The name must be unique within the whole symbol table. When you confirm the entry in this field or exit the field, a non-unique symbol is marked. The symbol can contain up to 24 characters. Quotation marks (") are not permitted.

Address When you confirm the entry in this field or exit the field, a check is made as to whether the address entered is allowed.

Data Type When you enter the address, this field is automatically assigned a default data type. If you change this default, the program checks whether the new data type matches the address.

Comment You can enter comments here to briefly explain the functions of the symbols (max. 80 characters). Entering a comment is optional.

7.5.3 Entering Single Shared Symbols in a Dialog Box

The procedure described below shows you how you can change symbols or define new symbols in a dialog box while programming blocks without having to display the symbol table.

This procedure is useful if you only want to edit a single symbol. If you want to edit a number of symbols, you should open the symbol table and work in it directly.

Activating Symbol Display in a Block

You activate the display of symbols in the block window of an open block using the menu command View > Display > Symbolic Representation. A check mark is displayed in front of the menu command to show that the symbolic representation is active.

Defining Symbols When Entering Programs

1. Make certain that the symbolic representation is switched on in the block window (menu command View > Display > Symbolic Representation.) 2. Select the absolute address in the code section of your program to which you

want to assign a symbol.