algoritmo logica difusa sensores navegacion

Dependencies:   GPS MODI2C SRF05 mbed HMC5883

Committer:
arturocontreras
Date:
Sat Jul 19 05:35:58 2014 +0000
Revision:
0:1c15748ff0e1
logica difusa

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arturocontreras 0:1c15748ff0e1 1 // based on http://mbed.org/users/Digixx/code/ADXL345/
arturocontreras 0:1c15748ff0e1 2
arturocontreras 0:1c15748ff0e1 3 #ifndef ADXL345_H
arturocontreras 0:1c15748ff0e1 4 #define ADXL345_H
arturocontreras 0:1c15748ff0e1 5
arturocontreras 0:1c15748ff0e1 6 #include "mbed.h"
arturocontreras 0:1c15748ff0e1 7 #include "I2C_Sensor.h"
arturocontreras 0:1c15748ff0e1 8
arturocontreras 0:1c15748ff0e1 9 #define ADXL345_I2C_ADDRESS 0xA6
arturocontreras 0:1c15748ff0e1 10 //the ADXL345 7-bit address is 0x53 when ALT ADDRESS is low as it is on the sparkfun chip: when ALT ADDRESS is high the address is 0x1D
arturocontreras 0:1c15748ff0e1 11 //when ALT ADDRESS pin is high:
arturocontreras 0:1c15748ff0e1 12 //#define ADXL345_I2C_ADDRESS 0x3A
arturocontreras 0:1c15748ff0e1 13
arturocontreras 0:1c15748ff0e1 14 // register addresses
arturocontreras 0:1c15748ff0e1 15 #define ADXL345_DEVID_REG 0x00
arturocontreras 0:1c15748ff0e1 16 #define ADXL345_THRESH_TAP_REG 0x1D
arturocontreras 0:1c15748ff0e1 17 #define ADXL345_OFSX_REG 0x1E
arturocontreras 0:1c15748ff0e1 18 #define ADXL345_OFSY_REG 0x1F
arturocontreras 0:1c15748ff0e1 19 #define ADXL345_OFSZ_REG 0x20
arturocontreras 0:1c15748ff0e1 20 #define ADXL345_DUR_REG 0x21
arturocontreras 0:1c15748ff0e1 21 #define ADXL345_LATENT_REG 0x22
arturocontreras 0:1c15748ff0e1 22 #define ADXL345_WINDOW_REG 0x23
arturocontreras 0:1c15748ff0e1 23 #define ADXL345_THRESH_ACT_REG 0x24
arturocontreras 0:1c15748ff0e1 24 #define ADXL345_THRESH_INACT_REG 0x25
arturocontreras 0:1c15748ff0e1 25 #define ADXL345_TIME_INACT_REG 0x26
arturocontreras 0:1c15748ff0e1 26 #define ADXL345_ACT_INACT_CTL_REG 0x27
arturocontreras 0:1c15748ff0e1 27 #define ADXL345_THRESH_FF_REG 0x28
arturocontreras 0:1c15748ff0e1 28 #define ADXL345_TIME_FF_REG 0x29
arturocontreras 0:1c15748ff0e1 29 #define ADXL345_TAP_AXES_REG 0x2A
arturocontreras 0:1c15748ff0e1 30 #define ADXL345_ACT_TAP_STATUS_REG 0x2B
arturocontreras 0:1c15748ff0e1 31 #define ADXL345_BW_RATE_REG 0x2C
arturocontreras 0:1c15748ff0e1 32 #define ADXL345_POWER_CTL_REG 0x2D
arturocontreras 0:1c15748ff0e1 33 #define ADXL345_INT_ENABLE_REG 0x2E
arturocontreras 0:1c15748ff0e1 34 #define ADXL345_INT_MAP_REG 0x2F
arturocontreras 0:1c15748ff0e1 35 #define ADXL345_INT_SOURCE_REG 0x30
arturocontreras 0:1c15748ff0e1 36 #define ADXL345_DATA_FORMAT_REG 0x31
arturocontreras 0:1c15748ff0e1 37 #define ADXL345_DATAX0_REG 0x32
arturocontreras 0:1c15748ff0e1 38 #define ADXL345_DATAX1_REG 0x33
arturocontreras 0:1c15748ff0e1 39 #define ADXL345_DATAY0_REG 0x34
arturocontreras 0:1c15748ff0e1 40 #define ADXL345_DATAY1_REG 0x35
arturocontreras 0:1c15748ff0e1 41 #define ADXL345_DATAZ0_REG 0x36
arturocontreras 0:1c15748ff0e1 42 #define ADXL345_DATAZ1_REG 0x37
arturocontreras 0:1c15748ff0e1 43 #define ADXL345_FIFO_CTL 0x38
arturocontreras 0:1c15748ff0e1 44 #define ADXL345_FIFO_STATUS 0x39
arturocontreras 0:1c15748ff0e1 45
arturocontreras 0:1c15748ff0e1 46 #define ADXL345_X 0x00
arturocontreras 0:1c15748ff0e1 47 #define ADXL345_Y 0x01
arturocontreras 0:1c15748ff0e1 48 #define ADXL345_Z 0x02
arturocontreras 0:1c15748ff0e1 49
arturocontreras 0:1c15748ff0e1 50 typedef char byte;
arturocontreras 0:1c15748ff0e1 51
arturocontreras 0:1c15748ff0e1 52 class ADXL345 : public I2C_Sensor
arturocontreras 0:1c15748ff0e1 53 {
arturocontreras 0:1c15748ff0e1 54 public:
arturocontreras 0:1c15748ff0e1 55 ADXL345(PinName sda, PinName scl); // constructor, uses I2C_Sensor class
arturocontreras 0:1c15748ff0e1 56 virtual void read(); // read all axis to array
arturocontreras 0:1c15748ff0e1 57
arturocontreras 0:1c15748ff0e1 58 float offset[3]; // offset that's subtracted from every measurement
arturocontreras 0:1c15748ff0e1 59 void calibrate(int times, float separation_time); // calibration from 'times' measurements with 'separation_time' time between (get an offset while not moving)
arturocontreras 0:1c15748ff0e1 60
arturocontreras 0:1c15748ff0e1 61 private:
arturocontreras 0:1c15748ff0e1 62 virtual void readraw();
arturocontreras 0:1c15748ff0e1 63 };
arturocontreras 0:1c15748ff0e1 64
arturocontreras 0:1c15748ff0e1 65 #endif