2021-05-25 01:24 AM
Hi, I am using the lis2dh12 accelerometer and I read the applications note and the datasheet, but after that, I'm still not understanding how to use the high pass filter. I want to use a high pass filter in reference mode.
For reference mode as per my understanding, the output data is calculated as the difference between the input acceleration and the content of REFERENCE (26h). The content of REFERENCE (26h) is set per selected G-scale.
I want to know how to use the filter in reference mode? Can I change the content of REFERENCE (26h)? Whether its content fixed as per the data sheet?
2021-05-27 03:56 AM
Hi @PD_learner ,
if you want to use the HP filter you have to enable it.
once enabled, the output will be subtracted from REFERENCE value and then you can set your interrupt accordingly.
hope this helps
Niccolò
p.s. if you found a solution to your problem, please, select a best answer to help other users with similar issues
2021-05-28 06:59 AM
Hi Niccolo,
I have enabled HP filter in reference mode as follows
spi_write_reg(LIS2DH_CTRL_REG2, 0x48); // High-pass filter (HPF) enabled
spi_write_reg(LIS2DH_CTRL_REG4, 0x80); //BDU on, 2g,
What will be the reference value?
Can I change the content of REFERENCE (26h)? if yes how do this? can you give me an example?
2021-05-28 08:32 AM
Hi @PD_learner ,
the value of REFERENCE(26h) depends on what you want to use as reference.
it is a 2’s complement value and the value of its LSB depends on the Full Scale (you can see the values in table 12, page 19 of the application note).
If you want to select a "reference position" of your sensor, I would suggest to use the HP filter in normal mode (spi_write_reg(LIS2DH_CTRL_REG2, 0x08); // High-pass filter (HPF) enabled ), and read the REFERENCE register to reset the reference state.
you can refer to section 4.3.1 of the AN to check the options.
Niccolò
2021-06-04 12:55 AM
Hi Niccolo,
The purpose of using the Hp filter in reference mode is as follows.
I need only pure acceleration values in all directions. So at any state, if the device is stable (or at a constant speed), it should give (0.0,0.0,0.0) roughly
But didn't get (0,0,0) when the device is in a stable position.
read the REFERENCE register to reset the reference state.
=> Where to read the REFERENCE register? Before the reading output register or after configurations?
2021-06-04 03:52 AM
Hi @PD_learner ,
you should read it after configuration
Niccolò
2021-09-01 06:07 AM
I have used the following configuration and kept the device in a stable horizontal position.
spi_write_reg(LIS2DH_CTRL_REG1, 0x07); // Enable Low Power Mode and X,Y,Z Axis
spi_write_reg(LIS2DH_CTRL_REG2, 0x08); // High-pass filter (HPF) enabled
spi_write_reg(LIS2DH_CTRL_REG5, 0x00); // Disable Latch
spi_write_reg(LIS2DH_CTRL_REG4, 0X80); //BDU on, 2g, hr off
spi_write_reg(LIS2DH_CTRL_REG3, 0X50); // Enable DataReadyInterrupt
spi_write_reg(LIS2DH_CTRL_REG6, 0X00); //clear all
spi_write_reg(LIS2DH_CTRL_REG1, 0X97); // Turn on the sensor, enable: NORMAL
// power Mode, X, Y, and Z // ODR =1344 Hz
I got a raw value between -6 to 6. Is this normal behavior? Can I subtract these values to get (0,0,0) on all axis?
pls, do needful.
2021-09-02 12:15 AM
yes,
try it and let me know if it works
Niccolò