An fully working IMU-Filter and Sensor drivers for the 10DOF-Board over I2C. All in one simple class. Include, calibrate sensors, call read, get angles. (3D Visualisation code for Python also included) Sensors: L3G4200D, ADXL345, HMC5883, BMP085

Dependencies:   mbed

main.cpp

Committer:
maetugr
Date:
2013-08-27
Revision:
3:6dbefedce7fe
Parent:
1:798db5deb8b9
Child:
4:f62337b907e5

File content as of revision 3:6dbefedce7fe:

#include "mbed.h"
#include "LED.h"        // LEDs framework for blinking ;)
#include "IMU_10DOF.h"  // Complete IMU class for 10DOF-Board (L3G4200D, ADXL345, HMC5883, BMP085)
#include "PC.h"         // Serial Port via USB by Roland Elmiger for debugging with Terminal (driver needed: https://mbed.org/media/downloads/drivers/mbedWinSerial_16466.exe)

#define RATE            0.002                               // speed of the interrupt for Sensors and PID

LED         LEDs;
PC          pc(USBTX, USBRX, 921600);   // USB
IMU_10DOF   IMU(p28, p27);

Ticker Dutycycler;                      // timecontrolled interrupt for exact timed control loop

void dutycycle() { // method which is called by the Ticker Dutycycler every RATE seconds
    IMU.read();
}

void executer() {
    pc.putc(pc.getc());
    LEDs.tilt(2);
}

int main() {
    Dutycycler.attach(&dutycycle, RATE);     // start to process all RATE seconds
    pc.attach(&executer);
    while(1) {
        // just putting out the angle on console
        pc.printf("%f,%f,%f,%3.5fs,%3.5fs\r\n", IMU.angle[0], IMU.angle[1], IMU.angle[2], IMU.dt, IMU.dt_sensors); // Output for Python
        wait(0.01);

        LEDs.tilt(1);
    }
}