I want to read and store data from an accelerometer and I'm just wondering what the best practice is, or what the limitations are.
I have this accelerometer, and this is (hopefully soon) on it's way.
I'm just wondering what to do. I could:
- Try to write data to the SD-card as fast as possible directly from the x, y and z axis.
- Average the data using one or three threads and store the average value every second or so.
- Just pull a sample every second or so and store that.
I believe the first method would be best for analysis. I can run some tests and find the best algorithm for reating the data afterwards. However, can it be too much for the SD card, perhaps? Or how fast can the Netduino Plus sample data?
Method three is the easiest to implement, but I could be missing information I'm interessted in.
Method two is the one I'll use eventually, I believe, as it shouldn't be necessary to keep that much data.
If this had been a Windows application, I'd say just store the data and process them later. But on a little more limited hardware I'd like to know what I should do.
I am doing this exact same thing with my weatherstation project.
http://forums.netdui...itor-webserver/
I use the netduino+ to sample the sensors. I have a single "stats" class that contains the values for each of the readings I am taking. So, the main program just calls a class to sample a sensor, gets that reading, and calls a stats class method to update the value for that sensor. In that method, I check to see if the value is higher or lower than my min/max values I have stored. If so, the class updates min and max, and saves a timestamp for min and max.
Every 1 second a thread wakes up and sends the values (via xml) over a socket to a server running on another PC. This server has the same stats class implemented, and it keeps averages every 1 minute, day, hour, week, month, year, and since inception. Every 1 minute a thread in the server wakes up and saves the 1 minute average to an XML log file that I can later pull into excel to do all of the trending that I want.
So, in a nutshell, isolate the main program from the statistical work via a stats class. Have the stats class summarize the data and write it where ever you want to. I chose to do this on a separate PC/Server because I was running low on memory on the netduino, and I want to write a web interface to the weatherstation. Too much work for the netduino+ IMHO.
Hope that helps,
Scott...