Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIS3DH_DATARATE_LOWPOWER_5KHZ mode is not setting the accelerometer in 5kHz low power mode but in 1.344 kHz High resolution mode #14

Closed
nalexopo opened this issue Jun 1, 2018 · 12 comments
Assignees

Comments

@nalexopo
Copy link

nalexopo commented Jun 1, 2018

lis.setDataRate(LIS3DH_DATARATE_LOWPOWER_5KHZ);

Above code is not setting the accelerometer in 5kHz mode but in 1.344 kHz High resolution mode. I read the LIS3DH_REG_CTRL1 register and i get a value b'1001 0111. It should be b'1001 1111 for 5kHz low power mode and the HR bit in LIS3DH_REG_CTRL4 should be 0. Read Lis3dh datasheet in page 35/54.

@erichiggins
Copy link

I was looking into setting a faster data rate in my sketch and came across this reported issue. I haven't tried implementing it yet, but I wanted to share some additional information from the docs in case it helps anyone to confirm (and/or fix) the issue reported above.

Based on what I've read and the information below, I believe the following code is needed to use low-power (5khz) mode. Please double-check before trying it for yourself.

// Enable all axes, low-power mode
writeRegister8(LIS3DH_REG_CTRL1, 0xf);
// 5khz data rate
setDataRate(LIS3DH_DATARATE_LOWPOWER_5KHZ);
// High res off,  BDU enabled
writeRegister8(LIS3DH_REG_CTRL4, 0x80);

Datasheet info

The following is taken directly from page 9 of the Application Note.

Referring to the LIS3DH datasheet, output data rate (ODR) and low power enable (LPen)
bits of CTRL_REG1 and HR bits of CTRL_REG4 are used to select the operating modes
(power-down mode, normal mode and low power mode) and output data rate (Table 2 and
Table 3).

Table 2. Operating mode selection

Operating mode CTRL_REG1[3] (LPen bit) CTRL_REG4[3] (HR bit) BW [Hz] Turn-on time [ms]
Low power mode 1 0 ODR/2 1
Normal mode 0 1 ODR/9 7/ODR

Table 3. Data rate configuration

ODR3 ODR2 ODR1 ODR0 Power mode selection
0 0 0 0 Power-down mode
0 0 0 1 Normal/low power mode (1 Hz)
0 0 1 0 Normal/low power mode (10 Hz)
0 0 1 1 Normal/low power mode (25 Hz)
0 1 0 0 Normal/low power mode (50 Hz)
0 1 0 1 Normal/low power mode (100 Hz)
0 1 1 0 Normal/low power mode (200 Hz)
0 1 1 1 Normal/low power mode (400 Hz)
1 0 0 0 Low power mode (1.5 kHz)
1 0 0 1 Normal (1.250 kHz)/low power mode (5 kHz)

I believe these correlate to the these data rate options in Adafruit_LIS3DH.h.

References

@erichiggins
Copy link

@ladyada Is this repo still being maintained? There are several open PRs and Issues, like this one, which have not had responses.

@nalexopo
Copy link
Author

nalexopo commented Sep 11, 2018

@erichiggins

Some suggestions from my part as I just saw that you replied.

  1. Don't use the datasheet from adafruit site but rather the one from ST site because it has been revised a few times from the 2010 version your link leads to. This is the 2016 version you can see some differences in the ODR that's why i am talking about 1.344 kHz and not 1.250 kHz.

Here the December 2016 version which is the current version.
https://www.st.com/resource/en/datasheet/lis3dh.pdf

  1. If you are planning on going full speed on this sensor have a look on the application note page 9/59
    you may be limited by bandwidth limitations when using HR mode.

https://www.st.com/content/ccc/resource/technical/document/application_note/77/ed/e7/e1/28/5a/45/d6/CD00290365.pdf/files/CD00290365.pdf/jcr:content/translations/en.CD00290365.pdf

@hakeemta
Copy link

hakeemta commented Oct 9, 2018

HR bit in LIS3DH_REG_CTRL5

HR bit is in LIS3DH_REG_CTRL4

@T-Mosher
Copy link

Note, same issue raised via this forum thread:
https://forums.adafruit.com/viewtopic.php?t=211362

Is this issue pending a resolution, stuck, or merely forgotten?

@tyeth
Copy link
Contributor

tyeth commented Jun 17, 2024

Hardware arriving on Wednesday, so I'll have a look + test then

@tyeth
Copy link
Contributor

tyeth commented Jul 1, 2024

Hey @nalexopo @erichiggins @hakeemta @T-Mosher, there is a PR in to add the functionality, see #50 , it would be really appreciated if you folks could give it a thorough testing!

There is a new constructor argument (frequency - last arg for SPI overloads, defaulting to 500kHz) to allow raising the SPI frequency as needed for the 5KHz rate. I went up to 2MHz.
There is a new method for setPerformanceMode to allow selecting low power / normal / high resolution modes

@T-Mosher
Copy link

T-Mosher commented Jul 1, 2024

Sorry, can't test it, don't have the hardware.

@tyeth
Copy link
Contributor

tyeth commented Jul 8, 2024

@nalexopo @erichiggins @hakeemta final testing reminder prod ☝️ before I merge it tomorrow and release anyway. We can always fix it afterwards.

@erichiggins
Copy link

I'm currently traveling and unable to test this

@tyeth
Copy link
Contributor

tyeth commented Jul 8, 2024 via email

@tyeth tyeth closed this as completed in a07a936 Jul 16, 2024
@tyeth
Copy link
Contributor

tyeth commented Jul 16, 2024

Please feel free to reopen or create a new issue if there are any problems with the release (1.3.0).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants