Adding Time and Date stamping to the AXE110 datalogger programs

westaust55

Moderator
Following a request from another forum member (Brendan) relating to the fact that the Programming Editor wizard generated code does not include an option to date/time stamp the data as it is logged, in conjunction with Brendan attached is some example program code to do just that.

What has been done here is to take the default code generated by the PE wizard based upon using the DS1307 (or similar) RTC, 8 x 24LC256 EEPROMs and up to 4 sensors (one being the temperature).

There has been additions to the program in many areas. To help highlight these changes the method has been:

1. The use the semicolon ( ; ) instead of the apostrophe ( ' ) for adding remarks/comments into the code - there are copious additional comments to describe the changes

2. new lines of program code have the commands/keywords in upper case (the wizard generated code is in lower case)

3. A few blocks of the original code are deleted. To highlight this the lines have been left in but commented out.

An example of the .csv file, as saved by the PE Datalink section, which can be read by Excel has also been included so you can quickly see in notepad or excel what the output looks like.

Obviously this is set up for 8 x 24LC256 EEPROMS and with virtually no changes (maybe just 1 line as noted in program) should work with a single 24LC16. For other E24LC256 EEPROM combinations (i.e. 1 to 7) the method of storing the data and time in blocks within the EEPROM will need to be addressed with a few (or lot depending on your point of view) of line changes/additions.

Hopefully others will find this useful to add date/time stamping to their data logging projects as well

EDIT - new copy attached with fix per post 2 below
 

Attachments

Last edited:

ki4mmm

New Member
I think this is my very first post here, but I have been lurking and learning for several months now. I am currently working on my first real project, a (various kinds of) motion detector based security system, with RF communications between sensors and a base station. It will alert me to movement around my 5-acre wooded property and outbuildings. Anyway, this post looks invaluable to me for my planned time-stamping of alerts.

That said, there is one minor typo in the code which is fairly obvious to figure out from the compile error, but I thought I'd mention it. Halfway down the file, there is an extra "E" on a i2cslave command i.e.,

; if address > 16383 then save_data_high
i2cslaveE %10100000, i2cslow, i2cword ; EEPROM 0

Thanks for the great code example!
Greg
 
Last edited:

westaust55

Moderator
@ki4mmm,

glad to read that you can find it useful.

Thanks for the typo report. :eek:
Think that came about when I started to change that keyword for new lines to capitals and realised it was not one of the new lines of code just before I posted.

I have corrected the BASIC program attached to post 1
 

davidwf

Senior Member
Westaus55 : thanks for the listing but if that's keeping it simple.....:eek:

I don't have capacity in the '08M for all that additional code though

Is there an easier way, all I need is the date & time added to a couple of "sertxd" lines when I send data back to the host PC

Thanks
 

Jeremy Leach

Senior Member
Code:
 i2cSLAVE %11010000, i2cSLOW, i2cBYTE       ; set up to read the clock
 READi2c 0,(secs,mins,hours,temp_byte,day,month,year) ; read in BCD format
I don't want to tread on WestAus55's toes here, but these lines of his code get the data from the clock, so if you're very limited in program space all you really need to do is store the received bytes without any processing at all. Then let the PC process these bytes into meaningful values when the data is uploaded. For instance if uploading to Excel, you could write forumulae to do the translation.
 

westaust55

Moderator
Hi Jeremy,

not a problem.

David had started a thread on the same topic here:
http://www.picaxeforum.co.uk/showthread.php?t=14872
I pointed him to this thread where he might be able to extract some lines of code.

David posted here but I posted back into his own thread with some information but nothing further from David.

As you say, you can leave the BCD to Binary calcs until uploaded into the PC and thus save PICAXE code, if you do not use the RTC for interval timing as well.
 

andyshrimpton

New Member
looks like just the thing

Hi Westaust55

Thanks for sharing your code.

It looks just the thing to get me started on time stamping.

I have ordered some parts to build a circuit, DS1307 RES038 and the button battery and holder.

Are you able to post a circuit diagram that would work with your code.

I have not used eeprom before i assume you are using this memory function within the 18X chip. You code is very clear and i can follow how it works ie storing the values then reading them.

I am looking forward to understanding the i2cslave and read i2c commands.

I hope to biuld an interval timer to do a cetain job only between certain times of the day. I feel that you have guided me in the right direction.

I feel like a young boy (i wished 45 now) waiting for my parts to be delivered.

I will let you know how i get on using your code.

Thanks again

Andy
 

westaust55

Moderator
Andy,

as the thread heading states, the code was for the AXE110 datalogger

Using the Datasheets button on the orangebar at the top of the forum pages you can download the AXE110 datasheet which from memory has a schematic diagram.

Obviously you do not have to clone that circuit exactly and can use any X/X1 or X1 part for the i2c comms
 

andyshrimpton

New Member
setting the clock values

I am going mad over what i think is simple but i cant get my head around it.

when setting the clock values they have a "$" in front of the (HEX i think) but they need to be in BCD format.

is there a chart somewhere to show the conversion.

Can somebody gave me from getting my gray hairs

i am trying to follow this code.


what is the "control" code doing

let seconds = $00 ' 00 Note all BCD format
let mins = $59 ' 59 Note all BCD format
let hour = $11 ' 11 Note all BCD format
let day = $01 ' 03 Note all BCD format
let date = $28 ' 01 Note all BCD format
let month = $04 ' 04 Note all BCD format
let year = $10 ' 09 Note all BCD format
let control = %01110000 ' Enable output at 1Hz in 12 hour mode PM set %01110000

' Clock will be set to 11:59:00 PM on (01 sunday) 1/04/10
writei2c 0,(seconds,mins,hour,day,date,month,year,control)
return
 
Last edited:

BeanieBots

Moderator
HEX and BCD are basically the same thing just that BCD is a subset of the full hex.

To show 23 minutes, you must the BCD code $23.
It just happens that $23 (a hex value) falls within the BCD subset.

ALL BCD values can be reperesnted as HEX (but not the other way around).
There is NO conversion required. They are the same thing.
It's bit like saying how can I convert the numbers 0 to 6 into decimal.
They ARE decimal, it's just that they only go up 6 and not 9.

Take the hex value $09 and add 1.
It becomes $0A
In BCD, it would become $10 because "A" is 10 in decimal so it 'clocks over' to the next digit. But $10 is STILL a perfectly valid HEX value.

This can be shown in binary too:
$09 = %00001001
$0A = %00001010
$10 = %00010000

In BCD:-
The first 'nibble' (first four bits) indicates the 'tens'
The second 'nibble' indicates the units.

Hope that all made sense.

To get 24 hour mode, you need to set the correct control code.
That's what the "control" code is for.
It does things like start the clock running and switches on/off the square wave output. Have a good read of the datasheet for a full explanation.

for example "let control = %01110000 ' Enable output at 1Hz in 12 hour mode PM set %01110000
"
The clue is in the comment!
 

andyshrimpton

New Member
Using RTC to wait for 1 second

I have spent most of the day getting no where fast.

I have a DS1307 RTC clock set up and running thanks help from Westaust55

It pulses an LED once per second, i also have an LCD showing me the time and date, clocking nicely

In my current project i am using pause command to wait a second, this is not accurate as i have many "if" statements that makes a countdown timer and depending where it jumps out of the "if" staements effect the time accuratacy.

Instead of using a pause 1000 command, can a use the output on the flashing LED (one per second). So if the LED is HIGH the programme with continue, as all of my "if" statement take less than i would say 0.3 of a second to complete, the code should complete all of the "if" staement and then wait for the LED to go high, meaning a second has passed for it to continue.

Thanks

Andy
 

eclectic

Moderator
I have spent most of the day getting no where fast.

I have a DS1307 RTC clock set up and running thanks help from Westaust55

It pulses an LED once per second, i also have an LCD showing me the time and date, clocking nicely

In my current project i am using pause command to wait a second, this is not accurate as i have many "if" statements that makes a countdown timer and depending where it jumps out of the "if" staements effect the time accuratacy.

Instead of using a pause 1000 command, can a use the output on the flashing LED (one per second). So if the LED is HIGH the programme with continue, as all of my "if" statement take less than i would say 0.3 of a second to complete, the code should complete all of the "if" staement and then wait for the LED to go high, meaning a second has passed for it to continue.

Thanks

Andy
Andy,
I suggest that you duplicate your post in
the Main/Active Forum,
and a reference to this thread,
along with your code.

e
 
time stamp not working

The time stamp code is brilliant, and is exactly what I am looking for.
However, I can't seem to get the code working properly with my 20x2 setup.
I have a single 24L16 which has the WP pin tied to ground.
bi color LED is in pins C.3 and C.2
Temp sensor on C.7
LCD out on b.0
and SerOut on B.2

The file saved from datalink capture is attached.

Modified code is too large to post, but here is the first 1/3 of it.

Code:
'AXE110 PICAXE-18X - New Datalogger Mission Program
'Automatically generated by Wizard and Manually modified by Westaust55

'LED will flash green as readings are taken.

'Data can be retrieved after mission (LED red) by Datalink tool (F9).
'Use Datalink options: Baud rate - 4800, Sensors - 4, Send G - Enabled

' *******************
' ***** Options *****
' *******************

'Title -  
'Date  - 13/03/2010
'Time  - 12:53:07 PM

'Options Selected
'Sensors:
'Sensor 0 - Future 2
'Sensor 1 - Future 3
'Sensor 2 - Future 4
'Sensor 7 - Temperature

'Memory:
'No of readings = 200
'8 x 24LC256

'Outputs:
' Bi-colour LED
' AXE033 LCD

''Logging Period:
' DS1307 RTC
' Hours: 0 Mins: 5 Secs: 0 

' ********************
' ***** Symbols  *****
' ********************

'Symbol definitions
symbol data0       = b0
symbol day         = b0
symbol data1       = b1
symbol month       = b1
symbol data2       = b2
symbol data7       = b3
symbol top_address = w2 '(b4 + b5)
symbol address     = w3 '(b6 + b7)
symbol temp_word   = w4 '(b8 + b9)
symbol temp_byte   = b10
symbol hours = b11
symbol mins  = b12
symbol secs  = b13

SYMBOL year = b2        ; all other date/time parameters are already defined at the top
SYMBOL LCD = b.0          ; LCD on Output 0 becasue we are using the EEPROM Write Protect
SYMBOL Events =  200    ; the number of events/records to log 
;                         600 / 60 ==> 12 hours 
;                         1 count made at start and any PICAXE power recycle an extra 
;                         address location is used to store the complete time and data again
		
symbol COM = 44         ' comma
symbol RET = 13         ' carriage return
symbol LFEED = 10       ' line feed

'Preload sensor names and title into data memory
EEPROM 0,(0,0,0,0) ; clear the address counter and the power-up/cycle counter
EEPROM 16,("Future 1")
EEPROM 32,("Future 2")
EEPROM 48,("Future 3")
EEPROM 64,("Temperature")
EEPROM 80,("Time Stamping Example")


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

init:
	'high 5 ' write protect eeprom
;
; Here we clear the AXE033 LCD and check if the logging is completed
	high LCD
	pause 2000
	SEROUT LCD, T2400,("?f") 'clear LCD
	PAUSE 150
	READ 3, temp_byte	; will be set to $FF if memory is full or required number of events have been logged
	IF temp_byte =$FF THEN memory_full
	
	
	SEROUT LCD, T2400,("The Data Logger ?n") 
	SEROUT LCD, T2400,("  is Activated  ") 
	PAUSE 2000
;	
; ===============================================================================
; Here we read the RTC once to collect all data and save time and date across all EEPROMs
; If the power is cycled we end up back here and it will again log the entire time and date information
; This can act as a flag that the power went off and then back on as opposed to just missing some data

; can move the next one line up near other SYMBOL stements if you want

  
; Fetch the address previously stored in EEPROM - 
; If it is a new campain should be zero else indicates PICAXE power was cycled   
  	READ 0,b6  ; fetch any previously stores EEPROM address value
	READ 1,b7
;
; Here we save the full data and time data with a marker in the first EEPROM for the transfer to PC phase
Logfulltime:     ; we only log the full time and date once per PICAXE power-up/reset at the start

      'LOW 5 ; enable writing to EEPROM

	i2cSLAVE %11010000, i2cSLOW, i2cBYTE		     ; set up to read the clock
	READi2c 0,(secs,mins,hours,temp_byte,day,month,year) ; read in BCD format
	
	temp_word = $FF   ; used as flag when doing BCD to decimal conversion to store full data
	GOSUB bcd_decimal ; convert all the BCD values to decimal
	temp_word = $00
      
      i2cSLAVE %10100000, i2cSLOW, i2cWORD  ; EEPROM 0  save a "-" character in the first EEPROM as a flag
	WRITEi2c address,("-")
	PAUSE 10		; pause needed to give EEPROM time to write data before it can be read back
	READi2c address,(temp_byte)
	IF temp_byte <>   "-" THEN ee_error
	
	i2cSLAVE %10100010, i2cSLOW, i2cWORD  ; EEPROM 1  save a "-" character in the second EEPROM for good measure
	WRITEi2c address,("-")
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  "-" THEN ee_error
	
	i2cSLAVE %10100100, i2cSLOW, i2cWORD  ; EEPROM 2
	WRITEi2c address,(year)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  year THEN ee_error
	
	i2cSLAVE %10100110, i2cSLOW, i2cWORD  ; EEPROM 3
	WRITEi2c address,(month)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  month THEN ee_error
	
	i2cSLAVE %10101000, i2cSLOW, i2cWORD  ; EEPROM 4
	WRITEi2c address,(day)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  day THEN ee_error
	
	i2cSLAVE %10101010, i2cSLOW, i2cWORD  ; EEPROM 5
	WRITEi2c address,(hours)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  hours THEN ee_error
	
	i2cSLAVE %10101100, i2cSLOW, i2cWORD  ; EEPROM 6
	WRITEi2c address,(mins)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  mins THEN ee_error
	
	i2cSLAVE %10101110, i2cSLOW, i2cWORD  ; EEPROM 7
	WRITEi2c address,(secs)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  secs THEN ee_error

	'HIGH 5  ; write protect the EEPROM

	SEROUT LCD, T2400,("?f?n") 'clear LCD and start new line
		PAUSE 1000
	SEROUT LCD, T2400,("Date ")
	IF day <10  THEN
	  SEROUT LCD, T2400,(" ")  ; For single digit values put a blank in front
	ENDIF
	  SEROUT LCD, T2400,(#day,"/")
	IF month <10  THEN
	  SEROUT LCD, T2400,("0")  ; For single digit values put a zero in front
	ENDIF
	  SEROUT LCD, T2400,(#month,"/20")
	IF year <10  THEN
	  SEROUT LCD, T2400,("0")  ; For single digit values put a zero in front
	ENDIF
	  SEROUT LCD, T2400,(#year)
	SEROUT LCD, T2400,(254,192,"?nTime ")
	IF hours <10  THEN
	  SEROUT LCD, T2400,(" ")  ; For single digit values put a blank in front
	ENDIF
	  SEROUT LCD, T2400,(#hours,":")
	IF mins <10  THEN
	  SEROUT LCD, T2400,("0")  ; For single digit values put a zero in front
	ENDIF
	  SEROUT LCD, T2400,(#mins,":")
	IF secs <10  THEN
	  SEROUT LCD, T2400,("0")  ; For single digit values put a zero in front
	ENDIF
	  SEROUT LCD, T2400,(#secs)
	PAUSE 2000


; The first address (0) is NOW used to log the full time and date at the start of campaign
; so we increment the address in preparation for event logging and saving of the data

	LET address = address + 1  
	WRITE 0,b6
	WRITE 1,b7

;       Here we advance the power up/cycle counter while still logging data
	  READ 2, temp_byte
	  temp_byte = temp_byte + 1 ; set the start number - increments by 1 each time power up occurs
	  WRITE 2, temp_byte
;
; The following is back to the standard wizard auto generated program code
		
	
'reload the last address from data memory
	read 0,b6
	read 1,b7


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

'Now read each sensor
main:
	high c.3 ' flash green  LED
	low c.2

;	readadc 0, data0
;	readadc 1, data1
;	readadc 2, data2
	readtemp c.7, data7
	

; These  next 3 lines are just some dummy values until you have need for other sensors above
	data0 = 1
	data1 = 2
	data2 = 3
	pause 1000

	low c.3 ' end of flash LED
	
; *********************************
; ***** Display values on LCD *****
; *********************************
; Here is continuously display the last logged temperature, how many thimes the power has been cycled or reset performed
; and the number of records stored thus far in the current campaign
;
	SEROUT LCD, T2400,("?f?n") 'clear LCD
	PAUSE 1000
	READ 2,temp_byte
	SEROUT LCD, T2400, ("Temp=",#data7," ?n")
	SEROUT LCD, T2400, ("PwrOn=",#temp_byte," ?n")
	SEROUT LCD, T2400, ("Rec-Count=",#address,"?n")
	

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

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

;	
; ===============================================================================
; This arrangement has changed from the typical wizard auto setup details
; to suit logging of the data and time as well as up to 4 sensors
;
;24LC256 addr 0 = Input0 in IC0 as Humidity
;24LC256 addr 1 = Input1 in IC1 as Future 1
;24LC256 addr 2 = Input2 in IC2 as Future 2     - year at address 0 only
;24LC256 addr 3 = Input3 in IC3 as Temperature  - month at address 0 only
;24LC256 addr 4 = Input0 in IC4 as Date
;24LC256 addr 5 = Input0 in IC5 as Hours
;24LC256 addr 6 = Input0 in IC6 as Mins
;24LC256 addr 7 = Input0 in IC7 as Secs


; with 8 x 24LC256 EEPROMs = 32768 bytes each as 0 to 32667 
; 
; If there was a single 24L16 EEPROM, then that EEPROM is in 8 blocks
; so no change needed below other than the max is now 255 instead of 32767
; in which case adjust the next line of code

	if address > 255 then memory_full

; 	
;	
;
 

Attachments

westaust55

Moderator
welcome to the PICAXE forum.

The code as written was based upon a set of eight 24LC256 EEPROMs.

If you only have one 24LC16 EEPROM then you will need to modify the slave addresses in many writei2c and readi2c commands for the EEPROM only so that they are all set for the same EEPROM. In fact where I had writes and reads in sequence to many EEPROMs then just one SLAVEi2c command will suffice.

Thus for example, where the developed code currently is:
Code:
      i2cSLAVE %10100000, i2cSLOW, i2cWORD  ; EEPROM 0  save a "-" character in the first EEPROM as a flag
	WRITEi2c address,("-")
	PAUSE 10		; pause needed to give EEPROM time to write data before it can be read back
	READi2c address,(temp_byte)
	IF temp_byte <>   "-" THEN ee_error
	
	i2cSLAVE %10100010, i2cSLOW, i2cWORD  ; EEPROM 1  save a "-" character in the second EEPROM for good measure
	WRITEi2c address,("-")
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  "-" THEN ee_error
	
	i2cSLAVE %10100100, i2cSLOW, i2cWORD  ; EEPROM 2
	WRITEi2c address,(year)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  year THEN ee_error
	
	i2cSLAVE %10100110, i2cSLOW, i2cWORD  ; EEPROM 3
	WRITEi2c address,(month)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  month THEN ee_error
	
	i2cSLAVE %10101000, i2cSLOW, i2cWORD  ; EEPROM 4
	WRITEi2c address,(day)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  day THEN ee_error
	
	i2cSLAVE %10101010, i2cSLOW, i2cWORD  ; EEPROM 5
	WRITEi2c address,(hours)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  hours THEN ee_error
	
	i2cSLAVE %10101100, i2cSLOW, i2cWORD  ; EEPROM 6
	WRITEi2c address,(mins)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  mins THEN ee_error
	
	i2cSLAVE %10101110, i2cSLOW, i2cWORD  ; EEPROM 7
	WRITEi2c address,(secs)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  secs THEN ee_error

this can be altered to:
Code:
      i2cSLAVE %10100000, i2cSLOW, i2cWORD  ; EEPROM 0  save a "-" character in the first EEPROM as a flag
	WRITEi2c address,("-")
	PAUSE 10		; pause needed to give EEPROM time to write data before it can be read back
	READi2c address,(temp_byte)
	IF temp_byte <>   "-" THEN ee_error
[COLOR="Red"]	INC address[/COLOR]
 ; EEPROM 1  save a "-" character in the second EEPROM for good measure
	WRITEi2c address,("-")
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  "-" THEN ee_error
[COLOR="Red"]	INC address[/COLOR]	
; EEPROM 2
	WRITEi2c address,(year)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  year THEN ee_error
[COLOR="Red"]	INC address[/COLOR]	
; EEPROM 3
	WRITEi2c address,(month)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  month THEN ee_error
[COLOR="Red"]	INC address[/COLOR]	
; EEPROM 4
	WRITEi2c address,(day)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  day THEN ee_error
[COLOR="Red"]	INC address[/COLOR]
; EEPROM 5
	WRITEi2c address,(hours)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  hours THEN ee_error
[COLOR="Red"]	INC address[/COLOR]
; EEPROM 6
	WRITEi2c address,(mins)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  mins THEN ee_error
	
[COLOR="Red"]	INC address[/COLOR]
; EEPROM 7
	WRITEi2c address,(secs)
	PAUSE 10
	READi2c address,(temp_byte)
	IF temp_byte <>  secs THEN ee_error
notice how I have the address value incrementing after each write.

Now there are further potential complications in that we do need to change the slave address as each block of 64 bytes is written since the 24LC16 uses the slave address as pasrt of the access to all the EEPROM memory locations.

Have a look at the output from the PE Wizard for the Datalogger when using 4 sensors and a 24LC256.

Use of even a single a 24LC256 (only slightly higher cost than a 24LC16) will overcome these addressing issues.
 
Last edited:
Thanks Westaust,

I've got four Atmel 24C32's on order. I will mess around with the code once I have these on hand.

Again, I appreciate your help. I sure am having fun with the picaxe.

Best Regards,
-Brian
 

Armp

Senior Member
On Chip EEPROM Endurance

Thanks for providing the very useful code. I'm hoping to borrow some of it for a datalogger with a 'circular' 24LC256 buffer storing about 10 samples/sec...

My question is : Does the on-chip EEPROM have the same limitations on write cycles that the 24LC256 has? I know its a large number but in the example code it looks like locations 0 and 1 get written every time a sample is taken? That's 864,000 times/day.

Not a problem for me as I think I can use the DS1307 RAM for non volatile variable storage anyway - just curious.

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

	let address = address + 1
	write 0,b6
	write 1,b7
 

papaof2

Senior Member
If you want data saved with no worries about write limitations, FRAM chips have have a 1 trillion write cycle spec. They cost more than EEPROM, but there are pin-compatible FRAM chips that plug into the socket the EEPROM was in.

At 864000 writes per day, I think 1 trillion writes might take several lifetimes ;-)

John
 

Armp

Senior Member
I don't have a problem with the 24LC256 EEPROM John, the address is written to the PICAXEs EEPROM as far as I can tell....
But then similarly I don't understand why the datalogger only uses 16k of the 32k space available :confused:
 

westaust55

Moderator
Thanks for providing the very useful code. I'm hoping to borrow some of it for a datalogger with a 'circular' 24LC256 buffer storing about 10 samples/sec...

My question is : Does the on-chip EEPROM have the same limitations on write cycles that the 24LC256 has? I know its a large number but in the example code it looks like locations 0 and 1 get written every time a sample is taken? That's 864,000 times/day.

Not a problem for me as I think I can use the DS1307 RAM for non volatile variable storage anyway - just curious.
A very good point. Yes most PIC chips have around 1 Million write cycles for endurance for the EEPROM memory.

And yes, in thinking about it, using the DS1307 RTC NV ram is a better solution to keep track of the EEPROM address location.

The code as written at the time was in a bit of a hurry and was for a particular application to log the data inside an articulated trailer on occassions when it took a live load to a destination.
Power outages were being logged in the original inproject in case the datalogger was isolated due to operator/driver "error".
Tentatively for most datalogging applications unless power consumption is critical, it may even be possible to keep the address pointer in PICAXE RAM where an RTC without NV ram is used for a home brew or other datalogger.
 

Armp

Senior Member
Tentatively for most datalogging applications unless power consumption is critical, it may even be possible to keep the address pointer in PICAXE RAM where an RTC without NV ram is used for a home brew or other datalogger.
In my case, with a circular buffer, I need to keep the start and end pointers to the buffer.

My code was originally written in compiled basic for an ARM LPC2103 chip running at 60Mhz. Complete overkill, and the ARM board cost $30.

It has been an 'interesting' project mapping over to a $4 PICAXE. [Old Fart] Feels like I've gone back 30 years to the Sinclair ZX81. :) [/Old Fart]

Not quite there yet - but close. Still trying to tweak the timings to give me the desired sample rate.
 
Last edited:

westaust55

Moderator
Good luck with your high frequency / short interval datalogger.

For what it is worth, I have just had a look at the Programming Editor Wizard output for the AXE110 datalogger and the use of the PICAXE EEPROM memory locations 1 and 2 to hold the external EEPROM address stems from there.

Code:
' ***************************
' ***** Initialisation  *****
' ***************************

init:
	let dirsB = 255 'setup outputs

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

	high 5 ' write protect eeprom
'reload the last address from data memory
	[COLOR="#FF0000"]read 0,b6
	read 1,b7[/COLOR]
As I started reading your previous post even before I reached the end I had the same thought to use the DS1307 RTC NV ram as a more suitable address storage location.
 

g6ejd

Senior Member
Another way of doing this, assuming your data logging at fixed intervals, is to save the base time, then after recovering the data, just add the number of logging unit intervals (e.g. 1-hr or 1-min) to the base time, to get the same result, then a little processing saves a lot of storage and extends the logging capacity:
00:00 (base time saved)
1, data reading1
2, data reading2
3, data reading3
4, data reading4

Reading 4 took place at 00:04 and so on.
 

westaust55

Moderator
Yes that concept will work equally well for many requirements.

In the example first posted (and it was just an example for others) the end user wanted to log only a few sensors and had an AXE111 expansion board so we had lots of memory.
Additionally the end user had an essential need to know when the data logger had lost power and then resumed and how many times this had occurred (hopefully nill)
as the logger was used to monitor critical freight where high temperatures lead to the demise of the freight.
 
Top