Git Product home page Git Product logo

sparkfun_lsm9ds1_arduino_library's People

Contributors

andreadevo avatar bboyho avatar edspark avatar evancharlton avatar grahldg avatar jackdoan avatar jgromes avatar jonasboss avatar lewispg228 avatar sneakers-the-rat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sparkfun_lsm9ds1_arduino_library's Issues

accelerometer dynamic range

In the sample code (LSM9DS1_Settings for the IMU breakout board LSM9DS1 from sparkfun) the accelerometer dynamic range can be set in the line of code:

imu.settings.accel.scale = 16; // Set accel scale to +/-16g.

when I set the range to 2, 4, or 8 the acceleration measured when the IMU is 'flat' on a given axis the acceleration reads about 1 or - 1 which makes sense as it is being accelerated with 1 G of gravity. When I set it to 16 the acceleration is about 0.68 when exposed to 1 G. My question is does anyone know what is going on? Why is the acceleration not 1?

Can I use this library with the nrf52 SDK?

Hello!
I am using nrf52 sdk and I want to use lsm9ds1 sensor. For that, I would like to test it with a module first.
But this sensor library is dedicated to Arduino. How do I modify it to use it in nrf? Or do other libraries exist for it?

Thank you in advance!

IMU won't initialize

Hi everyone!

I'm using the library you provide here and I have a couple of problems/doubts:

  • I've tested you LSM9DS1_Settings.ino on my Arduino Nano 33 BLE Sense board and it won't get any values from the accelerometer, gyro, magnetometer o thermometer. I've tested it by adding a simple Serial.print in each "if" that checks the availability of the sensor and it won't print anything.
  • Could anyone tell me why the registers WHO_AM_I_AG_RSP + WHO_AM_I_M_RSP have to be equal to WHO_AM_I_XG + WHO_AM_I_M in order to return the value of whoAmICombined variable in the begin() funtion in the SparkFunLSM9DS1.cpp file? The thing is, the first two registers are defined as 0x68 and 0x3D and the other two are 0x0F both so they'll never be equal... What am I doing wrong?

Thanks in advance.

Initializing IMU breaks PWM on raspberry pi

I am working with a Raspberry Pi 3B. I am trying to use this IMU and provided libraries/code in a robot that also utilizes PWM for motor control. I can show (LED+oscilloscope) that the PWM (using wiringPi) works immediately before but not after the following code:

LSM9DS1 imu(IMU_MODE_I2C, 0x6b, 0x1e);

let alone

imu.begin();

If the PWM is connected to PWM0 (either pin), then the measured PWM signals jump all over the place rather than smoothly increasing the duty ratio and then decreasing it multiple times. If the PWM is connected to PWM1, then the PWM signal remains flatlined.

The IMU works fine which is very nice. Thank you!

Similar issue: https://raspberrypi.stackexchange.com/questions/53455/pwm-conflicts-with-i2c

FIFO random issue

Did anyone experience random infinite loop while calibrating?

while (samples < 0x1F)
{
	samples = (xgReadByte(FIFO_SRC) & 0x3F); // Read number of stored samples
}

When this happens the first time (randomly and seldom), the only solution is to disconnect Vcc...

I think it is safe to put a timeout condition to exit the loop.

What do you think?

LSM9DS1 code to measure temperature

Hi! currently im working on a project in which im using LSM9DS1 and according to datasheet LSM9DS1 can be used as "Embedded temperature sensor" so anyone can help me out with the code for measuring the temperature

Interrupt configuration pushPull logic broken

Currently, the interrupt configuration function looks like this:

void LSM9DS1::configInt(interrupt_select interrupt, uint8_t generator,
	                     h_lactive activeLow, pp_od pushPull)
{
	[...]

	if (pushPull) temp &= ~(1<<4);
	else temp |= (1<<4);
	
	[...]
}

with pp_od being declared as

enum pp_od
{
	INT_PUSH_PULL,
	INT_OPEN_DRAIN
};

The LSM9DS1 spec says:

