What are macros and how to use them in an HMI application? | HMI programming course. Part 6.


During the course you will learn, among others:

  • How to create a new script
  • How to use the IF..ELSE conditional statement
  • How to configure a time macro

In the previous article from the series "What types of variables are used in operator panels? | HMI panel programming course episode 5" we described how to create and assign variables to graphic objects.

In this episode, you will learn how to write simple control programs (macros) based on the built-in script editor. In the software for programming and configuring Astraada HMI panels, the editor is very intuitive, automatically marks the syntax and provides quick access to extensive help, which will significantly speed up your program writing.

How to create a macro and assign it to a function?

Start by creating a new macro called MAIN. You can do this in the Native Scripts tab in the application tree. Go to edit the macro, enter or copy the code below and read its syntax carefully.

Save and compile the program. Then open a new macro called second.

This code will increment the value of the counter variable and will serve as a time macro, which you will now add to the main application configuration in the General Setup tab.

In the General Setup window, select the Main Macro option and in the tab of the same name select the created MAIN code.

Return to the General tab and select Time Macro #1. Set the execution interval to 1 second so that the time code works correctly. Now go to the Time Macro #1 tab and, similarly to the previous step, select the seconds script you created.

Save, compile and test the program using the offline simulator. You can observe the change in the liquid level displayed on the bar graph on the tank. Additionally, the DATA window should display the actual numerical values for the monitored variables.


In this episode you learned how to write macros - simple control programs and how to use them in practice. In the next part of the series, you will learn how to add and configure alarms.

If you have any questions at this stage of the course, write them in a comment - we will be happy to answer :)


In the next part of the course "How to configure alarms in operator panels? | HMI panel programming course episode 7” you will learn:

  • how to add and configure alarms,
  • how to display messages using variable monitoring,
  • how to present currently needed data on the operator panel.

Authors:
Paweł Podsiadło
Ewelina Niziołek