How to calculate machine working time on HMI

How to calculate machine working time on HMI
none 5.0 1
  • HMI Model: cMT-FHDX-820
  • EasyBuilder Pro Version: V6.10.01.510

Dear Sir,

I have some machines which are controlled and monitored by HMI

From HMI, I can get run/stop/fault of machine. Base on these signals, I want to calculate for working time, stopping time of machine.

Could you please show me solution to calculate as request?

Is is possible to do by object function or by macro ?

Can working time & stopping time indicate on HMI screen?

Can they sort by date, by week, by month?

Hope to receive your feedback soon.

Thank you so much for your support!

@cuongho ,

Something like this is definitely achievable, for visualization purposes, I’d recommended using the Event Bar Chart object. This can be used to display elapsed time based on event triggers within your project.

To keep time my suggestion would be to use a macro like the example below:

macro_command main()
bool status = false
int ss = 0, mm = 0, hh = 0, tot = 0

// TO-DO - At new day implement change to reset total
// Total time running in seconds
GetData(tot, "Local HMI", "run_tot", 1)

// Get run status
GetData(status, "Local HMI", "Run", 1)

// Check if running
if status then
	tot = tot + 1
SetData(tot, "Local HMI", "run_tot", 1)
end if

// Get remainder in seconds
ss = tot mod 60

// Get remainder in minutes
mm = ((tot - ss) / 60) mod 60

// Get hours
hh = ((tot - ss) / 60) / 60 

SetData(hh, "Local HMI", "run_hh", 1)
SetData(mm, "Local HMI", "run_mm", 1)
SetData(ss, "Local HMI", "run_ss", 1)

end macro_command

I’ve also attatched a small demo project here: Tracker Demo

You can reference this data a few different ways, like using the Recipe data base for example.

Hope this helps you get going in the right direction. Let us know if you have any more questions!

1 Like

Dear Daniel,

Thank you so much!

Your support is clear. I will try to apply it in my machine.

However, one important thing, I forgot to tell you.

How to save and remember data of this working time on HMI?

I mean when I switch of power of HMI then switch on power, I need HMI remember previous number and continuous count.

Thank again.

@cuongho ,

You can accomplish this by saving the data into RW (Retentive) memory. In the macro you can change the SetData registers to RW so it saves within the HMI’s flash memory. Here is a more comprehensive tutorial of that process on our YouTube channel : link

The best way to call that data in the future would be using the recipe database.

1 Like

Hi, I have similar project. What the maximum number of “hours” - 24 or possible to DDDDDD?

Thanks

Hi @Andy27 ,

The maximum number of hours is above 24 as within the projects its getting saved to a 32 bit unsigned memory address within the recipe database. Therefore the maximum value for hours is 4,294,967,295 (2^32 - 1).