Qaseem
Hi,

What is the best way to log the current time obtained from ML1024 in a textfile? I want to record it as Epoch time. If you recommend saving it in a holding register and use a custom layer to write to the file, which holding register should I use?

Thanks,
Quote 0 0
thiagoralves
You can just read it directly from ML1024, which is at *special_functions[0], and store it in a file using a custom layer at HWLCB.
Quote 0 0
Qaseem
Thanks, I edited the custom layer at HWLCB as follows:
void updateCustomOut()
{
 
time_t   timeNow=*special_functions[0] ;
  
  if (bool_output[100] != NULL)      //logging time when %QX100 is updated
     Myfile << timeNow << endl;

}

But when I run the OpenPLC, it didn't work and it refused to connect to the slaves. I removed the condition and use *special_functions[0] without using the temporary var but it didn't fix the error. Please help me fix this error?

Thanks,


Quote 0 0
thiagoralves
Can you send the whole HWLCB code?
Quote 0 0
Qaseem
Please find it attached. 

When I review the function handleSpecialFunctions, I notice that Epoch time is modified and you add 3600.
Would you mind clarifying this point as well?

Many thanks,
Quote 0 0
thiagoralves
I will check your code, but the 3600 is added just for day light saving time. 3600 seconds = 1 hour. If there is DST enabled for the current time zone the code adds one hour to the current time.
Quote 0 0
Qaseem
Thanks a lot for the clarification. I appreciate your time!
Quote 0 0