PP_OD   Push-pull/open-drain selection on the INT1_A/G pin and INT2_A/G pin.
        Default value: 0
        (0: push-pull mode; 1: open-drain mode)

So with the current code, if you specify INT_PUSH_PULL (which is 0), it will write 1 into the register and switch to open-drain mode instead.

The parameter should be renamed and the logic swapped to give the correct result.

Fwiw, this means that all uses of interrupts with this library are broken.

I2CreadBytes should return an unsigned int

The function I2CreadBytes returns an unsigned integer, but uses -1 as an error indication.
So the return variable (and probably the input argument count) should be int8 instead.

uint8_t LSM9DS1::I2CreadBytes(uint8_t address, uint8_t subAddress, uint8_t * dest, uint8_t count)

Incorrect temperature sensor readouts

The LSM9DS1::readTemp() doesn't seem to read the correct value from the sensor - it reads either reads 277 or 278 (°C?) all of time.

This is my code (LSM9DS1 is initialized and everything beforehand):

...
// called by Arduino loop()
void IMU::update()
{
  ....
  if (sensor.tempAvailable())
  {
    sensor.readTemp();
  }
}

float IMU::getTemperature()
{
  return sensor.temperature;
}

I'm also using STM32duino on a STM32F4 board but that shouldn't be the issue. Other readouts seem to be correct as well.

cc @Grahldg

Setting functionality does not work

Hi,
first of all I am really glad for your effort and work. As part of my project I am working with the LSM9DS1 to measure frequencies and amplitudes of vibrations and more or less inherited the sensor from a former team member which is why I am not very familiar with it. But to the problem:

I use an Arduino DUE and installed your library which on first glance worked pretty good when executing the example codes. But then I saw that not a single function had an effect on the sensor's settings.

There is no way to change the sampling rates, scales or anything else. I tried to modify the corresponding values in the example codes "Settings" and "Interrupts", but nothing changed.

I hope that I am not abusing this part of your GitHub, but I do not know better where to contact you.

Thanks in advance.
Max

setting the imu settings.accel.scale fails

Using the LSM9DS1_Settings example fails to set the 'settings' values. It appears that the 'begin' function (which is called to apply the settings) is calling the 'init' function. The init function then promptly overwrites the user applied settings with hard coded values.

Warnings in SparkFunLSM9DS1.cpp due to missing return statement

These warnings will stop compilation unless you ignore them in your properties - at least using eclipse IDE with sloeber v4 plugin.

To make it work I needed to add "else return -1/or anything else" for the method in Line 1047 and the following 2 methods.
I don't know why this warning doesn't occur in the other methods as well - as I'm still a student I might not have the knowledge to unterstand why not using a default return statement is useful in this case.

magnetometer measurement results increase temp?

he magnetometer readings after 30-60 minutes begin to trigger false alarms. Magnitude is growing. It looks like the effect of temperature. The test stand is not disturbed by the presence of metals or sensor movement. Only the temperature changes. It doesn't matter if temperature compensation is on or off. Measurements are made every 10 ms. I understand that the results will have some deviations but eventually the value increases. Does the magnetometer need to be calibrated by rotation for such a measurement? The sensor will not be used in vehicles, I only need to measure magnitude. How does temperature compensation work on this sensor?

Error compiling (SPI issue) for nrf52 (nano 33 BLE)

