Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
9 years, 5 months ago.
Incorrect Sensor Data
Hi Chris,
I am using your program.
I am getting the following Values:
ACC: 3909, -3615, 4482 GYRO: 0, -1, -1 Magn: 5888, 5888, 4864
- QUAT_R: 0.891736 -0.225939 -0.357148 0.161875 ACC: 3917, -3618, 4486 GYRO: 0, 0, -1 Magn: 6144, 7168, 4608
- QUAT_R: 0.891764 -0.226022 -0.357009 0.161912 ACC: 3946, -3614, 4475 GYRO: -1, -1, -1 Magn: 6912, 6912, 4352
- QUAT_R: 0.891763 -0.226052 -0.356997 0.161901 ACC: 3944, -3615, 4481 GYRO: 0, -1, -1 Magn: 5888, 6400, 4864
- QUAT_R: 0.891773 -0.225967 -0.357019 0.161918 ACC: 3929, -3615, 4480 GYRO: 0, -1, -1 Magn: 6656, 6144, 5632
- QUAT_R: 0.891776 -0.225780 -0.357156 0.161856
I just wanted to know whether these values are correct (These are values at rest!!!) .
The quaternions seem to be correct, as the teapoint example works. But the other sensor data, shouldnt acc be close to zero?
Could you please help me with this as I am stuck up with understanding this since days
Thanks and Regards, Neil
Hey Neil, It has been a while since I've looked at this code, and you've just reminded me I never did finish the api, getQuat, getAccel ect where supposed to be there. Can you show me how you are decoding the buffer.
posted by Chris Pepper 17 Jun 2015This is the format of the data in the fifo, /* ================================================================================================ *
debug.printf("GYRO: %d, %d, %d\r\n", (int16_t)(((int16_t)buffer[16] << 8) + (int16_t)buffer[17]), (int16_t)(((int16_t)buffer[20] << 8) + (int16_t)buffer[21]), (int16_t)(((int16_t)buffer[24] << 8) + (int16_t)buffer[25]));
debug.printf("Magn: %d, %d, %d\r\n", (int16_t)(buffer[28] << 8) + buffer[29], (int16_t)(buffer[30] << 8) + buffer[31], (int16_t)(buffer[32] << 8) + buffer[33]);
posted by Neil S Carvalho 17 Jun 2015I think for Accx,accy I am supposed to get 0 and around 16300 for the z axis, gyro all 0, no idea for the magnetometer. I am going crazy with this Please help :)
posted by Neil S Carvalho 17 Jun 2015I managed to find my mpu9150 after much digging and the code above does work (it looked right but I thought I'd check) how long and secure are your i2c connections, have you left the i2c at 100khz?
posted by Chris Pepper 17 Jun 2015yes I have kept it the same as 100khz.
Could you please let me know what are the values u get?
The airplane moves okayish in Processing
posted by Neil S Carvalho 17 Jun 2015If you mbed it doing lots, or trying to send data at a low baud rate it may miss data on the i2c bus, but the fact the first half of the packet (the quaternion) is always valid is odd.
accelerometer is set to 4g full scale, gyro 2000 deg/s full scale.
posted by Chris Pepper 17 Jun 2015Hi Chris, I changed the baud rate to 115200.
I get the below which I think is stil wrong for Acceleration and Magn. Gyro seems right I guess any idea why only the accelerometer is having issues? Even the magnetometer keeps varying. I am using a different board NRF51DK. Do you have code to convert these values to their actual values?
- QUAT_R: 0.986836 0.032715 0.035414 -0.154373
ACC: -634, 426, 7945
GYRO: 0, -1, 0
Magn: -6913, 28672, 4608
- QUAT_R: 0.986434 0.033040 0.035943 -0.156730
ACC: -648, 442, 7946
GYRO: -1, -1, 0
Magn: -6913, 29696, 4608
- QUAT_R: 0.986509 0.033956 0.036442 -0.155943
ACC: -663, 423, 7965
GYRO: 1, -2, 0
Magn: -6913, 28160, 5120
- QUAT_R: 0.986175 0.033157 0.036380 -0.158228
ACC: -614, 445, 7922
GYRO: 0, 0, 0
Magn: -6913, 29184, 5120
- QUAT_R: 0.986545 0.034871 0.035305 -0.155780
ACC: -653, 502, 7949
GYRO: -1, -1, -1
Magn: -6401, 29184, 5120
- QUAT_R: 0.986286 0.036978 0.035423 -0.156901
posted by Neil S Carvalho 17 Jun 2015the data values look correct in the last data you posted? to convert you just scale by (full_range / MAX_INT16). so for the accelerometer its full range is set to 4g
Hi Chris
Thanks a lot. These are the values I get now .
ACC: 0.108398, -0.158325, 0.912231 GYRO: 0.000000, -0.061035, 0.000000 Magn: -225.036621, 796.875000, 196.875000
Does this seem ok at rest? I also wanted to know the following: 1) How do I setup Bias for each of them? 2)Also where should I make the changes if I want to set Acc to 2G and Gyro to 250 . I need to use it for human motion so I think lower resolution values should be good enough?
I am really really really thankful for all the help your giving me :) One more thing, the program at time gives zero values for everything, I need to restart the board and then I get proper values, Any idea about this?
Thanks and Regards, Neil
posted by Neil S Carvalho 17 Jun 2015I wrote this library for personal use and never really got to writing a nice api, there are methods in the MPU9150 class ( setGyroFullScaleRange, setAccelFullScaleRange for changing the resolution of the sensors, but I don't know if that effects the DMP firmware that is uploaded (this is what generates the quaternions), and modifying the frequency of the data is even harder, there's a config array in the dmpdata.h file and the last hex value controls the update frequency. looking at the header file for the library is the best way to see whats available I'm afraid.
posted by Chris Pepper 17 Jun 2015also the data looks fine, If the sensor board is perfectly level then there may be an issue with the factory set biasing though. The magnetometer reading is normal but actually getting useful data from it is a bit of hassle.
posted by Chris Pepper 17 Jun 2015Oh, Thanks Chris. Btw could you please let me know how you found out that the resolution for acc and gyro is 4 and 2000?
And How do you increase the speed at which the data is acquired and displayed?
posted by Neil S Carvalho 18 Jun 2015because I set them that way ;) 4g is the default and isn't changed, the gyro is set in the initialiseDMP method in the library. As i mentioned a few comments up changing how the actually DMP chip sends data is messy, the last value of the dmpConfig array in dmpdata.h controls it (there is a comment). As far as I could find when i was porting this library there is no documentation for the DMP in these sensors, the firmware uploaded to it is undocumented and no source is available.
posted by Chris Pepper 18 Jun 2015But even if I try to change the resolution of the two in the above said method it doesn't change :(
It still stuck at 4g and 2000
And the rate of read is just changd by this right:
if(timer.read_ms() > [1000
posted by Neil S Carvalho 18 Jun 2015->this value]){ timer.reset();that line only effects how often data is sent over serial, not the actual sensor update frequency, (see previous comment) I'l look into the range of the sensors not changing but I'm not sure how the DMP firmware effects this, You may be better off using a library that doesn't use the DMP and calculating sensor fusion on the mbed.
posted by Chris Pepper 18 Jun 2015Yes, I actually tried another library but the quaternions generated using madgwick or so are very very different from the quaternions generated by the DMP and do not work with the teapot or any other programs.
Raw Values:
Processed Values:
Quaternions
These are the values I get with the other api located here: https://developer.mbed.org/users/onehorse/code/MPU9150AHRS/
The accel values seem to be okay but the mag and gyro and quaternions do not.
I am so confused what to do :(
posted by Neil S Carvalho 18 Jun 2015Invensense have released a lot more information and source code since I wrote this library (I will have to update it when I'm not so busy (if that ever happens) so i can see now that the DMP needs 4G, 2000Deg/s to work (also it turns out the DMP doesn't even use the magnetometer). I'm not sure why that other library Isn't working properly, the fusion seems wrong but it could just be calibration.
posted by Chris Pepper 18 Jun 2015You mean this:
The embedded Digital Motion Processor (DMP) is located within the MPU-9150 and offloads computation of motion processing algorithms from the host processor. The DMP acquires data from accelerometers, gyroscopes, magnetometers and additional 3rd party sensors such as pressure sensors, and processes the data. The resulting data can be read from the DMP’s registers, or can be buffered in a FIFO. The DMP has access to one of the MPU’s external pins, which can be used for generating interrupts. The purpose of the DMP is to offload both timing requirements and processing power from the host processor. Typically, motion processing algorithms should be run at a high rate, often around 200Hz, in order to provide accurate results with low latency. This is required even if the application updates at a much lower rate; for example, a low power user interface may update as slowly as 5Hz, but the motion processing should still run at 200Hz. The DMP can be used as a tool in order to minimize power, simplify timing, simplify the software architecture, and save valuable MIPS on the host processor for use in the application.
It says here that it generates using all? Could you please let me know which document you are referring to ;)
posted by Neil S Carvalho 18 Jun 2015