I am attempting to log data using my Arduino and I am unsure about the feasibility of my approach. My goal is to scan a linear sensor with 512 pixels six times, that is 5126 data values. The values are coming from a 16 bit ADC so some of then have a magnitude of >10000. It was suggested that I use a char array of a large enough size to store all those numbers, that is 512pixels6scans*5characters per value max. That takes up way to much of my dynamic memory (i.e. 787% of it). Obviously that won't work. I considered using PROGMEM to save the char array to, but this requires that the array is constant which it is not.
Since I eventually need to write this data to an SD card I could try to just write each value to a single file on the card, but I am worried this will severely slow my data collection as it only took about 10 seconds originally to just Serial.print all the data before. I read something like upwards to 380 ms just to write a 30 bit character to the SD card.
So, does anyone have any suggestions on how I should approach this? If writing to the SD one value at a time is the only other way, then so be it, but is there a better way?
16 bits per value.
Read values from ADC -> Place in to array of ints. Each int is 16bits = 2 bytes.
Memory available is aprox 2kB = 2kB/2 = 1,000 ints.
512 pixels should easy fit in that space. Takes about half of available SRAM.
You are getting mixed up with types.
An INT is 2 bytes. A CHARACTER is one byte. During writing to the SD card, the library will convert the 2 byte INTs in to CHARACTERS in the txt file. You only need to store the ints in mem...not some pre-converted characters.
Or as '1284P, 16K SRAM, vs just 8K in the 1280/2560. I offer boards in several form factors, including Uno style, with onboard or offboard USB/Serial interface optons, and varying other features: http://www.crossroadsfencing.com/BobuinoRev17/