Skip to main content
Visitor II
May 25, 2021
Question

How to use reference mode of High Pass filter?

  • May 25, 2021
  • 3 replies
  • 2464 views

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?

    This topic has been closed for replies.

    3 replies

    ST Employee
    May 27, 2021

    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

    Visitor II
    May 28, 2021

    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?

    ST Employee
    May 28, 2021

    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ò

    Visitor II
    September 1, 2021

    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.

    Visitor II
    June 4, 2021

    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?

    ST Employee
    June 4, 2021

    Hi @PD_learner​ ,

    you should read it after configuration

    Niccolò