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
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?
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?