CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

eeprom data compression

 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
zonared



Joined: 24 Mar 2004
Posts: 4

View user's profile Send private message MSN Messenger

eeprom data compression
PostPosted: Wed Mar 24, 2004 11:45 pm     Reply with quote

I was wondering if anyone has ever had to compress variables to make better use of there eeprom space? I have an external eeprom 256byte and 256byte internal eeprom in the 18F452. I need to fit more variables into these eeproms and thought maybe the data could be compress. Has anyone written some form of algorithm/function to do this? Thanks.
Ttelmah
Guest







Re: eeprom data compression
PostPosted: Thu Mar 25, 2004 4:03 am     Reply with quote

zonared wrote:
I was wondering if anyone has ever had to compress variables to make better use of there eeprom space? I have an external eeprom 256byte and 256byte internal eeprom in the 18F452. I need to fit more variables into these eeproms and thought maybe the data could be compress. Has anyone written some form of algorithm/function to do this? Thanks.

Data compression algorithms, are not simple. The odds are that the size needed to implement the algorithm, would use so much code space, that you can't then fit the rest of your program...
A massive amount, depends on the nature of your data. For instance, if it is a sequence of numbers, which may change only by a small amount, it is simple to use 'delta' storage, and only save the difference between values, possibly using a single bit or nibble to hold this. Equally, if there are only a limited number of possible 'value ranges', for a 16bit value, then you could store a much smaller value, used as an index to a table of values stored in the code area.
In general, unless there is some special pattern to the data, compression algorithms, will not save space for small amounts of data. Most algorithms are dependant on the fact that patterns will repeat in data, and store a 'library' of patterns, extracted from the data. For sizes under probably a few kB, the library itself will be larger than the data...
In fact, most of the smarter algorithms know this, and will not compress data sizes smaller than a critical size.
You need to look at your data, and work out if there are ways of using less space. For instance, if you are wanting to store floating point numbers, and know they are in a particular range, then store a scaled integer instead.

Best Wishes
Haplo



Joined: 06 Sep 2003
Posts: 659
Location: Sydney, Australia

View user's profile Send private message

PostPosted: Thu Mar 25, 2004 4:17 am     Reply with quote

Or try to pack more data in the available space. For example if your variable values are always going to be smaller than 32 you can pack 8 variables in 5 bytes.
Neutone



Joined: 08 Sep 2003
Posts: 839
Location: Houston

View user's profile Send private message

PostPosted: Thu Mar 25, 2004 7:30 am     Reply with quote

I typicaly locate bit variables so they occure in byte groups. This allows them to be saved and loaded all at once. Not really compression as much as locating.
zonared



Joined: 24 Mar 2004
Posts: 4

View user's profile Send private message MSN Messenger

Thanks
PostPosted: Tue May 25, 2004 7:53 pm     Reply with quote

Smile I have organised some of my variables into status registers and I can write to the eeprom as integers like Neutone suggested. Thanks again guys.
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group