How to make a toggle button in SCADA/HMI?

A toggle button is a button when user presses, the state will be toggled. For example, a button initially at “OFF” state, when user presses, it switches to “ON” and stay in that state. Then, when user presses again, it will be switched to “OFF”, and so on.

A toggle button is usually common in panels at site. Thus, when process automation is implemented, the same behavior is required in SCADA HMI front-end.

In this training, we will learn how to make a toggle button in SCADA/HMI. Or in other words, how to configure a SCADA/HMI button into a toggle button.

Create a new or open an existing project, choose a tag that will be used for the toggle state. Then, open Inkscape SAGE and draw a button. Right click on the button and select “Object Properties”. Navigate to “Script” tab, and insert the script as shown in example below.

Ecava IGX SCADA training HMI toggle button

Basically what the script does is:
1. Read the current state of the tag
2. Reverse the state (or toggle it)
3. Write the new state into the tag

For Boolean type tag, the values are only true/false, hence the script will be as following.

setTag('tagname', !getTag('tagname'));

While for Integer type (non Boolean) tag, it is achievable with the following script.

if (getTag('tagname') == 0) { setTag('tagname', 1);} else {setTag('tagname', 0);}

By setting this, the button will behave as a toggle button upon user’s interaction.


Download Ecava IGX today and create your own HMI buttons and mimics anyway you want!


← Back to SCADA Training

Do NOT follow this link or you will be banned from the site!