Libraries MEMS STM32F30x

This forum is about you. Feel free to discuss anything is related to embedded and electronics, your awesome projects, your ideas, your announcements, not necessarily related to ChibiOS but to embedded in general. This forum is NOT for support.
User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Libraries MEMS STM32F30x

Postby RoccoMarco » Sun May 26, 2013 8:22 pm

The zip file contains the libraries for the use of MEMS STM32F30x discovery L3GD20 and LSM303DLHC. I hope these files can be useful to someone.
Over time, I will expand as well as improve these libraries.

Regards
Attachments
Libraries MEMS STM32F30x.rar
Libraries for L3GD20 and LSM303DLHC
(11.24 KiB) Downloaded 302 times

User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Re: Libraries MEMS STM32F30x

Postby RoccoMarco » Sat Jun 08, 2013 8:52 pm

ERRATA CORRIGE
there was an error in "lsm303dlhcWriteRegister" when
LSM303DLHC_SAD == LSM303DLHC_SAD_MAGNETOMETER;

line 212 of lsm303dhlc.c changed from

Code: Select all

*message = i2cMasterTransmitTimeout(i2cp, sad & LSM303DLHC_SAD, txbuf, 1, rxbuf, 0, TIME_INFINITE);

to

Code: Select all

*message = i2cMasterTransmitTimeout(i2cp, sad & LSM303DLHC_SAD, txbuf, 2, rxbuf, 0, TIME_INFINITE);


:mrgreen:
Attachments
Libraries MEMS STM32F30x.rar
(11.27 KiB) Downloaded 215 times

User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Re: Libraries MEMS STM32F30x

Postby RoccoMarco » Mon Jun 10, 2013 8:02 am

ERRATA CORRIGE

there was an error in "lsm303dlhcWriteRegister" when
LSM303DLHC_SAD == LSM303DLHC_SAD_MAGNETOMETER;

line 212 of lsm303dhlc.c changed from

Code: Select all

*message = i2cMasterTransmitTimeout(i2cp, sad & LSM303DLHC_SAD, txbuf, 1, rxbuf, 0, TIME_INFINITE);

to

Code: Select all

*message = i2cMasterTransmitTimeout(i2cp, sad & LSM303DLHC_SAD, txbuf, 2, rxbuf, 0, TIME_INFINITE);


there was another error in "lsm303dlhcReadRegister" for msg

lines 95 and 112 of lsm303dhlc.c chenged from

Code: Select all

    if((msg1 != RDY_OK)||(msg2 != RDY_OK)){

to

Code: Select all

    if((msg1 == RDY_OK)&&(msg2 == RDY_OK)){
Attachments
L3GD20 & LSM303DLHC.rar
(11.27 KiB) Downloaded 222 times

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Libraries MEMS STM32F30x

Postby Tectu » Mon Jun 10, 2013 8:04 am

Cool! I assume that this can be helpful for many users. Might I ask why there doesn't seem to be any e-compass support? :P


~ Tectu

User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Re: Libraries MEMS STM32F30x

Postby RoccoMarco » Mon Jun 10, 2013 8:40 am

I'm using these libraries, correcting them and expanding them depending on the things that seem most useful and recurring. What do you intent for e-compass support? Maybe I'll add it. I'm creating an AHRS application (using Madgwick filter) reading data from the MEMS (Gyroscope, Accelerometer and Magnetometer too) periodically and these libraries are essential to what I do. But surely they are very small. Need to be improved.

User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Re: Libraries MEMS STM32F30x

Postby RoccoMarco » Sat Jun 15, 2013 10:44 pm

Hello everyone. It's time for a new release. I've modified l3gd20.h and l3gd20.c adding a new set of function in order to calibrate the gyroscope and to receive a filtered output (removing offset and noise effects on read data). I attach an example too, where I'm using the new set of function. Enjoy :mrgreen:
Attachments
L3GD20 v2.0 + ARMCM4-STM32F303-DISCOVERY-L3GD20.7z
Libraries + a small example
(1.14 MiB) Downloaded 223 times

User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Re: Libraries MEMS STM32F30x

Postby RoccoMarco » Mon Jun 17, 2013 9:29 am

and these are files for an "advanced" use of lsm303dhlc (with a small example), with a full support for accelerometer. As soon as possible I'll add a set of function for magnetometer too. Please report every kind of bug or imperfection using a private message or replying to this post. as always, Enjoy :mrgreen:
Attachments
LSM303DLHC v2.0 + ARMCM4-STM32F303-DISCOVERY-LSM303DLHC.7z
(1.16 MiB) Downloaded 210 times

User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Re: Libraries MEMS STM32F30x

Postby RoccoMarco » Tue Jun 18, 2013 3:12 pm

Hi, i've written a new example for lsm303dlhc.c with a small video that demonstrates in a funny way the good working of app
Video
Attachments
ARMCM4-STM32F303-DISCOVERY-LSM303DLHC-SASA.7z
(1.2 MiB) Downloaded 224 times

User avatar
Tectu
Posts: 1226
Joined: Thu May 10, 2012 9:50 am
Location: Switzerland
Contact:

Re: Libraries MEMS STM32F30x

Postby Tectu » Tue Jun 18, 2013 3:40 pm

Sorry for my late reply.
Thank you for keeping this going. I couldn't take any look yet to be honest. However, I have now attached a 5" touchscreen TFT panel to the F3 discovery board and I hope to get the time one day to create some nasty compass / gyro application.


~ Tectu

User avatar
RoccoMarco
Posts: 635
Joined: Wed Apr 24, 2013 4:11 pm
Location: Salerno (Italy)
Has thanked: 78 times
Been thanked: 60 times
Contact:

Re: Libraries MEMS STM32F30x

Postby RoccoMarco » Tue Jun 18, 2013 10:36 pm

Hi Tectu,
I hope my my work will be useful for your application. In a few week I and a friend of mine will release an lsm303dlhc.c with full support for the magnetometer too. We are looking for a way to calibrate the mag that is easy to use for a final user.


Return to “User Projects”

Who is online

Users browsing this forum: No registered users and 5 guests