# Start by initializing the datalogger with the desired mission parameters.
# For this example, the sample rate is 60 minutes, with no start delay
SET_SAMPLE_RATE( 60 );
SET_EHSS( 0 ); # Disable high-speed sampling
SET_START_DELAY( 0 );
SET_TEMPERATURE_SAMPLING( 0.0625C ); # enable sampling in desired resolution
# Initialize and start the Real-time clock
SET_RTC( CurrentTimeAndDate );
START_MISSION();
# Since resolution is minutes, first sample will only be taken on RTC’s
# minute boundary, so delay to give the device time to take the sample
DELAY_ONE_MINUTE();
# Check to make sure the Mission Sample Count register is a non-zero value
If ( GET_MISSION_SAMPLE_COUNT() == 0 ) Then
# Mission did not begin right away, so a 1 second mission will be
# used to clear the internal counter of the device
STOP_MISSION();
SET_SAMPLE_RATE( 1 );
SET_EHSS( 1 ); # Enable high-speed sampling
START_MISSION();
# Now counter is counting down in 1 second increments instead of
# 1 minute increments. Wait for first sample to be recorded.
While( GET_MISSION_SAMPLE_COUNT() == 0 )
DELAY_ONE_MINUTE();
EndWhile;
# Mission sample has been recorded and the internal countdown register
# contains a value of either 1 or 0. Reset the original parameters.
STOP_MISSION();
SET_SAMPLE_RATE( 60 );
SET_EHSS( 0 ); # Disable high-speed sampling
START_MISSION();
# Mission will now start in less than 2 minutes reliably. The time could be
# 2 minutes because there is up to one minute of delay if the RTC is not
# near the minute boundary and up to one minute of delay from the internal
# counter. Delay 2 minutes and double-check, for sanity’s sake.
DELAY_ONE_MINUTE();
DELAY_ONE_MINUTE();
If ( GET_MISSION_SAMPLE_COUNT == 0 ) THEN
SEVERE_ERROR(); # There is another unrelated failure with this device
EndIf
EndIf;