WinCC SCADA (Windows Control Center – Supervisory Control and Data Acquisition) by Siemens is a powerful industrial automation software used to monitor, control, and visualize industrial processes. It supports the integration of VBScript (Visual Basic Scripting Edition) to enable dynamic behavior in SCADA graphical user interface (GUI) screens. VBScript in WinCC SCADA allows developers to implement custom automation logic, handle events, manipulate data, and create interactive SCADA interfaces.
One of the key benefits of using functions in VBScript is to promote code reusability, reduce repetition, and improve the maintainability of SCADA projects. Functions make scripts cleaner, modular, and easier to debug or update.
This tutorial explains how to create, structure, and use functions within WinCC SCADA using VBScript. In the example below, we demonstrate how to define a simple global function to read from and write to SCADA tags. These reusable functions simplify your SCADA scripting and help build efficient automation routines in your WinCC project.
VBScript is a lightweight and easy-to-learn scripting language, making it suitable for creating responsive and scalable SCADA solutions. Whether you're automating alarms, controlling process flows, or handling operator inputs, VBScript provides the flexibility to tailor SCADA behavior precisely to your plant's needs.
A Global VBScript in WinCC SCADA is used to define reusable functions, standard modules, project modules, and global actions that can be accessed throughout the entire SCADA project. Functions created within the global script are not limited to a single screen or object—they can be invoked from any part of the project, making them ideal for standardizing automation routines across multiple areas. You can create multiple global functions and actions to be reused in the same project or exported for use in other WinCC SCADA projects, promoting modular development and easier maintenance.
The Global Script Editor in WinCC SCADA allows you to create global functions, actions, standard modules, project modules, and routines. To open the Global VBScript Editor:
Inside this editor, you can write and organize reusable script blocks that serve as the backbone of custom logic across your SCADA project. These scripts help automate complex tasks, manage tag operations, handle events, and improve overall project efficiency.
To create a global function in WinCC SCADA using VBScript, open the VBScript editor and follow these steps:
TagFunctions
or Utilities
.These functions can then be called from anywhere in your SCADA project, making them ideal for centralizing logic like tag read/write operations, validations, or repetitive tasks.
In this article, we demonstrate how to create a simple global function in WinCC SCADA using VBScript to read from and write to any tag value. This example helps you understand how to centralize tag operations for reuse throughout your SCADA project. Below is a sample script written in the Global VBScript Editor that shows how to define these functions effectively. after adding function check syntax and save it.
Below is a simple example of how to create two global VBScript functions in WinCC SCADA—one for reading a tag value and another for writing a value to a tag.
This function takes the name of a tag as input and returns its current value.
This subroutine writes a specified value to a given tag.
These reusable global functions can be called from anywhere within the SCADA project to simplify tag handling and reduce redundant code.
Open the Graphics Designer in WinCC SCADA and add two fields: one for input and one for output. Assign appropriate tags to both fields. In this article, we are using an input tag to read a value, which will then be multiplied by 2, and the result will be written to the output tag when a button is clicked.
Next, add a button to the screen. Open the button’s properties, go to the Events tab, select the Mouse Click event, and then choose VBScript to assign your script that performs the tag read, calculation, and write operation.
To use a global VBScript function in a WinCC SCADA graphics object, open the Graphics Designer and select the object (such as a button) where you want to execute the script. Then, open the object's properties, go to the Events tab, and choose the appropriate event—for example, Mouse Click.
In the VBScript editor for that event, you can directly call any function that has been defined in the global script module. For example, if you created a global function to read and write tag values, you can call it here with the required parameters. This approach keeps your code clean and modular while allowing centralized control of logic.
Below is an example of how to add a call to a global function within the object's VBScript event handler.
The following VBScript is executed when a button is clicked in the WinCC SCADA graphics screen. It demonstrates how to use a global function to read a tag value, perform a calculation, and write the result to another tag.