How Can We Help?

Print

How do I return to a specific HMI screen number after a certain period of inactivity?

 

Occasionally it is useful to return to a specific screen after a period of inactivity.

Register used to indicate the screen number to be displayed

You can define the register that will be used to indicate the number of the HMI screen to be displayed. This register can be the HMI register or a register of a connected PLC.

Let’s choose LW1 for our example.

Check screen usage activity

We’re going to use register LW60296: this indicates whether or not the touchscreen has been touched. (HMI internal registers)

Script: Timer, touch and screen jump

#include "MacroInit.h"
void Macro_main(IN *p)
{
MarcoInit
//ToDo
if (LocalWord[60296] == 1) Count=0; // Touch state : 1=Touch; 0=Release
Count ++; // Increment at each Script call (every 100 ms for example)
if (Count > 50) LocalWord[1]=0; // LW1 is define in System Setting > PLC Control
}

This script :

  • Checks whether the screen has been touched; if so, resets the counter.
  • It increments the counter each time the script is called.
  • If the counter exceeds a certain value (here 50 script calls every 100 ms = 5 seconds), we indicate to the register the screen number to be displayed.

“Count” is a variable to be declared in “Variable settings”. Useful if you wish to use it for display the timer on a screen.

If you don’t wish to display it on a screen, you can remove it from the “Variable settings”, and add this after “// ToDo”.

int Count; //This is an internal script variable