cancel
Showing results for 
Search instead for 
Did you mean: 

LIS3DH Self Test output change too low

kweikamp
Visitor

Hello,

i am trying to run the self test procedure on the lis3dh according to Application Note 3308 but for some reason the  output change (13 lsb) is below the minimum value listed in the lis3dh (17lsb) .

If i run the procedure multiple times in a row immediately after each other, it only fails the first test consistently. I assume as the test applies a electrostatic test force, the charge somewhat is retained on the sensor for a short time therefore the output change is higher.

The code was run on multiple lis3dh therefore i don't think this is a hardware issue, i also can read the WHOAMI Register just fine.

Here is a sample of my self test implementation:

 

const lis3dh_ctrl_reg2_t ctrl_reg2 = { 0 };
	lis3dh_write_reg(
	    &imu, LIS3DH_CTRL_REG2, (uint8_t *)&ctrl_reg2, sizeof(ctrl_reg2));

	const lis3dh_ctrl_reg3_t ctrl_reg3 = { 0 };
	lis3dh_write_reg(
	    &imu, LIS3DH_CTRL_REG3, (uint8_t *)&ctrl_reg3, sizeof(ctrl_reg3));

	lis3dh_ctrl_reg4_t ctrl_reg4 = { .bdu = 1 };
	lis3dh_write_reg(
	    &imu, LIS3DH_CTRL_REG4, (uint8_t *)&ctrl_reg4, sizeof(ctrl_reg4));

	const lis3dh_ctrl_reg1_t ctrl_reg1 = {
		.xen = 1, .yen = 1, .zen = 1, .odr = 4
	};
	lis3dh_write_reg(
	    &imu, LIS3DH_CTRL_REG1, (uint8_t *)&ctrl_reg1, sizeof(ctrl_reg1));

	/* Wait 90 ms for stable input.*/
	sleep_ms(90);

	lis3dh_dummy_read();

	struct self_test_samples out_nost = { .outx = 0, .outy = 0, .outz = 0 };

	lis3dh_self_test_avg_sample(&out_nost);

	/* Enable self test 0 */
	ctrl_reg4.st = 1;
	lis3dh_write_reg(
	    &imu, LIS3DH_CTRL_REG4, (uint8_t *)&ctrl_reg4, sizeof(ctrl_reg4));
	/* Wait 90 ms for stable input.*/
	sleep_ms(90);

	lis3dh_dummy_read();

	struct self_test_samples out_st = { .outx = 0, .outy = 0, .outz = 0 };

	lis3dh_self_test_avg_sample(&out_st);

	/* Disable self test 0 */
	ctrl_reg4.st = 0;
	lis3dh_write_reg(
	    &imu, LIS3DH_CTRL_REG4, (uint8_t *)&ctrl_reg4, sizeof(ctrl_reg4));

	uint32_t st_out_change_x =
	    abs((int32_t)out_st.outx - (int32_t)out_nost.outx);
	uint32_t st_out_change_y =
	    abs((int32_t)out_st.outy - (int32_t)out_nost.outy);
	uint32_t st_out_change_z =
	    abs((int32_t)out_st.outz - (int32_t)out_nost.outz);

	if (IN_ST_RANGE(st_out_change_x) && IN_ST_RANGE(st_out_change_y)
	    && IN_ST_RANGE(st_out_change_z))
	{
		return true;
	}
	return false;

 

0 REPLIES 0