Description
The TIA Portal V19 Update 2 and TIA Portal V18 Update 4 can cause assignments to be swapped during code generation in the SCL editor. This behavior occurs when structural variables are used within nested control statements. For instance:
- An IF statement inside a CASE instruction
- An IF statement nested within another IF statement
If structural variables are assigned values outside the control instructions and then reused along with block calls within nested IF-ELSE blocks, the SCL code optimizer does not generate new assignments for all subsequent uses of these variables within the nested IF-ELSE blocks.
Any combination of nested IF and CASE instructions can lead to the aforementioned behavior.
In the images below, we present some program examples where the SCL code optimizer did not generate any new assignments. Please compare these program examples with your own to see if this behavior applies to your situation.
Example 1
The variable "Static_2" should be assigned the value 8 (the value of the variable "Structure.Select"), but it is instead assigned the value 7 (the value of the variable "Structure.Control").
Example 2
The variable "Static_2" should be assigned the value 8, which is the value of the "Structure.Select" variable, but instead, it is assigned the value 7, which is the value of the "Structure.Control" variable.
Example 3
The array variables "Position[2]" and "Position[3]" should receive the values of "structArray[0].y" and "structArray[0].z," respectively. However, both variables have received the value from "StructArray[0].x."
Example 4
The variable "Static_2" should be assigned the value 8, which is the value of the variable "UDT.Select," but it has instead been assigned the value 7, which is the value of the variable "UDT.Control."
Resolution Measures
Resolution Measure 1 - Update
Install TIA Portal V19 Update 3 or TIA Portal V18 Update 5 to avoid the aforementioned behavior.
Resolution Measure 2 - Patch
(Alternative to Resolution Measure 1)
The corrections for these two updates are also included in the following patches. If you are unable to install these updates (e.g., due to pending IT approval), we temporarily provide these patches for you.
Install the patch for TIA Portal V19 Update 2 or V18 Update 4. The corresponding patch ensures that the SCL code optimizer also generates assignments for all subsequent structural variables. After installing the patch, you must recompile all program blocks and reload them into the CPU. When compiling, make sure to select "Software (Full Rebuild)." From now on, the aforementioned behavior will no longer occur.
SCL-Optimizer Patch V18
SCLOptimizerPatch_V18.zip (927.2 KB)
This patch is only applicable to TIA Portal STEP 7 V18.00.01.04 (V18 Update 4).
Manual Installation
Copy the ZIP file to the local drive of the PC where you want to install the patch.
Extract the ZIP file to a temporary folder on the local drive of the PC.
Back up the original DLL files from the folder "C:\Program Files\Siemens\Automation\Portal V18\Bin" (if it's a standard installation).
Copy the DLL from the ZIP file to the folder "C:\Program Files\Siemens\Automation\Portal V18\Bin" (if it's a standard installation).
Automated Installation
Extract the "PatchSCLOptimizer.zip" file on your PC. Make sure the extracted folder name does not contain any special characters other than "." or "_".
Run the "PatchSCLOptimizer_Installer.cmd" file with administrative privileges by selecting "Run as administrator" from the right-click menu.
SCL-Optimizer Patch V19
This patch is only applicable to TIA Portal STEP 7 V19.00.00.02 (V19 Update 2).
Manual Installation
Copy the ZIP file to the local drive of the PC where you want to install the patch.
Extract the ZIP file to a temporary folder on the local drive of the PC.
Back up the original DLL files from the folder "C:\Program Files\Siemens\Automation\Portal V19\Bin" (if it's a standard installation).
Copy the DLL from the ZIP file to the folder "C:\Program Files\Siemens\Automation\Portal V19\Bin" (if it's a standard installation).
Automated Installation
Extract the "PatchSCLOptimizer.zip" file on your PC. Make sure the extracted folder name does not contain any special characters other than "." or "_".
Run the "PatchSCLOptimizer_Installer.cmd" file with administrative privileges by selecting "Run as administrator" from the right-click menu.
Note
After installing the patch, in some cases, TIA Portal may crash during compilation. In such cases, please open Windows Explorer and search for the DLL file "Siemens.Simatic.Lang.SclPlusCompiler.dll." Open the properties of this DLL file and activate the "Unblock" feature in the "General" tab (see Figure 5). Then, you can compile the SCL program again.
FAQ Recent Updates
Descriptions of Resolution Measure 1 (Update) and Resolution Measure 2 (Patch Installation) have been provided.