CODESYS - the IEC 61131-3 automation software

Welcome to the official CODESYS Forum by 3S-Smart Software Solutions GmbH | A member of the CODESYS Group
Deutsche Version English version russian version 
It is currently Thu Sep 19, 2019 8:52 pm

All times are UTC+01:00




Post new topic  Reply to topic  [ 3 posts ] 
Author Message
 Post subject: How to get system time
PostPosted: Thu Jan 29, 2015 11:50 pm 
Offline

Joined: Tue Jan 27, 2015 1:05 pm
Posts: 7
Hi all
Does anyone know how to read the system time from rasbian to use in CoDeSys?
The Raspberry is set up for ntp, and i would like to use that for a project where i need actual time and date without the need to readjust the clock after a power off.
Probably there is already a function somewhere and i just have not found it
Helpful could also be the possibility to run a pyton/php (or any other language) script on rasbian by codesys code and read in the result...

Thanks for help, i work for years with codesys, but our controllers have RTC and we don't do the integration by our self :)


Top
   
PostPosted: Fri Jan 30, 2015 6:20 am 
Offline
Site Admin

Joined: Mon Sep 05, 2005 9:42 am
Posts: 3450
Hi,

use attached example,

Code:
(* get time in seconds since 1970 *)
udiUtcTime := SysTimeRtcGet(udiResult);
IF udiResult <> 0 THEN
   RETURN;
END_IF

(*converts the utc time (seconds) to a SYSTIMEDATE with year, month , day, and time etc. *)
udiResult := SysTimeRtcConvertUtcToDate(udiUtcTime, strTimeDate);
IF udiResult <> 0 THEN
   RETURN;
END_IF

(*converts the utc time to the local time, regarding timezone and summer time in seconds *)
udiResult := SysTimeRtcConvertUtcToLocal(udiUtcTime, udiUtcTimeLocal);
IF udiResult <> 0 THEN
   RETURN;
END_IF


The projectarchive is using the calendar from the oscat libraries too!

BR
Edwin


You do not have the required permissions to view the files attached to this post.


Top
   
PostPosted: Fri Jan 30, 2015 9:43 am 
Offline

Joined: Tue Jan 27, 2015 1:05 pm
Posts: 7
Hi Edwin
Big thanks for the fast help and the working solution, perfect!

Cheers
impius


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic  [ 3 posts ] 

All times are UTC+01:00


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Limited