Hi I'm using this configuration below, I 'm using bma_456_t bma = {
.power_save = APS_ON,
.fifo_wkp = FSW_ON,
.acc_enable = ACC_ON,
.aux_enable = MAG_OFF,
.acc_perf_mode = CIC_AVG,
.acc_odr = ODR_6P25,
.acc_bwp = RES_AVG128,
.acc_range = RANGE_4G};
config_remote_init(bma); for (int i = 0; i < 8 i++)
{
status = read_sensor_data(REG_ACCS_DATA, &sensor_data); // REGS 0X12
acc_x = (sensor_data[0] + (sensor_data[1] << 8)); // X (MSB|LSB)
acc_y = (sensor_data[2] + (sensor_data[3] << 8)); // Y (MSB|LSB)
acc_z = (sensor_data[4] + (sensor_data[5] << 8)); // Z (MSB|LSB)
}
aux_x = (float)acc_x / 100;
aux_y = (float)acc_y / 100;
aux_z = (float)acc_z / 100;
roll = atan2(aux_y, aux_z) * 57.3; // angulo x
pitch = atan2((-aux_x), sqrt(aux_y * aux_y + aux_z * aux_z)) * 57.3; // angulo y
I'm getting the acc (x,y,z) in register 0X12 to then calculate my angles, I 'm using it to see the inclination of trucks, but because of the motor vibration the values is being crazy vary up to a degree, so to exemplificate : The inclination is 4.2º, but because the of the vibration the read values goes to 4.9 º, 5.2º, 5.1º, 4.8º, I need clean the vibration noise.
... View more