BS2E Internal EEPROM DataLogging
skynugget
Posts: 172
hey all, I've come across a lot of post about this, but i cant seem to pull it together in my head, so I'm sorry if I'm beating a dead horse with this.
I would like to store a couple values in program bank 7 of my bs2e. its basically a "timestamp" consisting of:
day byte
month byte
year byte
hour byte
min byte
sec byte
value byte
so basically i want to write 3 words and a byte to the eeprom bank till the eeprom fills up then start over, then read it back for display on an lcd.
if anyone has a good post/article/snippet i would really appreciate it.
thanks in advance!
I would like to store a couple values in program bank 7 of my bs2e. its basically a "timestamp" consisting of:
day byte
month byte
year byte
hour byte
min byte
sec byte
value byte
so basically i want to write 3 words and a byte to the eeprom bank till the eeprom fills up then start over, then read it back for display on an lcd.
if anyone has a good post/article/snippet i would really appreciate it.
thanks in advance!
Comments
i guess i could pass the values through scratchpad to a routine in slot 7 that writes to its eeprom?
Take a look at this application information supplied by Dr. Tracy Allen on his web site:
http://www.emesystems.com/BS2pe.htm
Regards,
Bruce Bates
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
When all else fails, try inserting a new battery.
There's a Nuts and Volts Column on multi-slot programming. I don't remember which issue, but it should be easy to find on Parallax's Nuts and Volts Columns index.
thanks again mike, you are correct... the article you are thinking of is nv87 on multislot programming. ive got my head wrapped around its contents, this is my first multislot program, couldnt have gotten this far without it [noparse]:)[/noparse] (thanks jon!)
is anyone aware of some examples of "the usual solution" work around for a lack of the store command?
Post Edited (skynugget) : 10/31/2008 12:59:24 AM GMT
www.emesystems.com/BS2SX.htm#datalogger
hopefully i can wrap my head around it, thanks for the nudge bruce, and thanks for the page tracy!
im having trouble figuring out my read sub,_ee id like for my read statement to cycle through and populate an array stating at the last timstamp(0) spot in the eeprom and store it in spram for display elswhere.
any ideas?
I think there should be two pointers: One is EEadr as you have it, to point to the next location to write a group of 7 bytes. The other, call it EEzero, should point to the oldest location, which will always be the next one to read out. At the start, EEzero and EEadr both point to location zero. But then as data is written, EEadr advances. Nothing happens to EEzero until the EEadr pointer wraps around and catches up with the EEzero pointer. If that happens, then EEzero has to advance too, always in front of EEadr. EEzero always points to the oldest data, which you will want read first. The two pointers chase one another around the circular buffer. I'm not sure, does that make sense in light of what you are trying to figure out?
The math becomes a little easier if the size of the buffer is an integer multiple of the record size, for example, 271 * 7 = 1897, instead of 1900.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
i think im mopping up what your spilling with the double pointer, and the eeprom size. hopefully ill have time to play tonight and post my results.
basically what im trying to do here is scroll up and down the timestamp records in the eeprom and show them on a lcd.
thanks again tracy, and everyone else for that matter!
i ended up making 2 subs for the reading the eeprom... 1 to read up the eeprom(up button press), and one to read down the eeprom(downButton Press). also there is a sub Last write, then i use to display the last entry written.
tracy, or anyone else do you see any problems or have any suggestions?
many thanks!
EEZero = (EEadr -7) // EEAdr ' set read pointer 7 bytes from last eerprom write
will run into trouble when EEadr runs over to zero. Instead, add a number that is 7 less than the modulus, like this:
MaxAdr7 CON MaxAdr-7
EEZero = (EEadr + MaxAdr7) // EEAdr ' set read pointer 7 bytes from last eerprom write
The same caveat applies to the EE_read_down routine, but I see you already did that.
I didn't understand that you want to intersperse writing the data with reading it back. Right? There are separate slot entry points for each function. I think you need one more pointer and a flag.
EEadr points to the location to write the next data.
EEzero points to the location of the oldest data, which will be fixed until the memory is full, after which it will track one step ahead of EEadrs
EEfullflag is zero until the memory fills up, becomes 1 at the same time that EEzero starts to lock step with EEadr.
EEreap This is the read pointer, which has to stay within the bounds of the data that has been collected, and may be different from EEadrs or EEzero.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
Post Edited (Tracy Allen) : 11/12/2008 7:39:58 PM GMT
in this instance i dont care if the eeprom fills up, when it fills up i would like it just to go back to 0 and rewrite the old entries.
you still think i need more pointers?
As it stands now, it will work fine to wrap for both writing and reading once the memory is full. You have it arranged so that every time a write occurs, that sets the eezero pointer to the most recent reading. What happens if a person is stepping through the readings and suddenly a new reading comes along and shifts the read pointer? You see, I don't really know if that would even happen or be disconcerting!
When you press up or down for reading, what do you want to happen when it comes to either end? Stop, or wrap around? If the recording has just started and there are not yet 1610 bytes (230 records) recorded, then the read could go into eeprom areas that have not yet been recorded. Maybe that is not a problem.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Tracy Allen
www.emesystems.com
i thought about the eeprom issue, figured the math was to hard to do, but now i dont!
i debated last write sub for a while, but i figured id always want the last record to pop up so i know it was the last record from the start. i think i might be able to run some code in my "display slot" that could alias a record number now though as well. thanks for the attention dr.allen!
When i coment out
eeread = eewrite
at the top of sub Write_EE, it works like i think it should, but then i loose my functionality. when this sub writes an eeprom entry, i would like it to read it back to me as soon as its done with writing.