TIAPortal_Basics



In this module, the TIA Portal environment for PLC-programming is introduced.

Learning Outcome

Introduction

Requirements

What You Need

Software

TIA-Portal

tia-umgebung

The TIA Portal environment includes a networks window. Networks act like code lines; code (each network) is run by the CPU from up to down every PLC cycle (i.e., network 1, then network 2, and so on). Programming in networks is useful for good code organization, especially if the programming language used is LAD or FBD.

Programming Blocks

The design of PLC codes in TIA Portal is done with modular blocks. There are divided into 4 types according to their use.

These are:

add_new_block

Creating a new Functionblock

A new project will only have a block called Main OB1. This is the project’s main function. All user created functions and function blocks will be called inside the main function. The block Main OB1 in TIA Portal can be written using either LAD or FBD standard programming languages. In the context of this module, LAD will be used.

The programming language of Main OB1 can be changed through right click on Main OB1 -> Switch programming language.

To create a block, click on Add new block under Program blocks.

add_new_block_with_info

Blocks are useful for organizing and structuring a program.

The following figure shows a new function block that is named State_machine.

fb_with_info

Variables can be declared and used inside the function block.

blink_switch_ex1

To run this FC, you will have to include it inside the Main OB1 block.

To do so, drag and drop the function block into a Main OB1 network to create instance of the function block. Once you drag it on the rail of Main, a pop-up to create a DB would appear. Click OK to create the DB. This data block stores all the instance variables related to that instance of the FC.

fb_in_main_r1

All types of Functions have to be called in Main OB1 to execute them. If they are not in Main OB1, they won’t run or do their task.

A data block is not created to save variables of function code / functions. No instances of function code / functions exist.

Function blocks, however, are initiated as instances. Variables that belong to a specific instance of a function block are saved in a data block that specifically stores variables of that instance only. Creating another instance of the same function block type will create another data block for the new instance. Hence DB instance for LED_1 will be different from LED_2 and will operate separately.

Functions with inputs have to have inputs connected to them in Main OB1. If no inputs are connected to the function, a compilation error will occur.

Function blocks, on the other hand, do not require inputs to be connected to them in Main OB1. Each instance of a function block has its own Data block, in which the inputs of that specific instance is saved.

Using Predefined Functions

TIA Portal provides various predefined functions ready for use. These can be found on the right side under Basic instructions.

For example, if you need a Mathematics based function, expand Math functions and select the required function.

add_funct_example

User-defined functions and function blocks are used in the same way in LAD.

Watch and Force Tables Watch and force tables are tables that are used to monitor variables in real-time while the PLC is running. Watch and force tables can also be used to overwrite variables in real-time. Because they can change variables’ values, they are useful for testing a program. In this module, watch tables will be used to monitor and set variables while the program is running.

Deep Dive: Watch vs Force Tables: Force tables manipulate the peripherals. In this module, watch tables will be used to monitor and test the program. Watch tables are recommended for testing the program. For big programs, every scenario of inputs and outputs could be summed up in a watch table.

watch_force

Creating Watch Tables: To create a new watch table, select Add new watch table under Watch and force tables in the Project tree.

Add the variables you need in the rows. Set the PLC in Online mode (using Online -> Go online) and in RUN mode (Online -> Start CPU)

Once done, select the Monitoring tool from the menu above. Now you can watch the changes in the variables and also modify their values if required.

Watch tables are on PC hence you do not have to download the code again to the PLC.

wtables_r

All the variables shown in this watch table are part of a created data block called IMS_4_DB, hence the IMS_4_DB. at the beginning of the variables names. The address column is empty because these variables in this example were not mapped to a PLC I/O module, but are rather variables that belong to an instance of a user-defined function block called IMS_4.

wtables_setting_r

Using a watch or a force table to manipulate variables influence the real system and overrides the program on the PLC. Be sure that it is safe to do so when working with a real PLC as it may be connected to moving parts or could unintentionally release liquids through valves.

Timers

There are various types of timers available according to IEC standard. Here are the commonly used timers with their timing diagram.

timers

Monitoring runtime values

You can monitor runtime values using Monitor Tool. It looks like the image below. You will find it at various locations.

monitor_values_button