In this post, we will show you how to synchronize the HMI clock with the ACE PLC clock.

As the HMI has a saved clock, we use it to update the ACE PLC clock.

 

With vBuilder

First of all, it is necessary to define in the Modbus register these UI8 tags that will be written by the HMI.

Address 4×900 to 4×905. Don’t forget to set them to «Writable» : «Y»

You will get the clock of the HMI in your ACE PC.

With HMI-Tool

In the Macro Editor, add a new macro and copy it. You don’t have to use all the tags, if you need, for example, only the hours and minutes.

#include «MacroInit.h»
void Macro_main(IN *p)
{
MarcoInit
//ToDo
Sec = Convert (BCDSec);
Min = Convert (BCDMin);
Hou = Convert (BCDHou);
Day = Convert (BCDDay);
Mon = Convert (BCDMon);
Yea = Convert (BCDYea)-2000;
}
int Convert (int input)
{
int iFirst = input &0x000F;
int iSecond = (input/16) &0x000F;
int iThird = (input/256) &0x000F;
int iFourth = (input/4096) &0x000F;
return iFirst + iSecond*10 + iThird*100 + iFourth*1000;
}

And create the list of these tags.

BDCSec, BCDMin,.. come from the HMI clock.

Sec, Min,.. are for the ACE PLC.

   

Add the macro in «global Macro» list

And set its frequency of execution to 1000 ms for update the clock every seconds.

 

You can download here the HMI-Tool project if you wish to test it.