NOT FINISHED YET!!! My first try to get a self built fully working Quadrocopter based on an mbed, a self built frame and some other more or less cheap parts.
Sensors/Gyro/L3G4200D.h@34:3aa1cbcde59d, 2013-06-10 (annotated)
- Committer:
- maetugr
- Date:
- Mon Jun 10 13:22:46 2013 +0000
- Revision:
- 34:3aa1cbcde59d
- Child:
- 40:2ca410923691
First version with new ESCs (they are working with the KK Board); some strange kicks in the behaviour of balancing, next step a logger
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
maetugr | 34:3aa1cbcde59d | 1 | // based on http://mbed.org/users/shimniok/code/L3G4200D/ |
maetugr | 34:3aa1cbcde59d | 2 | |
maetugr | 34:3aa1cbcde59d | 3 | #ifndef L3G4200D_H |
maetugr | 34:3aa1cbcde59d | 4 | #define L3G4200D_H |
maetugr | 34:3aa1cbcde59d | 5 | |
maetugr | 34:3aa1cbcde59d | 6 | #include "mbed.h" |
maetugr | 34:3aa1cbcde59d | 7 | #include "I2C_Sensor.h" |
maetugr | 34:3aa1cbcde59d | 8 | |
maetugr | 34:3aa1cbcde59d | 9 | #define L3G4200D_I2C_ADDRESS 0xD0 |
maetugr | 34:3aa1cbcde59d | 10 | |
maetugr | 34:3aa1cbcde59d | 11 | // register addresses |
maetugr | 34:3aa1cbcde59d | 12 | #define L3G4200D_WHO_AM_I 0x0F |
maetugr | 34:3aa1cbcde59d | 13 | |
maetugr | 34:3aa1cbcde59d | 14 | #define L3G4200D_CTRL_REG1 0x20 |
maetugr | 34:3aa1cbcde59d | 15 | #define L3G4200D_CTRL_REG2 0x21 |
maetugr | 34:3aa1cbcde59d | 16 | #define L3G4200D_CTRL_REG3 0x22 |
maetugr | 34:3aa1cbcde59d | 17 | #define L3G4200D_CTRL_REG4 0x23 |
maetugr | 34:3aa1cbcde59d | 18 | #define L3G4200D_CTRL_REG5 0x24 |
maetugr | 34:3aa1cbcde59d | 19 | #define L3G4200D_REFERENCE 0x25 |
maetugr | 34:3aa1cbcde59d | 20 | #define L3G4200D_OUT_TEMP 0x26 |
maetugr | 34:3aa1cbcde59d | 21 | #define L3G4200D_STATUS_REG 0x27 |
maetugr | 34:3aa1cbcde59d | 22 | |
maetugr | 34:3aa1cbcde59d | 23 | #define L3G4200D_OUT_X_L 0x28 |
maetugr | 34:3aa1cbcde59d | 24 | #define L3G4200D_OUT_X_H 0x29 |
maetugr | 34:3aa1cbcde59d | 25 | #define L3G4200D_OUT_Y_L 0x2A |
maetugr | 34:3aa1cbcde59d | 26 | #define L3G4200D_OUT_Y_H 0x2B |
maetugr | 34:3aa1cbcde59d | 27 | #define L3G4200D_OUT_Z_L 0x2C |
maetugr | 34:3aa1cbcde59d | 28 | #define L3G4200D_OUT_Z_H 0x2D |
maetugr | 34:3aa1cbcde59d | 29 | |
maetugr | 34:3aa1cbcde59d | 30 | #define L3G4200D_FIFO_CTRL_REG 0x2E |
maetugr | 34:3aa1cbcde59d | 31 | #define L3G4200D_FIFO_SRC_REG 0x2F |
maetugr | 34:3aa1cbcde59d | 32 | |
maetugr | 34:3aa1cbcde59d | 33 | #define L3G4200D_INT1_CFG 0x30 |
maetugr | 34:3aa1cbcde59d | 34 | #define L3G4200D_INT1_SRC 0x31 |
maetugr | 34:3aa1cbcde59d | 35 | #define L3G4200D_INT1_THS_XH 0x32 |
maetugr | 34:3aa1cbcde59d | 36 | #define L3G4200D_INT1_THS_XL 0x33 |
maetugr | 34:3aa1cbcde59d | 37 | #define L3G4200D_INT1_THS_YH 0x34 |
maetugr | 34:3aa1cbcde59d | 38 | #define L3G4200D_INT1_THS_YL 0x35 |
maetugr | 34:3aa1cbcde59d | 39 | #define L3G4200D_INT1_THS_ZH 0x36 |
maetugr | 34:3aa1cbcde59d | 40 | #define L3G4200D_INT1_THS_ZL 0x37 |
maetugr | 34:3aa1cbcde59d | 41 | #define L3G4200D_INT1_DURATION 0x38 |
maetugr | 34:3aa1cbcde59d | 42 | |
maetugr | 34:3aa1cbcde59d | 43 | class L3G4200D : public I2C_Sensor |
maetugr | 34:3aa1cbcde59d | 44 | { |
maetugr | 34:3aa1cbcde59d | 45 | public: |
maetugr | 34:3aa1cbcde59d | 46 | L3G4200D(PinName sda, PinName scl); // constructor, uses I2C_Sensor class |
maetugr | 34:3aa1cbcde59d | 47 | virtual void read(); // read all axis from register to array data |
maetugr | 34:3aa1cbcde59d | 48 | float offset[3]; // offset that's subtracted from every measurement |
maetugr | 34:3aa1cbcde59d | 49 | void calibrate(int times, float separation_time); // calibration from 'times' measurements with 'separation_time' time between (get an offset while not moving) |
maetugr | 34:3aa1cbcde59d | 50 | int readTemp(); // read temperature from sensor |
maetugr | 34:3aa1cbcde59d | 51 | |
maetugr | 34:3aa1cbcde59d | 52 | private: |
maetugr | 34:3aa1cbcde59d | 53 | virtual void readraw(); |
maetugr | 34:3aa1cbcde59d | 54 | }; |
maetugr | 34:3aa1cbcde59d | 55 | |
maetugr | 34:3aa1cbcde59d | 56 | #endif |