algoritmo logica difusa sensores navegacion
Dependencies: GPS MODI2C SRF05 mbed HMC5883
Sensors/Alt/BMP085.cpp@0:1c15748ff0e1, 2014-07-19 (annotated)
- Committer:
- arturocontreras
- Date:
- Sat Jul 19 05:35:58 2014 +0000
- Revision:
- 0:1c15748ff0e1
logica difusa
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
arturocontreras | 0:1c15748ff0e1 | 1 | #include "BMP085.h" |
arturocontreras | 0:1c15748ff0e1 | 2 | |
arturocontreras | 0:1c15748ff0e1 | 3 | BMP085::BMP085(PinName sda, PinName scl) : I2C_Sensor(sda, scl, BMP085_I2C_ADDRESS) |
arturocontreras | 0:1c15748ff0e1 | 4 | { |
arturocontreras | 0:1c15748ff0e1 | 5 | // initialize BMP085 with settings |
arturocontreras | 0:1c15748ff0e1 | 6 | //writeRegister(0xf4, 0x2e); // TODO: was macht das + register in header! |
arturocontreras | 0:1c15748ff0e1 | 7 | |
arturocontreras | 0:1c15748ff0e1 | 8 | } |
arturocontreras | 0:1c15748ff0e1 | 9 | |
arturocontreras | 0:1c15748ff0e1 | 10 | /*void BMP085::read() |
arturocontreras | 0:1c15748ff0e1 | 11 | { |
arturocontreras | 0:1c15748ff0e1 | 12 | long P, UTemp, UPressure, X1, X2, X3, B3, B5, B6; |
arturocontreras | 0:1c15748ff0e1 | 13 | unsigned long B4, B7; |
arturocontreras | 0:1c15748ff0e1 | 14 | |
arturocontreras | 0:1c15748ff0e1 | 15 | // TODO: writeRegister(0xf4, 0x2e); ?!!! |
arturocontreras | 0:1c15748ff0e1 | 16 | twi_writechar(BMP085_ADRESS, 0xf4, 0x2e); |
arturocontreras | 0:1c15748ff0e1 | 17 | // Wait at least 4.5ms |
arturocontreras | 0:1c15748ff0e1 | 18 | wait(0.005); |
arturocontreras | 0:1c15748ff0e1 | 19 | UTemp = twi_readshort(BMP085_ADRESS, 0xf6); |
arturocontreras | 0:1c15748ff0e1 | 20 | |
arturocontreras | 0:1c15748ff0e1 | 21 | X1 = ((UTemp - AC6) * AC5) >> 15; |
arturocontreras | 0:1c15748ff0e1 | 22 | X2 = (MC << 11) / (X1 + MD); |
arturocontreras | 0:1c15748ff0e1 | 23 | B5 = X1 + X2; |
arturocontreras | 0:1c15748ff0e1 | 24 | Temperature = (float)((B5 + 8) >> 4)/10.0; |
arturocontreras | 0:1c15748ff0e1 | 25 | |
arturocontreras | 0:1c15748ff0e1 | 26 | twi_writechar(BMP085_ADRESS, 0xf4, 0x34 + (oss << 6)); |
arturocontreras | 0:1c15748ff0e1 | 27 | // Wait at least 4.5ms |
arturocontreras | 0:1c15748ff0e1 | 28 | wait(0.005); |
arturocontreras | 0:1c15748ff0e1 | 29 | UPressure = twi_readlong(BMP085_ADRESS, 0xf6) >> (8 - oss); |
arturocontreras | 0:1c15748ff0e1 | 30 | |
arturocontreras | 0:1c15748ff0e1 | 31 | B6 = B5 - 4000; |
arturocontreras | 0:1c15748ff0e1 | 32 | X1 = (B2 * (B6 * B6) >> 12) >> 11; |
arturocontreras | 0:1c15748ff0e1 | 33 | X2 = (AC2 * B6) >> 11; |
arturocontreras | 0:1c15748ff0e1 | 34 | X3 = X1 + X2; |
arturocontreras | 0:1c15748ff0e1 | 35 | B3 = ((AC1 * 4 + X3) << oss) >> 2; |
arturocontreras | 0:1c15748ff0e1 | 36 | |
arturocontreras | 0:1c15748ff0e1 | 37 | X1 = (AC3 * B6) >> 13; |
arturocontreras | 0:1c15748ff0e1 | 38 | X2 = (B1 * (B6 * B6) >> 12) >> 16; |
arturocontreras | 0:1c15748ff0e1 | 39 | X3 = ((X1 + X2) + 2) >> 2; |
arturocontreras | 0:1c15748ff0e1 | 40 | B4 = AC4 * (X3 + 32768) >> 15; |
arturocontreras | 0:1c15748ff0e1 | 41 | |
arturocontreras | 0:1c15748ff0e1 | 42 | B7 = (unsigned long)(UPressure - B3) * (50000 >> oss); |
arturocontreras | 0:1c15748ff0e1 | 43 | |
arturocontreras | 0:1c15748ff0e1 | 44 | if (B7 < 0x80000000) |
arturocontreras | 0:1c15748ff0e1 | 45 | { |
arturocontreras | 0:1c15748ff0e1 | 46 | P = (2 * B7) / B4; |
arturocontreras | 0:1c15748ff0e1 | 47 | } |
arturocontreras | 0:1c15748ff0e1 | 48 | else |
arturocontreras | 0:1c15748ff0e1 | 49 | { |
arturocontreras | 0:1c15748ff0e1 | 50 | P = 2* (B7 / B4); |
arturocontreras | 0:1c15748ff0e1 | 51 | } |
arturocontreras | 0:1c15748ff0e1 | 52 | X1 = (P >> 8) * (P >> 8); |
arturocontreras | 0:1c15748ff0e1 | 53 | X1 = (X1 * 3038) >> 16; |
arturocontreras | 0:1c15748ff0e1 | 54 | X2 = (-7357 * P) >> 16; |
arturocontreras | 0:1c15748ff0e1 | 55 | P = P + ((X1 + X2 + 3791) >> 4); |
arturocontreras | 0:1c15748ff0e1 | 56 | Pressure = (float)P / 100.0; |
arturocontreras | 0:1c15748ff0e1 | 57 | }*/ |