July 11, 2010

Arduino datalogging accelerometer with µ-SD storage


Thanks to Will Greiman's Fat16 library for the Arduino, I finally got a useful version of this datalogger working! Here's the schematic:

And here's the code.

The code is highly configurable: it can save raw A/D values or converted values, it allows software-defined gain, it can collect for a set time or until user input, and of course the collection interval is user-defined. It also includes a "DEBUG" mode, in which it tells the serial line everything that's happening. It can collect multiple data files (up to 100) per card, and will tell you about any errors it encounters.

All this in a small enough program to fit on an ATMega168! The data collection rate is not as high as I'd like on this 8MHz chip, and the sync() calls to the µSD card cause missed data intervals when the sample period is below 100ms, but for slower data-collection situations it works great. (Does anyone make a 32MHz 3.3V Arduino? That would be nice, here...)

Now to go do some physics with it!

6 comments:

  1. amazing man! nice job posting it.

    ReplyDelete
  2. I'll be borrowing these ideas. A project of mine is creating something like a Fit Bit, but with rawer data, and the Arduino Pro Mini was the exact microprocessor I was thinking of using. Good to know it has worked for someone, already.

    ReplyDelete
  3. I'm curious if you ever ran any experiments with this setup. I'm particularly interested to see what kind of data you were able to obtain. I'm trying to build the same accelerometer data logger for some vibration testing but 100 ms between samples is pretty slow for my application. I'm going to try the UNO and its 16 MHz clock speed and see how far I can push it. Any data you might have to offer would be very helpful.

    ReplyDelete
  4. Yeah, it's slow; and I've not been able to get it to go significantly faster. For vibration sensing I'd guess you need an order of magnitude faster at least, and I don't think that's possible with this hardware. The main bottleneck seems to be the SD card write speed, but the A/D conversion time may also be a limitation even if you can speed up (or postpone) the writing.

    Most of the data I've needed lately is thermal rather than acceleration, so the required data rate is very low. If I had to do this using an Arduino, I'd check into the possibility of offloading the data collection duties to another dedicated chip that could collect data in high-rate bursts, then send it to the Arduino for SD storage.

    ReplyDelete
    Replies
    1. Hello,

      Dr. Ayars, I am running into the exact issue you referenced in your June 27th post. I am trying to measure the natural frequency and natural dampening of a 100' tube (angular, not deflection). I want to take the stored data and analyze it in Matlab. Thoughts?

      Delete
    2. Wish I had some good advice for you on this one, but the truth is I've had trouble getting the arduino/SD combination to go much faster than 10Hz. I don't think that Arduino is the solution here.

      What about using a Raspberry Pi with one of the Adafruit A/D converter breakouts? I've not tried that yet, but it might be a better option than the Arduino.

      Delete