Reply To: G measurement - uncorrect values

Home Forums Forums Technical Support for BerryIMU G measurement - uncorrect values Reply To: G measurement - uncorrect values

#5882
Sten-Helge
Participant

According to the datasheet the settings for CTRL_REG2_XM register should be as follows for the different scales;

....
        // Enable accelerometer.
        writeAccReg(CTRL_REG1_XM, 0b01100111); //  z,y,x axis enabled, continuos update,  100Hz data rate
		
        //writeAccReg(CTRL_REG2_XM, 0b00000000); //+/- 2G full scale
        //writeAccReg(CTRL_REG2_XM, 0b00001000); //+/- 4G full scale
        //writeAccReg(CTRL_REG2_XM, 0b00010000); // +/- 6G full scale
        //writeAccReg(CTRL_REG2_XM, 0b00011000); // +/- 8G full scale
        writeAccReg(CTRL_REG2_XM, 0b00100000); // +/- 16G full scale
....
....
	//read ACC values
	readACC(accRaw);
	
	// +/- 2G full scale
	//printf("X = %7.2f G\t" , ((accRaw[0] * 0.061)/1000));
	//printf(" Y =   %7.2f G\t" , ((accRaw[1] * 0.061)/1000));
	//printf(" Z =  %7.2f G\n" , ((accRaw[2] * 0.061)/1000));
	
	// +/- 4G full scale
	//printf("X = %7.2f G\t" , ((accRaw[0] * 0.122)/1000));
	//printf(" Y =   %7.2f G\t" , ((accRaw[1] * 0.122)/1000));
	//printf(" Z =  %7.2f G\n" , ((accRaw[2] * 0.122)/1000));
	
	// +/- 6G full scale
	//printf("X = %7.2f G\t" , ((accRaw[0] * 0.183)/1000));
	//printf(" Y =   %7.2f G\t" , ((accRaw[1] * 0.183)/1000));
	//printf(" Z =  %7.2f G\n" , ((accRaw[2] * 0.183)/1000));	
	
	// +/- 8G full scale
	//printf("X = %7.3f G\t" , ((accRaw[0] * 0.244)/1000));
	//printf(" Y =   %7.3f G\t" , ((accRaw[1] * 0.244)/1000));
	//printf(" Z =  %7.3f G\n" , ((accRaw[2] * 0.244)/1000));	
	
	// +/- 12G full scale
	printf("X = %7.2f G\t" , ((accRaw[0] * 0.732)/1000));
	printf(" Y =   %7.2f G\t" , ((accRaw[1] * 0.732)/1000));
	printf(" Z =  %7.2f G\n" , ((accRaw[2] * 0.732)/1000));	
	
	//printf("Xraw = %d \t" , accRaw[0]);
	//printf(" Yraw =   %d \t" , accRaw[1]);
	//printf(" Zraw =  %d \n" , accRaw[2]);		
....

Please advice if not correct.

Thanks

Blip, blop, bloop...