First steps 3
3.1 Basic functions of the Totally Integrated Automation Portal
3.1.4 Programming the PLC
3.1.4.1 Programming environment in the TIA portal.
This section provides an overview of the TIA portal's programming environment:
•
Programming languages•
Program editor•
Symbolic programming•
LibrariesProgramming languages
The TIA portal supports you in the programming of code blocks in the following programming languages:
•
Ladder Logic (LAD)•
Function Block Diagram (FBD)Program editor
The program editor is the integrated development environment for programming functions, function blocks, and organization blocks. If offers comprehensive support for programming and troubleshooting.
Using LAD as an example, the following figure shows the components of the program editor:
3.1.4 Programming the PLC 3.1.4.1 Programming environment in the TIA portal.
3.1 Basic functions of the Totally Integrated Automation Portal
Symbolic programming
To make the program layout clearer and to simplify trouble-shooting, it is advisable to use symbolic names for the operands and tags in the programming.
You specify the symbolic names:
•
Define symbolic names for global tags in the PLC tag table.•
In the block interface, specify symbolic names for local tags in logic blocks or in global data blocks.Support during programming
When programming you can start out working with symbolic operands and then assign the absolute addresses later. The program can still be saved, even though the assignment is incomplete.
An operand to which no absolute address has yet been assigned is highlighted by a red wavy underline.
Libraries
You can store objects you want to use more than once in libraries. It is possible to reuse the stored objects throughout a project or across projects. This means you can, for example, create block templates for use in different projects and adapt them to the particular requirements of your automation task.
Libraries can accommodate a large number of objects. These include, for example:
•
Functions (FCs)To create the program for your automation solution, you have to add the blocks in the project and program them. You can add new devices in either Portal view or in Project view. The program editor and the task cards in the Project view support you in the programming.
Adding blocks in Portal view
To add a block in Portal view, follow these steps:
1. Select "PLC programming > Add new block".
3.1.4.2 Adding blocks
3.1 Basic functions of the Totally Integrated Automation Portal
2. Click on one of the buttons to create the block type you want.
3. Select the programming language for code blocks.
4. If necessary, change the block properties.
5. Click "Create".
Result
The block is created and opened in the program editor.
Adding blocks in Portal view
To add a block in Portal view, follow these steps:
1. Go to the required device in the project tree.
2. Double-click "Add new block" under "Program blocks".
The same selection dialog as in Portal view opens.
3. Execute steps 2. to 5. as in the Portal view.
Additional steps
You program a code block.
3.1 Basic functions of the Totally Integrated Automation Portal
3.1.4.3 Programming a code block
This section shows you how to program a function block in the programming language LAD in the program editor.
Requirement
The function block is created and opened in the program editor.
Procedure
To program a function block, follow these steps in any order:
•
Programming instructions•
Declaring the block interface•
Declaring PLC tags and using these in the programThese actions are explained below on the basis of examples.
Programming instructions
You have the following options for inserting LAD elements in a block:
•
Per drag-and-drop operation from the "Instructions" task card•
With the help of an empty box to which you subsequently assign a LAD instruction. You can find the empty box under "General", in the "Instructions" task card. To assign an instruction, click the yellow triangle in the upper right corner and select the instruction from the drop-down list box.Declaring the block interface
The block interface is shown as a table in the upper part of the program editor.
3.1.4.3 Programming a code block
3.1 Basic functions of the Totally Integrated Automation Portal
To declare a tag in the block interface, follow these steps:
1. Select the section (Input, Output, ...).
2. Enter the tag name in the "Name" column.
3. In the "Data type" column, select a data type from the list.
4. If required, enter a default value.
Result
The tag is created. A syntax check is performed after each entry, and any errors found are displayed in red.
3.1 Basic functions of the Totally Integrated Automation Portal
3.1.4.4 Declaring PLC tags
Using PLC tags and local tags in the program
You can define tags with different scopes for your program:
•
PLC tags are valid for the entire CPU and can be used by all blocks of a CPU. PLC tags are defined in the PLC tag table.•
Local tags apply only to the block in which they are defined.Opening the PLC tag table
To open the PLC tag table in a CPU, proceed as follows:
1. Open the "PLC tags" folder under the CPU in the project tree.
2. Double-click the PLC tag table in the folder.
3. In the top right corner select the "PLC tags" tab or the "Constants" tab.
Structure of the PLC tag table
The figure below shows an example of the structure of the PLC tag table.
3.1.4.4 Declaring PLC tags
3.1 Basic functions of the Totally Integrated Automation Portal
You can click the symbol in the first column to drag a tag into a network and use it there as an operand.
Declaring PLC tags
Operands that are not declared as PLC tag will be displayed in red in the program editor. You can declare PLC tags in the following way:
•
Directly in the programSelect an operand and click "Define tag" in the shortcut menu. The "Define tag" dialog box is opened.
This dialog displays a declaration table in which the name of the operand is already entered.
In the "Section" column, select the type you want and enter address, data type and comment in the other columns.
•
In the PLC tag tableOpen the PLC tag table you want to use. Enter the name for each PLC tag and select the data type.
3.1 Basic functions of the Totally Integrated Automation Portal