Warning: Board arduino:avr:unoisp doesn't define a 'build.board' preference. Auto-set to: AVR_UNOISP C:\Users\PC-User\Documents\Arduino\libraries\SparkFun_LSM9DS1_IMU\src\SparkFunLSM9DS1.cpp: In member function 'void LSM9DS1::initSPI()': C:\Users\PC-User\Documents\Arduino\libraries\SparkFun_LSM9DS1_IMU\src\SparkFunLSM9DS1.cpp:1141:6: error: 'class arduino::MbedSPI' has no member named 'setClockDivider' SPI.setClockDivider(SPI_CLOCK_DIV2); ^~~~~~~~~~~~~~~ C:\Users\PC-User\Documents\Arduino\libraries\SparkFun_LSM9DS1_IMU\src\SparkFunLSM9DS1.cpp:1141:22: error: 'SPI_CLOCK_DIV2' was not declared in this scope SPI.setClockDivider(SPI_CLOCK_DIV2); ^~~~~~~~~~~~~~ C:\Users\PC-User\Documents\Arduino\libraries\SparkFun_LSM9DS1_IMU\src\SparkFunLSM9DS1.cpp:1141:22: note: suggested alternative: 'NRF_CLOCK_Type' SPI.setClockDivider(SPI_CLOCK_DIV2); ^~~~~~~~~~~~~~ NRF_CLOCK_Type C:\Users\PC-User\Documents\Arduino\libraries\SparkFun_LSM9DS1_IMU\src\SparkFunLSM9DS1.cpp:1143:6: error: 'class arduino::MbedSPI' has no member named 'setBitOrder' SPI.setBitOrder(MSBFIRST); ^~~~~~~~~~~ C:\Users\PC-User\Documents\Arduino\libraries\SparkFun_LSM9DS1_IMU\src\SparkFunLSM9DS1.cpp:1146:6: error: 'class arduino::MbedSPI' has no member named 'setDataMode' SPI.setDataMode(SPI_MODE0); ^~~~~~~~~~~ exit status 1 Error compiling for board Arduino Nano 33 BLE.

Calibration example

How do you use the calibration method? I call the method calibration but there is still offset and drift... anybody have a code example?

Calibration details?

Is there a way to calibrate the magnetometer with this code? Could someone lend me a hand? :)

Code simplification?

In Examples-Basic I found:

if (heading > PI) heading -= (2 * PI);
else if (heading < -PI) heading += (2 * PI);
else if (heading < 0) heading += 2 * PI;

Could these 2 lines:
else if (heading < -PI) heading += (2 * PI);
else if (heading < 0) heading += 2 * PI;

be rewritten as:
else if (heading < 0) heading += (2 * PI);

What if, (by some miracle), (heading == PI) ?

Perhaps that last line could simply be:
else heading += (2 * PI);

No need to wait for data after Wire.requestFrom()

In two places in the source code there is a while-loop with a delay to wait for data after a call to Wire.requestFrom(). That while-loop and that delay is not needed.

When the Wire.requestFrom() functions returns, the I2C transaction has already completely finished and the received data is in the receive buffer in the Wire library.

printAttitude mixes degrees and radians incorrectly

In the example code for I2C (and presumably for SPI, though I didn't look) it incorrectly computes the heading. If my==0, it sets the heading to 180 degrees, then manipulates the heading as if it were in radians instead. To process the following code correctly, it should be set to pi instead.

Temperature sensor read

It does not seam like the correct value is being read from the temperature sensor. The only values i see from it are 256, 512, 768 and 1024. I am using the following lines to read the temperature.

imu.settings.temp.enabled = true;
imu.readTemp();
Serial.print("T: ");
Serial.println(imu.temperature);

new compile error

just download new version and getting buch of

/LSM9DS1_Basic_I2C.ino: In function 'void printMag()':
LSM9DS1_Basic_I2C:197: error: 'Serial' was not declared in this scope
Serial.print("M: ");
^

LSM9DS1_Basic_I2C:244: error: 'Serial' was not declared in this scope
Serial.print("Pitch, Roll: ");
^
exit status 1
'Serial' was not declared in this scope

power consumption

Hi everyone,

I have been playing with LSM9DS1 for quite some time. Now I want to reduce its power consumption.

Currently ardunioClone + LSM9DS1 draws about 60mA. If I disabled gyro, mag and two of the axis of Accelerometer and the current draw has gone down to 35-40mA. On disconnecting the LSM9DS1 from arduino entirely, the same sketch consumes 2-10 mA.

LSM9DS1 should draw typically 4.5mA. Any idea where I am going wrong?

I have connected VDD, GND, SDA, and SCL directly to the same Arduino pins.

Thanks in advance

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.