meta data for this page
LamaPLC: Simatic TIA Portal know-how
I predict that in the chapter, I will write the descriptions in my own words, as if I were trying to explain things to a friend. The description may not be professional this way, but my goal is for anyone who reads to understand what is described.
I have quite a lot of experience (more than 20 years) with Simatic systems, based on which I plan to develop this site.
If you have a specific question or request, please let me know! > Impressum
Management of TIA Portals with different versions
As a development engineer, I have to work with several different versions of TIA-Portal at the same time. I test the latest (currently 20), and develop new projects in 18. And I need to be able to open the old projects somehow. In theory, several TIA versions can exist on the machine at the same time, but in the case of WinCC (especially in the case of WinCC professional) this is not true. On my machine, only the current version always runs “directly”, and the rest are available on a virtual machine. Apparently, the V18 running on the current machine cannot open the older V15, so when I try to connect to the CPU online, I get the following error message:
In this case, I have two options:
1.) Delete the old V15 project from the CPU and overwrite it with the current V18 version. This solution can be implemented if:
- I'm pretty sure the version ported on PC (V15→V18) is DEFINITELY the same as the CPU version
- I have the opportunity to test the new version locally on the CPU
- I have a save from the old (V15) CPU version
2.) First connect ON-LINE with the PC to the old (V15) TIA Portal, save it and modify / repair it.
Second, if I can test the new version on the CPU, then download the ported V18 version to the CPU. In many cases, the focus is on the possibility of testing, and that's where the possibility of porting fails. “Don't touch a working system!” - this is usually the basic principle, so the old (V15) version remains on the CPU even after possible modifications and downloads. In this case, however, it is good to have several versions of TIA Portal on your PC that can be used simultaneously.
The use of a virtual machine is a big help in this. I use VmWare, a program available at a relatively normal price, its operation is very stable. I have saved several virtual machines simultaneously from various TIA portals, I always open the one that can “talk” to the CPU.
I always have a current “empty” Windows machine (“one” in the picture above). I install the current TIA version on it. For example, in the case of V15, type “tia 15 download” into Google. this will give you the download path, in this case this.
On the virtual machine, look for CD/DVD (SATA) in the settings and set the path to the downloaded TIA Portal ISO file here:
When we open the VmWare image, the DVD drive automatically opens the ISO file and we can start the installation:
Important: If the virtual machine is not shut down properly (this often happens to me), its lock “remains” and does not allow you to open the machine again, for example:
In this case, the locking directory must be deleted in the directory of the given virtual machine:
And, tadaaam, you can open the VmWare image.
FC / FB description
FC: function
FCs are programming blocks that do not require static variables, that is, they do not need internal information that would be stored from one cycle to another. It is therefore not necessary to assign data blocks, i.e. DBs, to FCs.
In the references, I denote FCs as follows: _FC_
for example: _FC_ Result := ABS (Value);
I repeat because it is important: The internal variables of the FC are valid only within one cycle, they lose their values for the next cycle. If you need to store information, use the FB or call DB, merkel.
Add new FC
FB: function blocks
FBs are a bit more complex modules than FCs. FBs are able to define cyclical variables, these are “static” variables. These are not actually stored in the FB, but will be assigned a datablock (DB) to each FB and it will store these variables. These DBs should be called IDBs (instant datablocks) because, unlike global DBs, they are assigned to a specific FB. In addition to storing variables, IDBs are also suitable for storing embedded FBs, this will be discussed later. The IDB will be assigned to a given SC during the first call.
In the references, I denote FBs as follows: _FB_
for example: _FB_ RetVal (INT):= BLKMOV (SRCBLK := source block (VARIANT); DSTBLK ⇒ destination block (VARIANT); ENO ⇒ operation enable );
Add new FB
FC / FB variable types
When we open the newly created Fc or FB (FB in the example) we will see the following image:
Field reports:
Name | FC / FB | description |
---|---|---|
Input | FC and FB | Variables read by modules. |
Output | FC and FB | Variables write by modules. |
InOut | FC and FB | Variables read and then written back by modules. Changes made to the module are reflected in the outputs. |
Static | FB only | static variables: their value is retained because they are stored in the IDB assigned to the FB. If you open the IDB, you can follow the change in the value of the variables there. |
Temp | FC and FB | Temporary variables: they can only be used within the given cycle, they will lose their value at the time of another call. |
Constant | FC and FB | Constant values: their value must not change. |
Return | FC only | the return value of the function, which is the name of the function. In the case of an external call: retval: = Function_name (); |
Call FCs
Calling FCs is easier:
- the part of the program (FC, FB or OB) from which the FC is to be called must be opened.
- drag-and-drop the FC from the “instructions” window, or simply plug it in. For example, after indentation, “LN” FC looks like this: LN (_real_in_)
- you need to know, for example from here that the “LN” FC is calling floating-point numbers, ie REAL or LREAL.
- the return value must also be given, eg: out:= LN(in); where in and out are REAL.
Call FBs
When calling FBs, we have two options:
- each invited sub_FB receives its own IDB
- sub_FBs are treated as an embedded function and their data area will be “taped” to the IDB of the calling FB.
Let's see this through examples, let's take one of the most commonly used methods, TON:
First method, call with separate IDBs:
Second method, call embedded FBs:
Switch off "optimization" attribute of DBs
By default, the TIA portal turns on the “optimization” attribute of DBs, which means that the order of variables in DBs is automatically optimized.
In many cases, this causes serious problems when the given variables have to remain in predefined positions, such as OPC, or typically any similar communication (Modbus, PN, ..) DB. For example, the BLKMOV command does not work with optimized DBs either.
To deactivate, right-click on the DB and select Properties… and then Attributes:
The “optimized block access” attribute in the menu must be turned off.
For generated DBs, the {S7_Optimized_Access: = 'TRUE'} entry should be modified as follows: {S7_Optimized_Access: = 'FALSE'}.
Import source code to the TIA portal
Troubleshooting in the TIA Portal
This is perhaps the “favorite” pastime of programmers. Errors are divided into Systematic and Semantic errors. Systematic are consistently repeated but formally correct errors that the compiler cannot “protect”, the programmer must find their cause.
Semantic error is simpler, the compiler also “notices” this. It is typically displayed as follows:. The TIA-portal compiere also indicates warnings, as follows:
These do not prevent the compilation and download of the program, they only draw attention to possible causes of errors, for example data conversions where data may be lost. A typical error report on the TIA portal looks like this:
In the event of an error, the program automatically opens the “Compile” status window to review the errors. The location and presumed cause of the error/errors is indicated here. In this case, a typing error is indicated, and the location of the error in the code is indicated by the compiler with a red underline. At the bottom of the list, the program also displays warnings for some conversions, but these are only warning signals, they do not hinder the translation and download.
There are cases when the compiler cannot reveal the location or cause of the error, or the program throws a “strange” error message (I will copy this here the next time I encounter it). This error mainly occurs when you switch between online and offline status several times and make changes to the program in the process. In such cases, it is easiest to recompile the entire program and perform a full download:
Right click on the PLC → compile → Software (rebuild all). Caution, since this means a complete download, the PLC must normally be switched to STOP (and then restarted) for this operation.
This page has been accessed for: Today: 1, Until now: 147