Real Time Clock RTC

The real time clock requires a battery to be fitted to the rear of the module or a 3VDC supply applied via a connector fitted to the rear of the PCB. The default format is 14 Sep 2010 09:50:06 which can be modified to suit the application which is achieved by loading the RTC into a variable having the required format. Another method is to use predefined variables of individual RTC values.
 
 

SET RTC
The RTC is set using 24 hour time with LOAD( RTC, "YYYY:MM:DD:hh:mm:ss" );
  with fixed format where:
  - YYYY is year 1900-2099
  - MM   is month 01-12
  - DD   is day of month 01-31
  - hh   is hours 00-23
  - mm   is minutes 00-59
  - ss   is seconds 00-59

Use vars to setup the time in a user page
VAR(years,2010,U16);
VAR(months,11,U8);
VAR(days,2,U8);
VAR(hours,10,U8);
VAR(mins,30,U8);

User changes the vars via buttons then a SAVE button would load the RTC
LOAD(RTC,years,":",months,":",days,":",hours,":",mins,":00");

READ RTC
You can LOAD the RTC into a variable where the format is specified in a style as follows:
STYLE( myRtcStyle, Data )
  {
  type = text;            // Setup a text variable
  length = 64;            // with max length of 64 chars
  format = "jS F Y g:ia"; // RTC format string
  }

 
VAR( RtcVar, "", myRtcStyle );  // Create a var to store formatted string
LOAD( RtcVar, RTC );        // Grab the formatted RTC time and date
TEXT( Txt1, RtcVar );;      // Show the formatted time on display in Txt1 and refresh screen
LOAD( RS2, RtcVar );      // Send formatted time on RS232 port

The RTC date/time can be displayed as a formatted string using special characters
 > Day:
    d      Day of month with leading zeros                                    01-31
     j      Day of month without leading zeros                                1-31
    S      Ordinal suffix for day of month                                      st, nd, rd, th

 > Month:
    F      Full textual representation of month                                January-December
    m      Numeric representation of month with leading zeros         01-12
    M      Short textual representation of month, three letters          Jan-Dec
    n      Numeric representation of month without leading zeros      1-12

 > Year:
    Y      Full numeric representation of year, 4 digits                    1900-2099
    y      Two digit representation of year                                     00-99

 > Time:
    a      Lowercase Ante meridiem and Post meridiem                 am, pm
    A      Uppercase Ante meridiem and Post meridiem                AM, PM
    g      12-hour format of hour without leading zeros                  1-12
    G      24-hour format of hour without leading zeros                 0-23
    h      12-hour format of hour with leading zeros                      01-12
    H      24-hour format of hour with leading zeros                      00-23
    i       Minutes with leading zeros                                             00-59
    s      Seconds with leading zeros                                           00-59
 > other characters not in list will be shown as is

Format examples:
 "d M Y H:i:s" will display as: 14 Sep 2010 09:50:06 (default format)
 "d/m/y" will display as: 14/09/10
 "jS F Y g:ia" will display as: 14th September 2010 9:50am

Predefined variables below can be read, but not set.

 RTCSECS numeric variable containing seconds (0-59) which can be tested or loaded into a text.
 RTCMINS numeric variable containing minutes (0-59) which can be tested or loaded into a text.
 RTCHOURS numeric variable containing hours (0-23) which can be tested or loaded into a text.
 RTCDAYS numeric variable containing days (1-31) which can be tested or loaded into a text.
 RTCMONTHS numeric variable containing month (1-12) which can be tested or loaded into a text.
 RTCYEARS numeric variable containing year (1900-2099) which can be tested or loaded into a text.

RTC Day Of Week


Added day of week support to RTC.
Built in variable
RTCWEEKDAY reports day of week where 1=Monday, 2=Tuesday,... 7=Sunday.
Formatting parameters added for RTC
 D   Short textual representation of day, three letters: Mon-Sun
 L   Full textual representation of the day of the week: Monday-Sunday
 N   ISO-8601 numeric representation of the day of the week: 1 (for Monday) - 7 (for Sunday)
Note RTC day of week is indeterminate if RTC has not been set.
The RTC Alarm does not support day of week.
For an alarm that triggers every Thursday at 16:00, the following example can be used:

INT( RTA, fnc_Alarm );
LOAD( RTA, ":::16:00:00" );
FUNC( fnc_Alarm )
  {
   IF( RTCWEEKDAY != 4 ? [ EXIT( fnc_Alarm ); ] );
      // Do Thursday alarm code here...
  }


Real Time Clock Alarm
(RTA)


Support for an RTC Alarm is provided using RTA. This can be set for duration,  time or time and date.
You can set an alarm every 20 seconds, at 17.45 every day or on the 15th March at 12.52 each year.
   To setup the interrupt which is triggered at the alarm point:
          
       INT(name,RTA,function);
  
 
  
To load the alarm time, use same format as setting RTC.
   Only populated values are used to set the alarm, therefore alarms can be set to go off every
   minute, hour, hour:minute:second, day or month etc..
   Note, the alarm does not support the years parameter, and is ignored when setting the alarm.

 
  Setting the alarm:
      
LOAD(RTA,":5:26:14:7:03"); // Alarm will occur every year on 26th May at 14:07:03
       LOAD(RTA,":::13:15:");   // Alarm will occur every day at 13:15:00
       LOAD(RTA,":::",hours,":",mins,":",secs); // Alarm will occur every day at hours:mins:secs
       LOAD(RTA,":::::20"); // Alarm will occur every 20 seconds past the minute.

    To clear alarm:
 LOAD(RTA,0); // Clear Alarm
 LOAD(RTA,":::::"); // Clear Alarm

    Read RTA
STYLE( myRtaStyle, Data )
  {
  type = text;            // Setup a text variable
  length = 64;            // with max length of 64 chars
  format = "jS F Y g:ia"; // RTC format string
  }

VAR( RtaVar, "", myRtaStyle );  // Create a var to store formatted string
LOAD( RtaVar, RTA );        // Grab the formatted RTC time and date
TEXT( Txt1, RtaVar );;      // Show the formatted time on display in Txt1 and refresh screen
LOAD( RS2, RtaVar );      // Send formatted time on RS232 port

    Settings can be read by accessing the built in variables
RTAMONTHS, RTADAYS, RTAHOURS, RTAMINS, RTASECS
If a value has not been set then -1 is returned.

operational