<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to "GetDateAndTime" =&gt; is there something "faster" exististing?</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/b7b2fa8862/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/b7b2fa8862/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/CODESYS-V2/thread/b7b2fa8862/</id><updated>2021-12-26T06:55:38.249000Z</updated><subtitle>Recent posts to "GetDateAndTime" =&gt; is there something "faster" exististing?</subtitle><entry><title>"GetDateAndTime" =&gt; is there something "faster" exististing?</title><link href="https://forge.codesys.com/forge/talk/CODESYS-V2/thread/b7b2fa8862/?limit=25#8bc0" rel="alternate"/><published>2021-12-26T06:55:38.249000Z</published><updated>2021-12-26T06:55:38.249000Z</updated><author><name>czerwinb</name><uri>https://forge.codesys.com/u/czerwinb/</uri></author><id>https://forge.codesys.com9b8eb7e8e8daff32cdb67e529d9167fc019ad9d2</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi all, quite an old topic to resurrect, but I have a very related question.&lt;/p&gt;
&lt;p&gt;I would like to ask for an advice how to measure the &lt;em&gt;speed&lt;/em&gt; or CPU load of the &lt;em&gt;SysRtcGetTime()&lt;/em&gt; function. At my WAGO 750-880 PLC I am running a cyclic task to execute &lt;em&gt;SysRtcGetTime()&lt;/em&gt; to read the clock at a given interval. The intention is to reduce CPU load - my assumption is that I do not need to read the clock at every cycle, as well as if the function was executed in the main program at every cycle it would impose higher CPU load? Is the second statement valid? I thought if I could measure the CPU load I could validate it.&lt;/p&gt;
&lt;p&gt;I would apperciate any best practices on using &lt;em&gt;SysRtcGetTime()&lt;/em&gt; function to read time.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>"GetDateAndTime" =&gt; is there something "faster" exististing?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/b7b2fa8862/?limit=25#e3a8" rel="alternate"/><published>2020-02-27T21:32:39.178000Z</published><updated>2020-02-27T21:32:39.178000Z</updated><author><name>Wicked</name><uri>https://forge.codesys.com/u/wicked/</uri></author><id>https://forge.codesys.comab9ab5651fd05944cd5b98eb1efe9d92eaf40b92</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Thank you!  &lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>"GetDateAndTime" =&gt; is there something "faster" exististing?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/b7b2fa8862/?limit=25#8cd1" rel="alternate"/><published>2020-02-27T21:32:35.078000Z</published><updated>2020-02-27T21:32:35.078000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.comf6fd31f2901913c09b504a5647740cab645e5a73</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; Eckhard&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hello Wicked&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;In my system (WAGO 750-) is also a second functionblock to read the time: CurTimeEx in the lib: SysLibTime.lib&lt;br/&gt;
This function is (in my case) about six times faster.&lt;br/&gt;
To get the same data type you have to create a DT# variable.&lt;/p&gt;
&lt;p&gt;Here the program which is translating the structure of CurTimeEx to DT#&lt;br/&gt;
The declaration part:&lt;/p&gt;
&lt;p&gt;&lt;span style="color: #0000FF;"&gt;PROGRAM &lt;/span&gt;ReadClock_CurTimeEx&lt;br/&gt;
&lt;span style="color: #0000FF;"&gt;VAR&lt;/span&gt;&lt;br/&gt;
    Realtime_extended:(&lt;em&gt; The realtime as a complex variable &lt;/em&gt;)&lt;br/&gt;
    Realtime_64:SysTime64;&lt;br/&gt;
    TimeDate:(&lt;em&gt; Structure with year, month, etc. &lt;/em&gt;)&lt;br/&gt;
    Helptime: (&lt;em&gt; Helper with is collecting the time&lt;/em&gt;)&lt;br/&gt;
    dtActualTime: DT;&lt;br/&gt;
&lt;span style="color: #0000FF;"&gt;END_VAR&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;The code part (in structured text):&lt;/p&gt;
&lt;p&gt;Realtime_extended   (SystemTime:= Realtime_64 , TimeDate:= TimeDate );&lt;br/&gt;
Helptime := CONCAT ( 'DT#',&lt;span style="color: #0000FF;"&gt;UINT_TO_STRING&lt;/span&gt; (TimeDate.Year));(&lt;em&gt; DT#2009               &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,'-');(&lt;em&gt; DT#2009-             &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,&lt;span style="color: #0000FF;"&gt;UINT_TO_STRING&lt;/span&gt; (TimeDate.Month));(&lt;em&gt; DT#2009-10           &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,'-');(&lt;em&gt; DT#2009-10-          &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,&lt;span style="color: #0000FF;"&gt;UINT_TO_STRING&lt;/span&gt; (TimeDate.Day));(&lt;em&gt; DT#2009-10-30      &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,'-');(&lt;em&gt; DT#2009-10-30-       &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,&lt;span style="color: #0000FF;"&gt;UINT_TO_STRING&lt;/span&gt; (TimeDate.Hour)); (&lt;em&gt; DT#2009-10-30-23     &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,':');                        (&lt;em&gt; DT#2009-10-30-23:    &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,&lt;span style="color: #0000FF;"&gt;UINT_TO_STRING&lt;/span&gt; (TimeDate.Minute));   (&lt;em&gt; DT#2009-10-30-23:56  &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,':');                        (&lt;em&gt; DT#2009-10-30-23:56: &lt;/em&gt;)&lt;br/&gt;
Helptime := CONCAT ( Helptime ,&lt;span style="color: #0000FF;"&gt;UINT_TO_STRING&lt;/span&gt; (TimeDate.Second));   (&lt;em&gt; DT#2009-10-30-23:56:30   &lt;/em&gt;)&lt;br/&gt;
dtActualTime := &lt;span style="color: #0000FF;"&gt;STRING_TO_DT&lt;/span&gt; (Helptime);&lt;/p&gt;
&lt;p&gt;Hope this helps,  Eckhard&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>"GetDateAndTime" =&gt; is there something "faster" exististing?</title><link href="https://forge.codesys.com/forge/talk/Codesys%2520V2.3/thread/b7b2fa8862/?limit=25#3058" rel="alternate"/><published>2020-02-27T21:32:33.570000Z</published><updated>2020-02-27T21:32:33.570000Z</updated><author><name>Wicked</name><uri>https://forge.codesys.com/u/wicked/</uri></author><id>https://forge.codesys.com909ec4c1656b4abc0bce0ca4f8f24e8ab265bccb</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello community&lt;/p&gt;
&lt;p&gt;Do you know whether there is in CDS3 function to get current date and time like it is in CDS2  "SysRtcGetTime" ?&lt;br/&gt;
I was able to find out just library DTU which has "GetDateAndTime" function block. &lt;br/&gt;
Unfortunately that FB needs some time to process and makes things little complicated … .&lt;br/&gt;
Is there something faster existing?&lt;/p&gt;
&lt;p&gt;Any help is appreciated.&lt;/p&gt;
&lt;p&gt;Thank you in advance.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;W.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>