BMA180 adr. 0x41 from BlazeX

Dependents:   Sensor_test

Committer:
caroe
Date:
Wed May 30 10:43:42 2012 +0000
Revision:
0:6904212fb1d1

        

Who changed what in which revision?

UserRevisionLine numberNew contents of line
caroe 0:6904212fb1d1 1 #pragma once
caroe 0:6904212fb1d1 2
caroe 0:6904212fb1d1 3 //I2C Adresse, entweder 0x40 oder 0x41, abhaengig von Pin VDDIO
caroe 0:6904212fb1d1 4 #define BMA180_ADRESS 0x41
caroe 0:6904212fb1d1 5
caroe 0:6904212fb1d1 6 //Beschleunigung in Meter pro Quadratsekunde umrechnen
caroe 0:6904212fb1d1 7 const float fConvMPSS= 3.4346447e-3;
caroe 0:6904212fb1d1 8
caroe 0:6904212fb1d1 9 class BMA180
caroe 0:6904212fb1d1 10 {
caroe 0:6904212fb1d1 11 private:
caroe 0:6904212fb1d1 12 I2C & I2CBus;
caroe 0:6904212fb1d1 13 Timer & GlobalTime;
caroe 0:6904212fb1d1 14
caroe 0:6904212fb1d1 15 //Offset
caroe 0:6904212fb1d1 16 float Offset[3];
caroe 0:6904212fb1d1 17
caroe 0:6904212fb1d1 18 public:
caroe 0:6904212fb1d1 19 //Beschleunigung auf allen drei Achsen
caroe 0:6904212fb1d1 20 short RawAcc[3]; //Rohdaten
caroe 0:6904212fb1d1 21 float Acc[3]; //kalibrierte Rohdaten in m/s^2
caroe 0:6904212fb1d1 22
caroe 0:6904212fb1d1 23
caroe 0:6904212fb1d1 24 //Initialisieren
caroe 0:6904212fb1d1 25 BMA180(I2C & I2CBus_, Timer & GlobalTime_);
caroe 0:6904212fb1d1 26 void Init();
caroe 0:6904212fb1d1 27
caroe 0:6904212fb1d1 28 private:
caroe 0:6904212fb1d1 29 //Rohdaten lesen
caroe 0:6904212fb1d1 30 void ReadRawData();
caroe 0:6904212fb1d1 31
caroe 0:6904212fb1d1 32 public:
caroe 0:6904212fb1d1 33 //Update-Methode
caroe 0:6904212fb1d1 34 //- Holt aktuelle Daten vom Sensor ab
caroe 0:6904212fb1d1 35 //- Rechnet das Offset hinzu
caroe 0:6904212fb1d1 36 //- Rechnet in andere Einheiten um
caroe 0:6904212fb1d1 37 void Update();
caroe 0:6904212fb1d1 38
caroe 0:6904212fb1d1 39 //Kalibrieren
caroe 0:6904212fb1d1 40 //- pRaw1g: Array short[3] ideale Rohdaten für 1g = ca. {0, 0, -2870}
caroe 0:6904212fb1d1 41 void Calibrate(int ms, const short * pRaw1g);
caroe 0:6904212fb1d1 42 };