get actual time

Anonymous
2011-05-23
2011-12-29
  • Anonymous - 2011-05-23

    Originally created by: Arjan

    Hello,

    I am an obvious newbie to CoDeSys so this is probably a dumb beginners question, but I´ve Googled around and could not find any satisfiable answer.

    How can a get the current time from my controller (a Wago 750-841)

    I want to start with a simple time clock which sets an output on or off according to the time of the day. Found the OSCAT library which contains a function for this purpose (TIMECHECK) this function needs an input in TOD type. The OSCAT libraries also contain functions to convert from different types to TOD, but my problem is I don´t know how to get the time in any format from the system.

    I´ve tried the CurTime and CurTimeEx functions but the seem to need inputs. I don´t want to set the time just read it.
    Can anyone give a hint on how to accomplish this probably simple task.

    thanks in advance,
    Arjan

     
  • shooter - 2011-05-24

    inside 750-841 is no RTC present so you can not ask for it.
    you can give a time when startup and then the time will be running (not very good on time though but you can make calcs with it.

     
  • Nitrozin - 2011-05-30

    Hi,

    the 750-841 has a battery buffered RTC.
    You can get the actual time with the 'SysRtcGetTime' function from the SysLibRtc.lib.

    VAR
    MyDateTime: DT;
    END_VAR

    MyDateTime := SysRtcGetTime(TRUE);

    Nitro

     
  • Anonymous - 2011-05-30

    Originally created by: Arjan

    Hello Nitro,

    Thanks that was what I was looking for.
    Maybe the clock of the 750-841 is not to accurate, but that is no problem for my application.

    Do you know of any documentation (pdf´s or websites) where these standard functions are explained some more and maybe easy to browse by categories etc.?

    Greetz,
    Arjan

     
  • Nitrozin - 2011-05-31

    Hi,
    you can find a lot of informations on the WAGO Website
    Service >> Downloads >> Automation
    also you can visit http://www.oscat.de/, a free library (open Source)

    Nitro

     
  • asifdip - 2011-11-03

    Hello everyone,
    I am using Codesys 2.3 with target SP RTE. I have already found "SysLibTime" and "SysLibRtc".
    I have also need to use Real system time in my ST editor. I have run the above small program as described above but I have this old time.
    VAR
    MyDateTime:DT;
    END_VAR

    MyDateTime := SysRtcGetTime(TRUE);

    Then result: DT#1970-01-01-00:00 It is not currect date & time system time.

    If I add and use "SysLibTime" library in my project then I have just write in Visualisation %t%a %b %d.%m.%y %H:%M:%S then i have the real system time in Visualisation.It is very nice.But I can only see not use it ST editor.how can i use this? or any idea?
    As I want to get the system time and then i want to use it again. how can i get this time in "Main "or " PLC_PRG" Program editor in ST language?

    I am waititng for ur reply.

    Thanks
    asif

     
  • CME - 2011-11-09

    I have the same problem. The example "MyDateTime := SysRtcGetTime(TRUE);" gives " DT#1970-01-01-00:00 ".
    I'm using a 750-841 controller and the time in the wago is correct.

    Anyone already a solution.

    Thanks,

    CME

     
  • gbutori - 2011-12-29

    Hello,

    I've used CurTimeEx (not to set time and date, but only to read it) and it works well.

    In the declarations:

    VAR
    ActualTime:SysTime64;
    ActualTimeEx:SystemTimeDate;
    RdCurTimeEx: CurTimeEx;
    END_VAR

    In the program part:
    RdCurTimeEx(SystemTime:=ActualTime , TimeDate:= ActualTimeEx);

    ActualTimeEx has now the time and date values.

    I use Lenze HMI(WCE) and IPC(WCE) and this works on both.

     

Log in to post a comment.