Comments (3)
Can you post more information:
- What version of the library are you using?
- What microcontroller?
- What breakoutboard? Are you using SPI or I2C?
- Post the simplest example code that demonstrates the problem.
from invensense-imu.
Can you post more information:
- What version of the library are you using?
- What microcontroller?
- What breakoutboard? Are you using SPI or I2C?
- Post the simplest example code that demonstrates the problem.
I'm using the following MPU connected to a WeMOS D1 mini through SPI connection.
The following libraries are installed using PIO library manager.
bolderflight/Bolder Flight Systems Eigen@^3.0.0
bolderflight/Bolder Flight Systems Unit Conversions@^4.1.0
bolderflight/Bolder Flight Systems MPU9250@^1.0.2
I uploaded the following code to test readSensor() which is a slightly modified version of the example provided at here:
#include <Arduino.h>
/*
Basic_SPI.ino
Brian R Taylor
[email protected]
Copyright (c) 2017 Bolder Flight Systems
Permission is hereby granted, free of charge, to any person obtaining a copy of this software
and associated documentation files (the "Software"), to deal in the Software without restriction,
including without limitation the rights to use, copy, modify, merge, publish, distribute,
sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or
substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#include "MPU9250.h"
// an MPU9250 object with the MPU-9250 sensor on SPI bus 0 and chip select pin 10
MPU9250 IMU(SPI,16);
int status;
void setup() {
// serial to display data
Serial.begin(115200);
while(!Serial) {}
// start communication with IMU
status = IMU.begin();
if (status < 0) {
Serial.println("IMU initialization unsuccessful");
Serial.println("Check IMU wiring or try cycling power");
Serial.print("Status: ");
Serial.println(status);
while(1) {}
}
IMU.setSrd(9);
}
long time_flag1 = 0;
long time_flag2 = 0;
long time_sum = 0;
float record_counter = 0;
void loop() {
// read the sensor
if(IMU.readSensor())
{
// display the data
IMU.getAccelX_mss();
IMU.getAccelY_mss();
IMU.getAccelZ_mss();
IMU.getGyroX_rads();
IMU.getGyroY_rads();
IMU.getGyroZ_rads();
IMU.getMagX_uT();
IMU.getMagY_uT();
IMU.getMagZ_uT();
IMU.getTemperature_C();
time_flag1 = time_flag2;
time_flag2 = millis();
time_sum += time_flag2 - time_flag1;
record_counter++;
Serial.printf("%f, %f\n", record_counter, time_sum / record_counter);
}
else Serial.println("Data not ready");
//delay(100);
}
Since I'm pretty sure that the loop is running way faster than 100hz, I expected to face "Data not ready" very often on the serial output (considering that setSrd() affect the readSensor()), but not a single such case happended.
Also I've added some variables to determine the frequency of running and this is what I faced after a couple of thousand loop iterations:
.
.
.
46287.000000, 2.070279
46288.000000, 2.070277
46289.000000, 2.070276
46290.000000, 2.070274
46291.000000, 2.070273
46292.000000, 2.070271
46293.000000, 2.070270
The second value supposed to converge to the (1/frequency) milliseconds which in case of srd = 9 means 10 milliseconds but
as I tested it for multiple times using different values for srd, no changes happened.
But the same code except using interrupt instead of loop works fine. (Has the same frequency as intended)
from invensense-imu.
I'm not sure what version fixed it, but the SRD works as expected in the current version of the library, v5.6.0
from invensense-imu.
Related Issues (20)
- No such file or directory #include <cstddef> + a few more imports HOT 1
- Latest version of the library is not available in PlatformIO library registry. HOT 1
- Glitches on Gyro data HOT 8
- Unable to reach magnetometer module in mpu9250 while using Teensy4.0 HOT 1
- SPI communication with teensy 4.1 is not working HOT 18
- cstddef: No such file or directory HOT 1
- cstddef & cstdint? HOT 1
- Set SPI clock speed HOT 1
- Why inverted axis for gyro and accelerometer HOT 5
- Esp32, Arduino how do I know the correct angle of the device? HOT 1
- Incompatible with AVR architecture ? HOT 3
- Compiling IDE 2.0 and arduino nano 33 iot HOT 2
- how can i get the cstddef HOT 2
- calibration HOT 1
- status -5 HOT 4
- Can't initialize I2C/SPI bus HOT 12
- X and Y axis accelerometer readings are swapped. HOT 1
- assert failed: i2c_ll_set_bus_timing i2c_ll.h:109 (scl_high > 13) HOT 5
- Please fix 1.0.2 release HOT 5
- Compilation Error on Arduino-Esp32 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from invensense-imu.