Is there a time counter block?

I want to measure how long a condition is last. The condition could possibly last more than a day. However, I cannot find a time counter block.

I could measure the duration with a timer (TON) with a large predefined time and record the “ET” output but I think it is not a best way. When I think of using the “RTC_S” block, I found that its output is in the string format. I cannot use the “SUB_LDT_LDT” to measure the duration since its inputs require the LDATE_AND_TIME format. What is the best way to measure the duration of condition? Thanks

Hello, There is a GetMicrotick function in the PLCnext Base Library … perhaps this will help do what you want? ~ Martin.

Hi, Martin, The GetMicrotick function only counts the time up to 4294s.

I have to use the DateTimeGet function block to count the time. It has a LDT data format output that can be used for calculation.
I attached the time counter logic in the attached file. The variable “Duration2” displays the counting time.
Why the RTC_S function block only output the string format but not the LDT format for the data and time?

Thanks

Hmm, I see. I will send this to the PLCnext Engineer support team and hopefully they will have a good answer.

Just to wrap this up, in answer to the final question:

Why the RTC_S function block only output the string format but not the LDT format for the data and time?

… the answer is that, at some stage in the past, there was a requirement for the value of the real-time clock to be returned as a String, so the RTC_S block was created. There was no requirement at the time for any other return value, and this has not been added since. I hope this answers the question. ~ Martin.

Hi Martin, The ‘TO_STRING’ under the ‘Data Type Conversion’ group can convert the LDT to a string while there is no function converting a string to LDT type. That would not make any sense to have RTC_S function output string instead of the LDT type. Is there any change regarding to it in the future?

Jason

No, the RTC_S function (“Real-Time Clock as a String”) will not change its output type from String in the future. ~ Martin.

Hi Martin, where can I find the DateTimeGet function block? kind regards, David de Roo

Hi David, The DateTimeGet FB is part of the PLCnextBase library. ~ Martin.