tDate data type - What is it?

2009-06-15
2009-06-16
  • norm.boessler - 2009-06-15

    I have a Real Time Clock for STW's ESX controllers which uses functions FB_SFB_RTC_SET_DATE and ...GET_DATE.

    The FB's use a data type of tDate which I can't find any info on. It is not compatible with the DATE_AND_TIME data type so I don't really know how to set it.

    EG.

    myTDate : tDate;

    myTDate := ??? ( dt#2009-06-15-10:00:00; doesn't work )

    Any suggestions welcome.

     
  • norm.boessler - 2009-06-16

    Ok so the answer is: (c/o STW support)

    Hardware referred to is the ESX controller.

    tDate is part of the ESX BIOS library (besx23xx.lib -> Data types -> StructBabyBoardAPwm). ItΒ΄s a structure and has the following members:

    TYPE tDate :

    STRUCT

    bDay : BYTE; ( day: 1..31 )

    bMonth : BYTE; ( month: 1..12 )

    bYear : BYTE; ( year: 0..99 (0 -> 2000) )

    bHour : BYTE; ( hour: 0..23 )

    bMinute : BYTE; ( minute: 0..59 )

    bSecond : BYTE; ( second: 0..59 )

    END_STRUCT

    END_TYPE

    Alternatively:

    The data type DATE_AND_TIME, or short DT, is an IEC 61131-3 conforming data type. It contains the time in seconds since 1st January 1970. You have to work with this type if you append the SFB RTC to the ESX in the PLC configuration.

    IΒ΄ve attached the corresponding PLC configuration file. Just copy it to '<codesysinstalldir>\Library\PLCConf\STW\ESX' and restart CoDeSys. It will be available then within the PLC configuration. Right click on the ESX, 'Append Subelement' and select 'Special Feature Board with RTC...':</codesysinstalldir>

    Date and time can be set via channel 'SFB_RTCSetDateAndTime' and get by 'SFB_RTCGetDateAndTime', e.g.

    VAR

    q_Firstcycle : BOOL := TRUE;

    dt_DateAndTime : dt;

    END_VAR

    IF (q_Firstcycle = TRUE) THEN

    q_Firstcycle := FALSE;

    SFB_RTCSetDateAndTime := dt#2009-06-15-07:43:00;

    END_IF

    dt_DateAndTime := SFB_RTCGetDateAndTime;

    You can set Date and Time also directly in the PLC configuration when the target is online (double click on Channel 'SFB_RTCSetDateAndTime' and enter Date and Time).

    sfb_rtc.zip [745 Bytes]

     

Log in to post a comment.