<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent posts to How to get the system time in milliseconds?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/" rel="alternate"/><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/feed.atom" rel="self"/><id>https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/</id><updated>2024-02-28T06:32:04.545000Z</updated><subtitle>Recent posts to How to get the system time in milliseconds?</subtitle><entry><title>How to get the system time in milliseconds?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/?limit=25#5706" rel="alternate"/><published>2024-02-28T06:32:04.545000Z</published><updated>2024-02-28T06:32:04.545000Z</updated><author><name>nilo</name><uri>https://forge.codesys.com/u/nilo/</uri></author><id>https://forge.codesys.com3a67392e6beb05a5c14ac39fe4ed4000f3f492a9</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, thanks for sharing your final results. may I ask why are you diving by 10?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to get the system time in milliseconds?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/?limit=25#acb8" rel="alternate"/><published>2024-02-28T06:32:02.333000Z</published><updated>2024-02-28T06:32:02.333000Z</updated><author><name>nilo</name><uri>https://forge.codesys.com/u/nilo/</uri></author><id>https://forge.codesys.com8c47e2bad7bcb4451accbcbcfaedcae3c3900622</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hi, thanks for sharing your final results. may I ask why are you diving by 10?&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to get the system time in milliseconds?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/?limit=25#f900" rel="alternate"/><published>2020-02-27T16:10:17.820000Z</published><updated>2020-02-27T16:10:17.820000Z</updated><author><name>elsabz</name><uri>https://forge.codesys.com/u/elsabz/</uri></author><id>https://forge.codesys.com05cfca1a492cf87cf36a12039f4f1361fc1d9e60</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I solved the problem!&lt;br/&gt;
The value was not stable because it was testing the application from a webvisualization, and this was set by default to a 100 ms cycle time.&lt;br/&gt;
Therefore, when I went to see the value it did not seem a plausible time. I apologize for the inconvenience, I hope it can serve to someone.&lt;/p&gt;
&lt;p&gt;The final code is as follows:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;TIME1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;TIME&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;milliseconds&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;DINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;TIME1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;TIME&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;milliseconds&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;TIME_TO_DINT&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;TIME1&lt;/span&gt;&lt;span class="o"&gt;)/&lt;/span&gt;&lt;span class="nt"&gt;10&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;

&lt;/div&gt;</summary></entry><entry><title>How to get the system time in milliseconds?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/?limit=25#55c8" rel="alternate"/><published>2020-02-27T16:10:15.543000Z</published><updated>2020-02-27T16:10:15.543000Z</updated><author><name>elsabz</name><uri>https://forge.codesys.com/u/elsabz/</uri></author><id>https://forge.codesys.com0de48c4f758f8bc94050bc19eda638f57c9e309e</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hy Scott,&lt;/p&gt;
&lt;p&gt;Tank you for the answer, but i need thys for RaspBerry pi 3 and not for PC.&lt;br/&gt;
I try with thys:&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;LTIME1&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;LTIME&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;TimeOFDay&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;TOD&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;milliseconds&lt;/span&gt;&lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;DINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;LTIME1&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;LTIME&lt;/span&gt;&lt;span class="o"&gt;();&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;TimeOFDay&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;LTIME_TO_TOD&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;LTIME1&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;milliseconds&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;TOD_TO_DINT&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;TimeOFDay&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;With thys not work... the value is not stable e not good increment,&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to get the system time in milliseconds?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/?limit=25#563e" rel="alternate"/><published>2020-02-27T16:10:14.718000Z</published><updated>2020-02-27T16:10:14.718000Z</updated><author><name>Anonymous</name><uri>https://forge.codesys.com/u/*anonymous/</uri></author><id>https://forge.codesys.com5eea03af75dd9ab33b45f6e6280dac19e211a0c5</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;&lt;em&gt;Originally created by:&lt;/em&gt; scott_cunningham&lt;/p&gt;
&lt;p&gt;For a PC, you need the SysTimeRtc library (part of the system library).  Look for the function SysTimeRtcHighResGet.  You can use the pTimestamp to get your time.  See the library documentation.  The most confusing part for me was the library implies pTimestamp is a pointer, but for my CoDeSys install, it is a ULINT.  When you use other hardware besides a PC (i.e. PLC or embedded controller), the hardware vendor will have different libraries to access a realtime clock (if it exists on the hardware).&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;VAR&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;Rtc&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;ULINT&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="err"&gt; &lt;/span&gt; &lt;span class="err"&gt; &lt;/span&gt;&lt;span class="nt"&gt;Clock&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="nt"&gt;TOD&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;
&lt;span class="nt"&gt;END_VAR&lt;/span&gt;
&lt;span class="nt"&gt;SysTimeRtcHighResGet&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;pTimestamp&lt;/span&gt;&lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;Rtc&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;span class="nt"&gt;Clock&lt;/span&gt; &lt;span class="o"&gt;:=&lt;/span&gt; &lt;span class="nt"&gt;ULINT_TO_TOD&lt;/span&gt;&lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;Rtc&lt;/span&gt;&lt;span class="o"&gt;);&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;For your needs, just use the ULINT - it is already in milliseconds.&lt;/p&gt;&lt;/div&gt;</summary></entry><entry><title>How to get the system time in milliseconds?</title><link href="https://forge.codesys.com/forge/talk/Runtime/thread/58207d7d70/?limit=25#0332" rel="alternate"/><published>2020-02-27T16:10:12.453000Z</published><updated>2020-02-27T16:10:12.453000Z</updated><author><name>elsabz</name><uri>https://forge.codesys.com/u/elsabz/</uri></author><id>https://forge.codesys.comd8d866ada29915bb2787a38d83c2abbbe61f026f</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;Hello everyone,&lt;br/&gt;
I can not understand how I can get the system time in milliseconds, someone can give an example to do this?&lt;/p&gt;
&lt;p&gt;Thank you&lt;/p&gt;
&lt;p&gt;Serghei&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>