Skip to content

LIS3DH accelerometer driver#2296

Merged
PeterKietzmann merged 1 commit intoRIOT-OS:masterfrom
jnohlgard:pr/lis3dh-initial
Jan 20, 2015
Merged

LIS3DH accelerometer driver#2296
PeterKietzmann merged 1 commit intoRIOT-OS:masterfrom
jnohlgard:pr/lis3dh-initial

Conversation

@jnohlgard
Copy link
Copy Markdown
Member

I wrote a driver for the ST Micro LIS3DH accelerometer. It only provides basic functionality of the sensor.
Polling in streaming or FIFO modes. No interrupts (INT1, INT2).

The sensor name is LIS3DH MEMS digital output motion sensor ultra low-power high performance 3-axes "nano" accelerometer

Manufacturer website: http://www.st.com/web/catalog/sense_power/FM89/SC444/PF250725
Data sheet: http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00274221.pdf

I have executed the test application on my Mulle board and it works there.

I based the structure of the driver and the test application on the design of the L3G4200 gyroscope driver.

@jnohlgard jnohlgard added Area: drivers Area: Device drivers Type: new feature The issue requests / The PR implemements a new feature for RIOT labels Jan 13, 2015
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use @name for this and the following group of macros.

@jnohlgard
Copy link
Copy Markdown
Member Author

Updated Doxygen according to comments, replaced disabled spi_acquire_bus->spi_acquire, replaced disabled spi_release->spi_release

@PeterKietzmann
Copy link
Copy Markdown
Member

Nice! Do you know if this is compatible with the LIS302DL or LIS3DSH which are mounted on the stm32f4discovery board?

@jnohlgard
Copy link
Copy Markdown
Member Author

@PeterKietzmann They are similar, but the LIS3DSH has a different response to the WHO_AM_I query.

The basic accelerometer functionality seem the same between the LIS3DH and LIS3DSH, but the LIS3DSH has some different registers for configuration and does not have the extra 3 auxiliary ADC channels on the LIS3DH. The changes seem too large to be easily made compatible, this driver can be used as a base for a future LIS3DSH driver.
The LIS302DL also seem similar, but not the same either.

@haukepetersen
Copy link
Copy Markdown
Contributor

As far as I see it you return raw data when reading the sensor values, right? I would actually vote for returning a physical value (as e.g. mili G). This is what we have done for most the other sensors.

When I use a sensor, even more importantly when I do sensor fusion, that's the values I am interested in and as a user I don't want to read the data sheet to figure out how to translate the raw values...

@jnohlgard jnohlgard added the State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet label Jan 14, 2015
@jnohlgard
Copy link
Copy Markdown
Member Author

@haukepetersen okay, I will add this scaling.

@PeterKietzmann
Copy link
Copy Markdown
Member

ERROR: The following new files generate doxygen warnings:

drivers/include/lis3dh.h

@jnohlgard
Copy link
Copy Markdown
Member Author

@haukepetersen After reading the data sheet again I noticed that it states that the scale is 1 mg per digit at +/- 2G, 2 mg per digit at +/- 4G etc. The values are left-aligned, meaning that we do not need to scale depending on which sensor full scale has been selected (edit: or do we? I need to test this). In ST Application Note AN3308 LIS3DH: MEMS digital output motion sensor
ultra low-power high performance 3-axis “nano” accelerometer
, 3.2.3
Example of acceleration data, Table 6
however, it says that 0x400 equals 1 G and 0xC000 equals -1 G, which would imply that 1 G equals 1024 LSB, not 1000 as the data sheet says.

I do not have the device with me at the moment, I need to do some experiments when I get back in order to verify the correct values, if it is at all noticeable, the difference is pretty small and close to the noise level.

@OlegHahm
Copy link
Copy Markdown
Member

Travis fail is unrelated.

@jnohlgard
Copy link
Copy Markdown
Member Author

Added scaling to milli G.

From my experiments it seems like the scale at 2G setting is such that 1 G is approx 16384, not 16000, so the app note seem correct.

@jnohlgard jnohlgard added CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable and removed State: WIP State: The PR is still work-in-progress and its code is not in its final presentable form yet labels Jan 19, 2015
@PeterKietzmann
Copy link
Copy Markdown
Member

@gebart I have no hardware to test. Anyone has? Everything looks valid to me, in results I think I can trust you. How about squashing?

@jnohlgard
Copy link
Copy Markdown
Member Author

@PeterKietzmann I have refactored to use int16_t scale in the driver struct for caching the scale factor.

Squash and go?

@PeterKietzmann
Copy link
Copy Markdown
Member

Yes looks good. Please squash, then let's see what Travis says.

@jnohlgard jnohlgard removed the CI: needs squashing Commits in this PR need to be squashed; If set, CI systems will mark this PR as unmergable label Jan 20, 2015
LIS3DH MEMS digital output motion sensor ultra low-power high
performance 3-axes "nano" accelerometer

Manufacturer website:

  http://www.st.com/web/catalog/sense_power/FM89/SC444/PF250725

Data sheet:

  http://www.st.com/st-web-ui/static/active/en/resource/technical/document/datasheet/CD00274221.pdf

tests/driver_lis3dh is a simple test application for testing on actual
hardware.

Signed-off-by: Joakim Gebart <joakim.gebart@eistec.se>
@PeterKietzmann
Copy link
Copy Markdown
Member

As nobody has this sensor available I'll trust you that it works:-). Everything looks fine and the unclear points had been discussed. ACK

PeterKietzmann added a commit that referenced this pull request Jan 20, 2015
@PeterKietzmann PeterKietzmann merged commit b02d68e into RIOT-OS:master Jan 20, 2015
@jnohlgard jnohlgard deleted the pr/lis3dh-initial branch February 27, 2015 09:04
@OlegHahm OlegHahm modified the milestone: Release 2015.06 Apr 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: drivers Area: Device drivers Type: new feature The issue requests / The PR implemements a new feature for RIOT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants