Number of records in 32 kilobytes?
I am considering buying an external EEPROM s开发者_开发技巧torage module for my microcontroller. However, it only has 32 kilobytes storage capacity.
I'm using this to store records where each record is basically 4 separate numbers ranging between 0 - 180.
How many records do you think 32 kilobytes could handle?
A single record is an element out of a range of 181^4
possible elements, giving an information entropy of log(181^4)/log(2) = 29.999 bits
. So you can, with some effort, encode one element in 30 bits.
This means you have floor(32 * 1024 * 8 / 30) = 8738
elements you can store. If you choose to encode using 32 bits - 4 bytes - for a significant simplification in your encoding logic, then it's 32 * 1024 * 8 / 32 = 8192
elements.
This analysis does not count any additional overhead for metadata such as validity bits, or flags to indicate which element is the newest, etc.
Besides the fact that you can store 8k elements using 4 bytes for each record in the EEPROM, have you considered using an SD card instead of an EEPROM? There are quite cheap SD card shields available for the Arduino, and, in addition, SD cards are very cheap and you won't have any space problems. You can access the SD card by SPI.
精彩评论