Section 15.1 · Chapter 15: Using Macros
Types of Macros
■ Global Macro
A global macro is a macro that can be used by all panel applications in the same
project. With global macros, the panel applications in the same project can
share common functions without having to keep and maintain the same set of
macros locally.
You can set up a password in the Project Information & Protection dialog box to
protect global macros. If global macros are under protection, you need to enter
a password to remove the protection before using them in your application.
Note that only internal variables can be used in global macros.
■ Local Macro
A local macro is a macro that can only be used by the panel application
which the macro is located in.
■ Sub-macro
A sub-macro is a macro that can be run by other macros using the CALL
command. When a CALL command is encountered while running a macro, that macro
stops running, and the sub-macro starts to run. The last command of a sub-macro
must be a RET command which terminates the sub-macro and returns control to the
calling macro. You can place RET commands at any location you want. The HMI will
resume the execution of the calling macro starting with the command following
the CALL command once the called sub-macro terminates.
By implementing common functions in sub-macros for other macros to use, your macros can be modularized, are sharable, easy to read, and easy to maintain.
■ Startup Macro, Main Macro, Event Macro and Time Macro for the application
■ Open Macro, Cycle Macro and Close Macro for the screen
■ On Macro, Off Macro and Object Macro for the object
■ Query Processing Macro for the alarm displays and the historic data tables
■ Data Logging Macro for the data logger
■ Start Macro and End Macro for the schedule
Select the macro that works best for the occasion you want the macro to run, and for the purpose you want the macro to do.
| Run the Macro: | Use: |
|---|---|
| When the application starts |
Startup Macro This macro is run only once when the application starts. The HMI will not display the start-up screen until the macro terminates. You can use Startup Macro to initialize global data and settings for your application. Specify Startup Macro in Panel General Setup dialog box. |
| While the application is running |
Main Macro This macro is run all the time while the application is running. The HMI runs Main Macro cyclically, i.e. it will delay preset time to run Main Macro starting from the first command again each time after it completes the processing of the last command of the macro or when it encounters an END command in the middle of the macro. Specify Main Macro in Panel General Setup dialog box. |
| When a specific trigger bit changes from 0 to 1 |
Event Macro An Event Macro is run whenever the associated trigger bit changes from 0 (off) to 1 (on). An application can have up to four Event Macros which are numbered from 1 to 4. Specify Event Macros in the Panel General Setup dialog box. |
| Periodically with a preset time interval |
Time Macro A Time Macro is run periodically with a preset time interval. An application can have up to four Time Macros which are numbered from 1 to 4. Each Time Macro has a different set of time interval options you can choose to specify how often you want the macro to run. Specify Time Macros in the Panel General Setup dialog box. |
| When a specific screen is being opened |
Open Macro An Open Macro is run once when the associated screen is being opened. The screen will not be displayed until the Open Macro terminates. Specify the Open Macro of a screen in the Screen Properties dialog box. |
| While a specific screen is open |
Cycle Macro A Cycle Macro is run all the time while the associated screen is open. The Cycle Macros runs cyclically, i.e. the Cycle Macro will run starting from the first command again every time after it completes the processing of the last command of the macro, or when an END command is encountered in the middle of the macro. The Cycle Macro terminates immediately when the screen is closed. Specify the Cycle Macro of a screen in the Screen Properties dialog box. |
| When a specific screen is being closed |
Close Macro A Close Macro is run once when the associated screen is being closed. The screen will not be erased until the Close Macro terminates. Specify the Close Macro of a screen in the Screen Properties dialog box. |
| When a specific button is pressed or released to set a bit to on |
On Macro An On Macro is run once when the associated button is pressed or released to set a bit to 1 (on). The setting of the bit will not be performed until the On Macro terminates. Therefore, it is important to keep the On Macro as short as possible in order to not delay the setting of the bit. Both the Bit Buttons and the Toggle Switches can have an On Macro. Specify the On Macro of a button in that button’s configuration dialog box. |
| When a specific button is pressed or released to set a bit to off |
Off Macro An Off Macro is run once when the associated button is pressed or released to set a bit to 0 (off). The setting of the bit will not be performed until the Off Macro terminates. So it is important to keep the Off Macro as short as possible in order to not delay the setting of the bit. Both Bit Buttons and Toggle Switches can have an Off Macro. Specify the Off Macro of a button in that button’s configuration dialog box. |
| When a specific object is activated to perform a specific operation |
Object Macro An Object Macro is run once when the associated object is activated to perform a specific operation. Whether the macro is run before or after the operation is performed depends on the type of the operation. The objects that can have an Object Macro include Screen Buttons, Function Buttons, and Keypad Buttons. Specify the Object Macro of an object in that object’s configuration dialog box. |
| When a specific object needs to display the records filtered by query conditions |
Query Processing Macro A Query Processing Macro is run once when the object displays or the associated trigger bit changes from 0(Off) to 1(On). Both the Alarm Display and the Historic Data Tables can have a Query Processing Macro. Specify the Macro in that object’s configuration dialog box. |
| When a data logger has to log processed data instead of original data |
Data Logging Macro The data logging macro is activated whenever a record of data is sampled. It is used to process the sampled data and save the converted data to the logging buffer by the SAVE2LB command. Specify the Data Logging Macro in the Data Logger properties dialog box. |
| When a schedule is activated to perform a specific operation at the start time |
Start Macro A Start Macro is run once at the designated start time upon the schedule. Specify Start Macros in the Schedule properties dialog box when the Run Macro action is selected. |
| When a schedule is activated to perform a specific operation at the end time |
End Macro A End Macro is run once at the designated end time upon the schedule. Specify End Macros in the Schedule properties dialog box when the Run Macro action is selected. |
Need PM Designer itself?
V4 for current PK, PT, ITV and PM panels, V2 for older models. Free, sent by email.
Source.Section 15.1 of the PM Designer Software User Manual, Edition 2.0, © Cermate Technologies Inc. (www.cermate.com, service@cermate.com). Reproduced online, with the manual's own figures, by TSL Automation Solutions, authorised Cermate distributor, for users of Cermate HMI panels. PM Designer and PanelMaster are trademarks of Cermate Technologies Inc.
Text and figures are the manufacturer's and may describe features your panel or software version does not have. For a plain-language introduction read the PM Designer guide; for help with a specific panel contact TSL Automation.