AXE110 date and time

John D Hudson

New Member
I have been using the Wizard to start each new mission for the axe110 datalogger, and wondering if anybody has an easy way to log the date and time each time a reading is logged. When the mission runs over several days it would make it easier to pinpoint when the event happened.
I Thank you for your time and would appreciate any solutions you may have.

 
 

vk5att

New Member
John,

The quick answer is YES. In fact this is how I discovered that the error that I posted earlier today. If you make the changes I listed in the message, the all you need to add is code in the memory routine to store the time variables. Here's the code I used to store hours, mins, secs and the readings from the light and temperature sensors. This was to store 200 readings at 5 minute 1 second interval. I had to add line to clear LCD in the display routine since I didn't bother to pad the time digits to two spaces. I hope this helps.

Robin


' ***************************
' ***** Initialisation *****
' ***************************

init:
serout 6,N2400,(254,1) 'clear LCD
pause 30

high 5 ' write protect eeprom
'reload the last address from data memory
read 0,b6
read 1,b7

'Read time now
read_rtc_now:
i2cslave %11010000, i2cslow, i2cbyte
readi2c 0,(secs,mins,hours)

'Convert to decimal
gosub bcd_decimal


' *********************************
' ***** Main loop - read data *****
' *********************************

'Now read each sensor
main:
high 3 ' flash LED

readadc 0,data0
readtemp 7,data7

low 3 ' end of flash LED

' *********************************
' ***** Display values on LCD *****
' *********************************

serout 6,N2400,(254,1) 'clear LCD
pause 30

serout 6,N2400,(254,128,"L=",#data0," ")
serout 6,N2400,(254,136,"T=",#data7," ")
serout 6,N2400,(254,192,"Time=",#hours,":",#mins,":",#secs)

'serout 6,N2400,(254,192,"sec=",#mins," ")
'serout 6,N2400,(254,200,"min=",#mins," ")


' *****************************
' ***** Now Save the Data *****
' *****************************

'Now save the data
save_data:
low 5 ' write enable eeprom

'Single 24LC256. Input0 from address 0, input1 from address 2730, input3 from address 5460
'Single 24LC256. Input4 from address 8190, input5 from address 10920, input6 from address 13650

if address > 2730 then memory_full
i2cslave %10100000, i2cslow, i2cword
writei2c address,(hours)
pause 10
readi2c address,(temp_byte)
if temp_byte <> hours then ee_error

temp_word = address + 2730 writei2c temp_word,(mins)
pause 10
readi2c temp_word,(temp_byte)
if temp_byte <> mins then ee_error

temp_word = address + 5460 writei2c temp_word,(secs)
pause 10
readi2c temp_word,(temp_byte)
if temp_byte <> secs then ee_error

temp_word = address + 8190 writei2c temp_word,(data0)
pause 10
readi2c temp_word,(temp_byte)
if temp_byte <> data0 then ee_error

temp_word = address + 10920 writei2c temp_word,(data7)
pause 10
readi2c temp_word,(temp_byte)
if temp_byte <> data7 then ee_error

'temp_word = address + 13650 dummy for another sensor
'writei2c temp_word,(data7)
'pause 10
'readi2c temp_word,(temp_byte)
'if temp_byte <> data7 then ee_error


'increment address and save in data memory
inc_address:
high 5 ' write protect eeprom

let address = address + 1
write 0,b6
write 1,b7
if address > 200 then memory_full


' ***********************
' ***** Time Delays *****
' ***********************

'Now do time delay
'Add offsets to hours minutes and seconds for sample interval


let data0 = secs
let data1 = mins
let data2 = hours

Add_Secs: 'Crashes at 1 second interval
let data0 = data0 + 3
if data0 < 60 then Add_Mins
'Secs is now greater than 60 so add 1 to minute instead
let data0 = data0 - 60
let data1 = data1 + 1

Add_Mins:
let data1 = data1 + 5
if data1 < 60 then Add_Hours
'Mins is now greater than 60 so add 1 to hour instead
let data1 = data1 - 60
let data2 = data2 + 1

Add_Hours:
let data2 = data2 + 0
if data2 < 24 then read_rtc
'Hours is now greater than 24 so correct
let data2 = data2 - 24

'Read rtc to test alarm'
read_rtc:
i2cslave %11010000, i2cslow, i2cbyte
readi2c 0,(secs,mins,hours)

gosub bcd_decimal

if secs <> data0 then read_rtc
if mins <> data1 then read_rtc
if hours <> data2 then read_rtc

'now do next reading
'Store the time for the next reading to time variables
let secs = data0
let mins = data1
let hours = data2
goto main


' *************************
' ***** Error Routine *****
' *************************

'Memory error - flash LED red/green'
ee_error:
high 2
low 3
pause 500
low 2
high 3
pause 500
goto ee_error

' ***********************
' ***** Memory Full *****
' ***********************

'Memory is full - LED red'
memory_full:
high 2

' ****************************
' ***** Datalink Routine *****
' ****************************

'Datalink routine to transmit data
read_init:
high 5 ' write protect eeprom
let address = 0

'Get top address from data memory (w2=b4+b5)

read 0,b4
read 1,b5

'Wait for G character sent from software
serin 6, N4800, ("G") 'Wait for GO signal

'Transmit the titles
serout 7,N4800,("Address",COM,"Hours",COM,"Minutes",COM,"Seconds",COM,"Light",COM,"Temperature",COM," ",RET,LFEED)

'Now read the data
read_data:
'Single 24LC256. Input0 from address 0, input1 from address 2730, input3 from address 5460
'Single 24LC256. Input4 from address 8190, input5 from address 10920, input6 from address 13650
if address > 2730 then all_done
i2cslave %10100000, i2cslow, i2cword
readi2c address,(hours)

temp_word = address + 2730
readi2c temp_word,(mins)

temp_word = address + 5460
readi2c temp_word,(secs)

temp_word = address + 8190
readi2c temp_word,(data0)

temp_word = address + 10920
readi2c temp_word,(data7)

'temp_word = address + 13650 dummy foranother sensor
'readi2c temp_word,(data7)

'transmit data
tx_data:
serout 7,N4800,(#address,COM,#hours,COM,#mins,COM,#secs,COM,#data0,COM,#data7,RET,LFEED)

let address = address + 1
if address = top_address then all_done
goto read_data

'finished so send NULL
all_done:
serout 7,N4800,(0)
goto read_init


' **********************************
' ***** Convert BCD to decimal *****
' **********************************

'Convert BCD to decimal
bcd_decimal:
let temp_byte = secs & %11110000 / 16 * 10
let secs = secs & %00001111 + temp_byte
let temp_byte = mins & %11110000 / 16 * 10
let mins = mins & %00001111 + temp_byte
let temp_byte = hours & %11110000 / 16 * 10
let hours = hours & %00001111 + temp_byte
return

 

John D Hudson

New Member
Robin,
Thanks for the suggestion,
Adding the time is a real improvement but can the date also be added
for those longer missions.

Regards John

 
 

JackoS

New Member
John,

See the axe110-i2c tutorial (section 4)
To get the date use:
readi2c 4,(day,month,year)

If your readings don't change rapidly, you can compare the new reading with the previous reading and only save the readings when they differ from the previous reading. In case of ambient temperatur reading this can save a lot of readings, but at the expense of having to save the date/time

Jack
 
Top