System time

cica-draza
2005-12-15
2006-01-13
  • cica-draza - 2005-12-15

    Please help.

    I don't know how to read System date and time. I supose that SysLibTime.lib is answer but I don't know how to use this library.

    I would like to set value in variable X of system date and time in ST.

    Thanx.

     
  • Anonymous - 2005-12-16

    Originally created by: Gast

    try

    ActDateAndTime := SysRtcGetTime(dummy);

    with ActDateAndTime as DT

    and dummy as BOOL.

    SysRtcGetTime ist a function from SysLibRtc.lib

     
  • cica-draza - 2005-12-18

    Thanx for reply but I don't have library SysLibRtc.lib.

    I search whole 3s folder but cannot find it. Can you post it here or mail it to me? Please?

    Maybe some other way?

    Please help my deadline is comming...

     
  • Igor Petrov - 2005-12-19

    cica_draza hat geschrieben:
    ... I don't have library SysLibRtc.lib.

    Indeed, System Libs are external libraries with realizations inside runtime system.

    If yours PLC has RTC and manufacturer (OEM) support appropriate library then CoDeSys Library Manger will discover SysLibRtc.lib without any trick.

    OEM may develop specialized library for system time access.

    The questions are:

    Does yours PLC have RTC hardware?

    How OEM supports the RTC?

     
  • cica-draza - 2005-12-19

    I'm just a student and I don't have PLC.

    I'm doing some project for my exam and I need to make ST program only for virtual PLC.

    I have ST program, visualization and that's it.

     
  • cica-draza - 2005-12-21

    I realize it!

    It is simple.

    Just used RTC block.

    It has 4 variables:

    enable

    InputDateAndTime as DT

    Q as bool

    OutDateAndTime as DT

    As soon as EN becomes TRUE, the time of InputDateAndTime is set, is counted up in seconds and returned in OutDateAndTime as long as EN is TRUE. As soon as EN is reset to FALSE, OutDateAndTime is reset to the initial value DT#1970-01-01-00:00:00.

    InputDateAndTime can be left out and than time and date are readen from the System.

    Finally.

     
  • Igor Petrov - 2005-12-27

    You are right. It is good solution for emulation mode.

    By the way, you may download our free TimeExp.lib http://www.prolog-plc.ru/docs/timeexp.zip includes effective date and time manipulation functions.

     
  • cica-draza - 2006-01-12

    Thanx

    I have downloaded but I have a problem. I don't know Russian (only few words I know are something like ya tebya lyublyu for my girlfriend )

    Big procent of that lib I figured out what is going on inside but not all.

    have you some version in english?

     
  • Igor Petrov - 2006-01-13

    Indeed the project was an appendix for our rather big article in Russian . It would be rather difficult to translate it to English completely .

    The project file comments translation would bring you nothing since the library includes the same functions with English comments.

    Main functions:

    Input: DATE; Output: year, month, day of the month
    Input: TIME; Output: hour, minute, second, ms
    Input: year, month, day of the month; Output: DATE
    Input: hour, minute, second, ms; Output: TIME

    Input: DATE, TIME_OF_DAY; Output: TD
    Input: TOD1, TOD2; Output: TIME
    Input: UINT 2 digits year; Output: UINT 4 digits year
    Input: UINT year; Output: BOOL
    Input: DATE; Output: UINT weekday number
    standard RTC realization example, based on TON

    Outer functions are only auxiliary for main functions.

    Conversions based on fast algorithms without cycles.

    Just tell me if you have problems to understand some functions or algorithms. I will try to describe it in details.

     

Log in to post a comment.