A class to receive data from the SparkFun 9DOF Razor IMU. It can be easily adapted to work with IMUs with different data formats.

Dependencies:   mbed

Committer:
avbotz
Date:
Sat Nov 05 01:02:59 2011 +0000
Revision:
3:f04d3d10d518
Parent:
2:d8b182fbe018
Added code for finding the average sensor values (for calibration). Problems: Average includes garbage data. We know when theres an IMU error, but Im not sure the best way to prevent parsing.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
avbotz 2:d8b182fbe018 1 #pragma once
avbotz 2:d8b182fbe018 2
avbotz 2:d8b182fbe018 3 #include "mbed.h"
avbotz 2:d8b182fbe018 4
avbotz 2:d8b182fbe018 5 Serial PC(USBTX, USBRX);
avbotz 2:d8b182fbe018 6
avbotz 2:d8b182fbe018 7 DigitalOut myled1(LED1);
avbotz 2:d8b182fbe018 8 DigitalOut myled2(LED2);
avbotz 2:d8b182fbe018 9 DigitalOut myled3(LED3);
avbotz 2:d8b182fbe018 10 DigitalOut myled4(LED4);
avbotz 2:d8b182fbe018 11
avbotz 2:d8b182fbe018 12 class IMU{
avbotz 2:d8b182fbe018 13 public:
avbotz 2:d8b182fbe018 14 IMU(int baud, PinName tx, PinName rx, Serial* pc);
avbotz 2:d8b182fbe018 15 ~IMU();
avbotz 2:d8b182fbe018 16
avbotz 2:d8b182fbe018 17 void getData();
avbotz 2:d8b182fbe018 18 void attach(void (*fptr)(void));
avbotz 2:d8b182fbe018 19 void putc(char c);
avbotz 2:d8b182fbe018 20 //void readIMU();
avbotz 2:d8b182fbe018 21 short accX, accY, accZ, gyrX, gyrY, gyrZ, magX, magY, magZ;
avbotz 2:d8b182fbe018 22 bool readable;
avbotz 3:f04d3d10d518 23 bool newData;
avbotz 2:d8b182fbe018 24
avbotz 2:d8b182fbe018 25 private:
avbotz 2:d8b182fbe018 26 Serial* p_device;
avbotz 2:d8b182fbe018 27 Serial* p_pc;
avbotz 2:d8b182fbe018 28 inline void makeCorrect(short* i);
avbotz 2:d8b182fbe018 29 void parse();
avbotz 2:d8b182fbe018 30
avbotz 2:d8b182fbe018 31 int i_IMU;
avbotz 2:d8b182fbe018 32 char bufIMU[21];
avbotz 2:d8b182fbe018 33 } imu(57600, p9, p10, &PC);
avbotz 2:d8b182fbe018 34
avbotz 2:d8b182fbe018 35 void readIMU();