A work project requires a headless data logger to store data from two accelerometers to determine the motion of a component.
For phase 1, the H3LISS31DL accelerometer and a Teensy 3.0 was chosen for a proof of concept demonstrator. As a stretch goal, the phase 1 demonstrator will also store and retrieve accelerometer data from external Flash memory.
Phase 2 will have a custom PCB, a microcontroller in place of a dev board, and a rechargeable battery. The goal is to develop a board as small as possible that can run for at least 15 minutes of continuous data logging. Off board data transfer and battery charging circuitry is acceptable.
Phase 3 will have to wait until MEMS accelerometers comes out with faster acquisition rates and higher measurement ranges. Further miniaturization of PCB and power supply.
ST eval board for H3LIS331DL in DIP form
Development board based on Freescale MK20DX128
Need to select a low power, fast, bufferred SPI Flash chip, prefferably in DIP form.
After managing to set the output data rate to 1000 Hz and the measurement range to 400G's, I made some mods to the Arduino sketch so I would poll the accelerometers every second and timestamp the readings down to the microsecond using the micros() function. In the interest of speeding up the code, I used a single Serial.println() statement to pass the accelerometer data back to the PC via the serial monitor. When it was all said and done, it was taking 1.0065 seconds between serial line prints.... So I guess that means my software loop was taking ~6.5 ms. My code was passing the accelerometer data out as "G's" in float format. The library can return the data as signed integers, reducing the overhead for the serial transfer and I can always get the data back into g's during post processing.
Further goals for Phase 1:
1) Implement I2C_TC3 library by Brian Nox that runs much more efficiently than the default Arduino Wire library on the Teensy 3 and 3.1.
2) Rewrite the read data function or create a dedicated function to take advantage of the accelerometer's ability to do multiple byte reads.
3) Write code to store raw accelerometer values into an array for transfer later to the PC via the Serial Monitor.
4) The accelerometers have configurable digital output pins that can serve as interrupts. One of the supported interrupts is "new data ready." Work interrupts into the code, so it only reads accelerometer data when it is available.
5) Work on implementing external Flash storage via SPI.
I purchased 2 STEVAL-MKI153V1 eval boards from Mouser and used an old Teensy 3.0 I had bought for personal use a while back for another project. I slapped everything onto a prototype board and wired everything up with some hookup wire. Now onto software! After some Goggling I found the Seed Studio Arduino library for the H3LIS331DL accelerometer. Github Link Here. The library communicates via I2C to the chip but unfortunately only supports 1 accelerometer at a time. The I2C slave address for the accelerometer is hard coded. So after getting the demo sketch to work with a single accelerometer, the next step was to delve into the library and dig into adding functionality to declare the accelerometer's I2C address when initializing the accelerometer.
After a lot of poking and prodding at the code, I managed to get the demo running with 2 accelerometers and configured for the measurement range and output data rate I was looking for. It was a huge help that I could save changes to the library's source and header files and then simply recompile the Arduino sketch and see the impact. If I can get my act together, there will be links to my Git with the modified library.