ITG3200 library with multiple configurable full-scale ranges. Based on the Sensor_test by Bo Carøe.
Fork of ITG3200 by
ITG3200.h@1:1208ffc3ace9, 2012-08-15 (annotated)
- Committer:
- cdonate
- Date:
- Wed Aug 15 01:33:01 2012 +0000
- Revision:
- 1:1208ffc3ace9
- Parent:
- 0:a3a0caa8e802
- Child:
- 2:044664f2cc01
Translate comments to english, change full-scale range and convertions values
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
caroe | 0:a3a0caa8e802 | 1 | #pragma once |
caroe | 0:a3a0caa8e802 | 2 | |
cdonate | 1:1208ffc3ace9 | 3 | //I2C address is either 0x68 or 0x69 , depending on pin AD0, check block diagram for your device |
cdonate | 1:1208ffc3ace9 | 4 | #define ITG3200_ADRESS 0x69 |
caroe | 0:a3a0caa8e802 | 5 | |
cdonate | 1:1208ffc3ace9 | 6 | //Convert gyro raw data to radians per second, 1 degree/s = 0,017453293 rad/s. |
cdonate | 1:1208ffc3ace9 | 7 | //The value is 0,017453293/LSB (+- 250 degrees/s) |
cdonate | 1:1208ffc3ace9 | 8 | |
cdonate | 1:1208ffc3ace9 | 9 | //const float fConvRPS= 2.6646248854961832061068702290076e-4; //For +- 500 degrees/s |
cdonate | 1:1208ffc3ace9 | 10 | //const float fConvRPS= 1.2141420883e-3; //For +- 2000 degrees/s |
cdonate | 1:1208ffc3ace9 | 11 | |
cdonate | 1:1208ffc3ace9 | 12 | const float fConvRPS= 1.3323124427480916030534351145038e-4; //For +- 250 degrees/s |
caroe | 0:a3a0caa8e802 | 13 | |
caroe | 0:a3a0caa8e802 | 14 | class ITG3200 { |
caroe | 0:a3a0caa8e802 | 15 | protected: |
caroe | 0:a3a0caa8e802 | 16 | I2C & I2CBus; |
caroe | 0:a3a0caa8e802 | 17 | Timer & GlobalTime; |
caroe | 0:a3a0caa8e802 | 18 | |
caroe | 0:a3a0caa8e802 | 19 | public: |
caroe | 0:a3a0caa8e802 | 20 | //Offset |
caroe | 0:a3a0caa8e802 | 21 | float Offset[3]; |
caroe | 0:a3a0caa8e802 | 22 | |
cdonate | 1:1208ffc3ace9 | 23 | //Rotational speed around all three axes |
cdonate | 1:1208ffc3ace9 | 24 | short RawRate[3]; //Raw data |
cdonate | 1:1208ffc3ace9 | 25 | float Rate[3]; //Calibrated rotation rate in radians per second |
caroe | 0:a3a0caa8e802 | 26 | |
caroe | 0:a3a0caa8e802 | 27 | |
cdonate | 1:1208ffc3ace9 | 28 | //Initialization |
caroe | 0:a3a0caa8e802 | 29 | ITG3200(I2C & I2CBus_, Timer & GlobalTime_); |
caroe | 0:a3a0caa8e802 | 30 | void Init(); |
caroe | 0:a3a0caa8e802 | 31 | |
caroe | 0:a3a0caa8e802 | 32 | |
caroe | 0:a3a0caa8e802 | 33 | private: |
cdonate | 1:1208ffc3ace9 | 34 | //Read raw data |
caroe | 0:a3a0caa8e802 | 35 | void ReadRawData(); |
caroe | 0:a3a0caa8e802 | 36 | |
caroe | 0:a3a0caa8e802 | 37 | public: |
cdonate | 1:1208ffc3ace9 | 38 | //Update Method |
caroe | 0:a3a0caa8e802 | 39 | void Update(); |
cdonate | 1:1208ffc3ace9 | 40 | char getInfo(void); |
caroe | 0:a3a0caa8e802 | 41 | |
cdonate | 1:1208ffc3ace9 | 42 | //Calibration |
caroe | 0:a3a0caa8e802 | 43 | void Calibrate(int ms); |
caroe | 0:a3a0caa8e802 | 44 | }; |