19.0 RTC (T7-Pro Only) [T-Series Datasheet] | LabJack
« Close

Datasheets and User Guides

App Notes

Software & Driver


19.0 RTC (T7-Pro Only) [T-Series Datasheet]

Overview - T7-Pro Only

The T7-Pro has a battery-backed RTC (real-time clock) which is useful for assigning timestamps to data that is stored on the microSD card during scripting operations—particularly in situations where the device could experience power failure or other reboots, and does not have a communication connection that can be used to determine real-time after reboot. The system time is stored in seconds since 1970, also known as the Epoch and Unix timestamp.

Note: To use the RTC_TIME_S register please update to a firmware version of 1.0297 or higher on the T7. The start of 2021 exposed a new bug in system time functions on the T7, and this subsequently broke the RTC_TIME_S register functionality on firmware versions 1.0292 and earlier.

Battery Life

Typically, the CR2032 battery can be expected to last 12 years. Several factors can influence the expected life including: 

  • Temperatures - Cold temperatures will decrease the battery's life. 
  • Battery age - Batteries naturally discharge as they age. This also has a temperature dependency, but 20% every 10 years is a good rule of thumb. 
  • External Power - When the T7 is powered up the battery is not used to maintain time. This will extend the battery life.

The RTC requires 925 nA to maintain it's time. A typical CR2032 battery has 210 mAH capacity which works out to a life of 25.9 years. We derate our expectations by ~2 to get the above life expectancy.

Reading Time

Read the system time in seconds with address 61500:

Name Start Address Type Access

RTC_TIME_S             Read the current time in seconds since Jan, 1970, aka Epoch or Unix time. This value is calculated from the 80 MHz crystal, not the RTC 32 kHz crystal. Non-pro devices do not have a real time clock, so the reported time is either seconds since device startup or the time reported by the network time protocol over Ethernet. Pro devices have a real time clock that will be used to initialize this register at startup, the time can then be updated by NTP.

61500 UINT32 R

SYSTEM_COUNTER_10KHZ             A 10 kHz counter synchronized to RTC_TIME_S. This register can be appended to RTC_TIME_S as the decimal portion to get 0.1 ms resolution.

61502 UINT32 R

Get a simple calendar time representation by reading six consecutive addresses, starting with address 61510:

Name Start Address Type Access

RTC_TIME_CALENDAR             Read six consecutive addresses of type UINT16, starting with this address. The result will be in year, month, day, hour, minute, second calendar format. i.e. [2014, 10, 21, 18, 55, 35]

61510 UINT16 R

To time events faster than 1 second apart, it is possible to read the CORE_TIMER (address 61520) and see how it changes from second to second. To access the core timer value in Lua scripts, use the LJ.Tick() function.

Setting Time

Set the system time by writing a new timestamp (in seconds) to address 61504:

Name Start Address Type Access

RTC_SET_TIME_S             Write a new timestamp to the RTC in seconds since Jan, 1970, aka Epoch or Unix timestamp.

61504 UINT32 W

To set the T7-Pro's time from a SNTP server, use RTC_SET_TIME_SNTP and SNTP_UPDATE_INTERVAL:

Name Start Address Type Access

RTC_SET_TIME_SNTP             Write any value to instruct the T7 to update its clock from a SNTP server. Requires that SNTP_UPDATE_INTERVAL is non-zero.

61506 UINT32 W

SNTP_UPDATE_INTERVAL             Sets the SNTP retry time in seconds. A value of zero will disable SNTP(0=default). Values must be 10 or greater.

49702 UINT32 R/W


[Lua] Read the value of the RTC in a Lua script

table = {}
table[1] = 0    --year
table[2] = 0    --month
table[3] = 0    --day
table[4] = 0    --hour
table[5] = 0    --minute
table[6] = 0    --second

table, error = MB.RA(61510, 0, 6)
print(string.format("%04d/%02d/%02d %02d:%02d.%02d", table[1], table[2], table[3], table[4], table[5], table[6]))

>> 2014/10/15 18:55.22

[C/C++] Read the value of the RTC in C/C++

int LJMError;
double newValue;
LJMError = LJM_eReadAddress(handle, 61500, 1, &newValue);
//returned value of 1413398998 would correspond with Wed, 15 Oct 2014 18:49:58 GMT