Collecting values for certain time and store it once

cembedded

I am trying to save some values to memory, I have an array with 6 values like as shown below

Data[6] = {5045.567,4567.987,4.5,190.5, 70.5,500};

I have to save this kind of data into flash memory. I have memory which can store only 16 bit at each address and i am able to write 16 bit.I need to write two times to write a float value. I am multiplying 5045.567 with 1000 to make long integer 5047567 so that i can save float value(two address to write float value). My data will look like this.

long int Data[6]= {5047567, 4567987, 4500 190500,700500,500}

Is there any best method to save float value instead of multiplying with 1000 to make it as long integer?

To save this kind of data i need two address sometime and one address is enough some time.I will have this kind of data every 10 secs, I can't write to memory every 10 secs because of power saving features.

I am trying to collect values every mint and trying write to memory at once every mint.

For this I have initialized an array with size[36] and saving all values after one mint. Is there any best way other than this to collect values for certain time and save once?

I am collecting all 36 values in an array.
for example first two values needs two address in memory then next four values need only one address in memory.
How do i increment address in memory for certain values? or is it best to divide long values into two integers before storing into array?

Best Answer

You are getting ahead of yourself.

First specify what exactly needs to be stored with what precision and range. Does it really need to be floating point? Very likely you don't need either the resolution or dynamic range, probably neither.

For example, if these are voltage measurements from 0-10 V measured with a 12 bit A/D, then you don't have more than 12 bits of real information. In this example, you could store the raw A/D readings directly, or use a common format like integer millivolts.

Added

You now say these values are derived from 24 bit A/D readings. If storage size is important, you can use a 24 bit representation (Are all 24 bits really meaningful? Probably not) and store two of them every 3 words. For more convenience but 1/3 more memory usage, use two whole words for each reading. I'd pick a convenient unit and zero offset and store the readings as 32 bit integers. Floating point is a bit silly in this case, but that's only 32 bits too.

Either way you have 32 bits, or two words, to write to the non-volatile memory for each reading. In any case, I fail to see a problem here. It doesn't matter whether you write the two words in high-low or low-high order as long as you are consistant and the reader follows the same scheme. Again, what exactly is the problem?