Grazie delle info.
Ora ho le idee un po' più chiare
Ora ho le idee un po' più chiare
// contribution from opie11 (rc-grooups) // I2C Accelerometer BMA180 // ************************** // I2C adress: 0x80 (8bit) 0x40 (7bit) #if defined(BMA180) static uint8_t rawADC_BMA180[6]; void i2c_ACC_init () { delay(10); i2c_rep_start(0x80+0); // I2C write direction i2c_write(0x0D); // ctrl_reg0 i2c_write(1<<4); // Set bit 4 to 1 to enable writing i2c_rep_start(0x80+0); i2c_write(0x35); // i2c_write(3<<1); // range set to 3. 2730 1G raw data. With /10 divisor on acc_ADC, more in line with other sensors and works with the GUI i2c_rep_start(0x80+0); i2c_write(0x20); // bw_tcs reg: bits 4-7 to set bw i2c_write(0<<4); // bw to 10Hz (low pass filter) acc_1G = 273; acc_25deg = 113; // = acc_1G * sin(25 deg) accPresent = 1; } void i2c_ACC_getADC () { TWBR = ((16000000L / 400000L) - 16) / 2; // Optional line. Sensor is good for it in the spec. i2c_rep_start(0x80); // I2C write direction i2c_write(0x02); // Start multiple read at reg 0x02 acc_x_lsb i2c_rep_start(0x80 +1); // I2C read direction => 1 for(uint8_t i = 0; i < 5; i++) { rawADC_BMA180[i]=i2c_readAck();} rawADC_BMA180[5]= i2c_readNak(); accADC[ROLL] = - (((rawADC_BMA180[1]<<8) | (rawADC_BMA180[0]))>>2)/10; // opie settings: + ; FFIMU: - accADC[PITCH] = - (((rawADC_BMA180[3]<<8) | (rawADC_BMA180[2]))>>2)/10; accADC[YAW] = - (((rawADC_BMA180[5]<<8) | (rawADC_BMA180[4]))>>2)/10; } #endif
// contribution from opie11 (rc-grooups) // I2C Accelerometer BMA180 // ************************** // I2C adress: 0x80 (8bit) 0x40 (7bit) #if defined(BMA180) static uint8_t rawADC_BMA180[6]; void i2c_ACC_init () { delay(10); i2c_rep_start(0x80+0); // I2C write direction i2c_write(0x0D); // ctrl_reg0 i2c_write(1<<4); // Set bit 4 to 1 to enable writing i2c_rep_start(0x80+0); i2c_write(0x35); // i2c_write(3<<1); // range set to 3. 2730 1G raw data. With /10 divisor on acc_ADC, more in line with other sensors and works with the GUI i2c_rep_start(0x80+0); i2c_write(0x20); // bw_tcs reg: bits 4-7 to set bw i2c_write(0<<4); // bw to 10Hz (low pass filter) acc_1G = 273; acc_25deg = 113; // = acc_1G * sin(25 deg) accPresent = 1; } void i2c_ACC_getADC () { TWBR = ((16000000L / 400000L) - 16) / 2; // Optional line. Sensor is good for it in the spec. i2c_rep_start(0x80); // I2C write direction i2c_write(0x02); // Start multiple read at reg 0x02 acc_x_lsb i2c_rep_start(0x80 +1); // I2C read direction => 1 for(uint8_t i = 0; i < 5; i++) { rawADC_BMA180[i]=i2c_readAck();} rawADC_BMA180[5]= i2c_readNak(); accADC[ROLL] = - (((rawADC_BMA180[1]<<8) | (rawADC_BMA180[0]))>>2)/10; // opie settings: + ; FFIMU: - accADC[PITCH] = - (((rawADC_BMA180[3]<<8) | (rawADC_BMA180[2]))>>2)/10; accADC[YAW] = - (((rawADC_BMA180[5]<<8) | (rawADC_BMA180[4]))>>2)/10; } #endif
Commenta