I want to enable the built-in high-pass filter in the LSM303DHLC accelerometer. The register that is responsible for doing this is called CTRL_REG2_A (0x21). From the datasheet, the information on this register is on page 26:
st.com/web/en/resource/techn … 027543.pdf
What I want to know is what should I do to change this register so that i can enable the high-pass filter? Also , i would like it to have a cutoff frequency of 1 Hz, is it possible to set that in the register?
FYI: I am using the LSM303DHLC to measure arm steadiness for post-stroke patients. I need the high-pass filter to filter out 1 Hz so as to compensate for drift (for eg when someone is simply picking up the tube i have placed the accelerometer sensor in).
Thanks in advance!
The LSM303DLHC datasheet seems to be missing the table that describes the High-pass filter cutoff frequency configuration bits (HPCF2 and HPCF1). We noticed that the datasheet for the LSM303DLM, which is an older version of that chip, has a table that explains how to achieve certain cutoff frequencies for a given data rate. You might try using that to see if it works. (If so, it looks like you can set a 1Hz cutoff frequency for data rates of 50Hz, 100Hz, and 400Hz.)
By the way, your application sounds awesome!
Thanks a lot Jon!
So, assuming the bits i want for HPCF1 and HPCF0 is 0 and 1, then how do i change the register? Do I just simply store a new hex value for CTRL_REG2_A in the sketch? (I think i forgot to mention I’m using Arduino Uno)
I also don’t really understand (Table 23. High pass filter mode configuration). All I want is for the hpf to remain on permanently.
If you are using our LSM303 library, you can use the writeAccReg() function to sets all of the bits in the CTRL_REG2_A register for the kind of behavior you want.
I am also not entirely sure which bits enable the High-pass filter mode configuration. (We do not have any additional information for this kind of sensor besides what is in the datasheet.) You might try setting the HPCF bits to what you think would work and then test different variations of HPM bits to see which one produces the results you expect.
Yes I’m using the LSM303 library, thanks for the info.
Also, from the LSM303DLM datasheet (the table 3 in pg 25), how do I know what is the data rate in Hz that the chip is sending out? Is this related to the baud rate i set in my sketch (which is 9600)?
Also, I tried to set the bits in that register address, but I couldn’t.
I used the Serial example code to test out, and i added in the line:
after the line compass.enableDefault(); in the setup() function.
The compiler says ‘CTRL_REG2_A’ was not declared in this scope, which puzzles me. The LSM303.h file has already been included. Did I leave out anything?
Our LSM303 library sets the output data rate to 50Hz, but you can select a different rate by changing the DR1 and DR0 bits of the CTRL_REG1_A register.
CTRL_REG2_A is defined as an enumerated value in the scope of the LSM303 class, so you will have to modify your code to reflect that. For example, this should work: