User Tools

Site Tools



Time( )

variable = Time (address)

variable Variable to store results. (No String or Single)
address Address of time value (0 to 6)

The CT1721C, CB290 has an internal Real Time Clock (RTC) chip. You can use the Time and TimeSet commands to write and read time values to and from the RTC. Time information such as the current time of day, day of the week, and year can be written to the RTC, and read from it in real-time.

For the CB405RT, please use RTCRead and RTCWrite instead.

If a backup battery is used, time is kept current even when the module powers off.

The following is a chart showing the addresses of the RTC and its corresponding values.

* CUBLOC-based devices without an RTC cannot make use of these addresses. Use the System Real Time Clock explained below instead.

Please refer to the chart below for the weekdays' corresponding numerical values:

Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
 A = Time(0)
 Debug Hex2 A,Cr

System Real Time Clock (RTC)

This feature will allow you to use the system timer of a Cubloc as an RTC. You can use Time and TimeSet commands to access the following addresses:

Address Returning Value Range
10 Seconds 0 to 59
11 Minutes 0 to 59
12 Hours 0 to 65535
13 Continuous Seconds0 to 65535

Address 10 will increment its value by 1 every second. When its value becomes 60, address 11 will increment its value by 1. When address 11’s value becomes 60, address 12 will increment its value by 1. When address 12’s value becomes 65535, it will reset back to 0. At power on, all addresses are set to 0. The TimeSet command can be used to set the time at the beginning of user’s program.

The system RTC (addresses 10 to 13)'s values are stored as raw binary values, unlike the CB290's and CB405's on-chip RTC . There is no need to convert the values using BCD2Bin and Bin2BCD.

The system RTC uses the processor’s system timer so there can be a slight time difference ( < 1%) after a 24 hour period.

Const Device = CB405
Dim i As Integer
Timeset 10,58
Timeset 13,254
  i = Time(10)
  Debug Goxy,0,0,dec4 i,Cr
  Debug Goxy,0,1,dec4 Time(13)
  Delay 100

Address 13 will increment its value by 1 every second, just like address 10, except when it reaches 65,535 it will reset to 0.

Go CUBLOC home

cubloc/time/index.txt · Last modified: 2019/05/22 08:48 by COMFILE Technology