View Full Version : data not in memory after program end
christree
21-01-2006, 05:16
I am working on the datalogger example for the picaxe08. It weems to be capturing data, and storing it in eeprom as determined through debugging, however when the program is restarted to download, the data seems to be missing. That is, the variable b1 is empty, verified by debugging. Additionally, information passed to the computer terminal program is in hex format (lots of symbols) with some text.
Any thoughts on the above would be greatly appreciated.
Thanks,
Chris
________
Oxycontin Rehab Dicussion (http://www.rehab-forum.com/oxycontin-rehab/)
The variables b0, b1, b2 etc... are not EEPROM stores buy volatile RAM stores and data stored here is lost on power-down. Reprograming the PICAXE also resets these storage locations. You will have to get the program to include a download routine so that you can send data in you "b" variables before reprogramming or power-down.
For the terminal data, what are you expecting should be sent and what exactly is being sent?
<b><i>ylp88 </b> </i>
Edited by - ylp88 on 1/21/2006 4:51:04 AM
christree
21-01-2006, 15:44
Thanks for your reply. I've posted the code below. I believe it is storing data in the eeprom using the write command. The data coming to the terminal looks sort of like this ||||||||datalog||||
|||||||%$record1||||
|||||||||%$record2|||| etc
The code is refined to just capture two records for testing,
'Send data to terminal
serout 0,n2400, ("Datalog")
for b0 = 0 to 2
Read b0,b1 ' READ b0,b1 - Reads EEPROM location b0 and puts that value into b1
debug b1
'serout 0,n2400, (#b1,"record",#b0)
'serout 0,n2400, (10,13) 'New line
next b0
wait 1
' Record and store the data
for b0 = 0 to 2
sound 0, (75,10) 'Sound sent to the peizo
pulsout 2,500 'Flashes the led on pin 2
readadc 1,b2 ' READ 1,b2 - Reads pin 1 and puts that value into b2
write b0,b2 'WRITE b0,b2 - Writes b2 to the EEPROM location specified by the value in b0
debug b0,b2
sleep 1 'Wait 1 x 2.3 seconds
next b0 'increment up to 63
for b0 = 0 to 2
read b0, b1
debug b1
next b0
Another odd thing is if I change the pin # from 0 to 4 for the serout it still seems to send information. Should this happen?
Thanks,
Chris
??
________
Wendie 99 (http://www.lovelywendie99.com/)
The code looks okay, although rather than DEBUG you might want to change those to SEROUT's so yoiu can see what's going on by using the Terminal Window ...
'Send data to terminal
FOR b0 = 0 TO 2
READ b0,b1
SEROUT 0,N2400,("Read ",#b0," Val ",#b1,CR,LF)
NEXT
WAIT 1
' Record and store the data
FOR b0 = 0 to 2
READADC 1,b1
WRITE b0,b1
SEROUT 0,N2400,("Write ",#b0," Val ",#b1,CR,LF)
SLEEP 1
NEXT
' Verify recording
FOR b0 = 0 to 2
READ b0,b1
SEROUT 0,N2400,("Verify ",#b0," Val ",#b1,CR,LF)
NEXT
' Reserve space for readings 0 to 2
EEPROM 0,(0,0,0)
When you restart the program, I presume you mean you remove and re-apply power rather than downloding the program again. Whenever a program is downloadd all Eeprom data is reset to zero except any specified by an EEPROM command.
If your program is still outputing when changing SEROUT pin from 0 to 4, that suggests there is a wiring fault or short somewhere, or the new version of the program wasn't downloaded.
Edited by - hippy on 1/21/2006 4:12:48 PM
christree
21-01-2006, 20:47
Hi Hippy:
That seemed to solve everything. It works well now, thanks!! Also, there is no more garbage in the terminal window; just the expected text and measurement values.
Is there literature that explains some of the terms like CR,LF?
Also why is it necessary to use this code,
EEPROM 0,(0,0,0)
When I don't use it, the program still seems to work. Is there literature you can refer me to?
Thanks again,
Chris
??
________
Grey's anatomy forum (http://www.tv-gossip.com/greys-anatomy/)
The CR and LF are pre-defined constants for carriage-return and line-feed, 13 and 10 respectively - which having written that made me realise now why you got the |||| effect; the CR needs to preceed LF, ie 13 before 10, whereas you were outputting them the otherway round. Not sure where they are defined, but I recall they may be mentioned in one of the PICAXE Manuals.
The EEPROM 0,(0,0,0) defines three areas of Eeprom so they can't accidentally be used by program code. When using the PICAXE-08, 08M and 18, the program memory is shared with data memory so a WRITE can corrupt the program itself.
Powered by vBulletin® Version 4.1.10 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.