PDA

View Full Version : How to save data on serial EEPROM like a database ?



iugmoh
- 28th January 2008, 16:40
Anyone have an experience what is the best algorithm to save data or information on serial eeprom like a database for the ease of reading and searching after saving like this table
ID Time Date #of register
=================================
1200312 8:30 12/9/2009 10
....
and so on

I know how to save data on serial eeprom using PIC microcontroller but how and what is the best way I don't know ?

so anyone can help me ?

skimask
- 28th January 2008, 16:46
Anyone have an experience what is the best algorithm to save data or information on serial eeprom like a database for the ease of reading and searching after saving like this table
ID Time Date #of register
=================================
1200312 8:30 12/9/2009 10
....
and so on

so anyone can help me ?

Just save it as raw character data...wouldn't that be the easiest thing to do? No math needed when saving or retrieving. Sure, it's not the most efficient way to save data, but how expensive is eeprom/flash these days?

iugmoh
- 28th January 2008, 17:10
but i think that there are an article or paper for the effiecient way of saving data , I don't know where I see it.

skimask
- 28th January 2008, 18:06
but i think that there are an article or paper for the effiecient way of saving data , I don't know where I see it.

Ok,
ID Time Date #of register
=================================
1200312 8:30 12/9/2009 10

ID - seems to be a 7 digit number. You can either store that as a single LONG, or 2 WORD's, either in hex format, or BCD... Figure 28 bits

Time - hours/minutes - 24 hours = 5 bits, 60 minutes = 6 bits, 11 bits for time, 11 bits for this

Date - Month/Day/Year - 12 months = 4 bits, 31 days = 5 bits, Year-call it 64 years total, offset by +2008, 6 bits; 15 bits total

Register - don't know how many registers, but I'll assume 16 (numbered 0-15), 4 bits there.

28 bits for ID + 11 bits for time + 15 bits for date + 4 bits for register = 58 bits, 8 bytes total, with 6 leftover for whatever else.

Then you play with the bits/byte, putting thing where they need to go...AND'ing them out here, OR'ing them in there. Whatever works for you.

So the bits in the 8 bytes look like:
IIIIIIII IIIIIIII IIIIIIII IIIIHHHH HMMMMMMm mmmddddd yyyyyyRR RRxxxxxx
I = ID
H = hours
M = minutes
m = month
d = day
y = year (offset by 2008, add 2008 to the total)
R = register
x = spare

Jerson
- 29th January 2008, 03:48
By efficient, I assume you are looking for utilising the EEPROM to its stated write endurance. I do recall having seen an article about this perhaps on this site. Or maybe, is it Microchip site?

JF

iugmoh
- 29th January 2008, 09:19
Thanks alot for skimask for the importnant information that clearify our problem