Unit testing and development for 9DOF sparkfun sensor stick
Dependencies: ADXL345 HMC5883L ITG3200 mbed
Diff: main.cpp
- Revision:
- 0:ac2f55940442
- Child:
- 1:dc730a26cdc2
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Oct 30 17:30:03 2012 +0000 @@ -0,0 +1,52 @@ +/** + 10 second 9-dof data log + + The purpose of this program is to demonstrate and calibrate the three + sensors on teh 9-doft board. + + The first version of this software will test the ITG3200 gyro to find + the temperature drift line. Data will be logged to help determine the + thermal drift line. + See: http://mbed.org/users/gltest26/code/ITG3200/wiki/Thermal-Drift +*/ + +#include "mbed.h" +#include "ITG3200.h" + +int main() +{ + DigitalOut myled(p24); + LocalFileSystem local("local"); // Create the local filesystem under the name "local" + ITG3200 gyro(p28, p27); // sda, scl - gyro + //const float offset[3] = {99.53, -45.26, -29.53}; // taken from itg3200_05.xls curve fit + //const float slope[3] = {-0.95, 0.95, 0.47}; + + //gyro.setCalibrationCurve(offset, slope); + //gyro.calibrate(1.0); + gyro.setLpBandwidth(LPFBW_5HZ); + + Serial pc(USBTX, USBRX); + + pc.baud(9600); + + myled = 0; + FILE *fp = fopen("/local/itg3200.csv", "w"); // Open "itg3200.csv" for writing + fputs("Temp, X, Y, Z\r\n", fp); // place the header at the top + + float temperature = 0.0; + int gyro_readings[3]; + + for(int i = 0; i < 120; i++) { // 120 seconds - 600 samples + myled = 1; + gyro.calibrate(1.0); + //wait(0.5); + myled = 0; + //gyro.getGyroXYZ(gyro_readings, ITG3200::Calibration); + gyro.getOffset(gyro_readings); + temperature = gyro.getTemperature(); + pc.printf("%3d,%f,%d,%d,%d\r\n",i,temperature,gyro_readings[0],gyro_readings[1],gyro_readings[2]); + fprintf(fp, "%f,%d,%d,%d\r\n",temperature,gyro_readings[0],gyro_readings[1],gyro_readings[2]); + } + fclose(fp); + myled = 0; +}