Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented ICM20948 / AK09916 magnetometer driver #9345

Closed
wants to merge 0 commits into from

Conversation

flochir
Copy link
Contributor

@flochir flochir commented Apr 19, 2018

Here's my prototype driver for the ICM20948 IMU on recent Here GNSS devices for review (see issue #8624).
The ICM20948 packages an AK09916 submodule which is also available as a standalone magnetometer, so I wrote the driver for it separately and use it from the ICM20948 driver. It should work with a AK09916 on its own. I might test this at some point.
The ICM20948 driver itself is no CDev yet as it only configures the ICM20948 parent to put through the AK09916 on the I2C bus. The accelerometer and gyro and temperature sensor could be implemented here, though. Would they make sense being mounted on the external GPS?

I will work to improve this. As of now it seems to be running well on my Pixhawk 2.1 + Here GNSS setup, will do a test flight tomorrow. Any hints on style or implementation welcome!

@LorenzMeier
Copy link
Member

What is the difference between the ICM20948 and the MPU9250? The reason I ask is that this looks like a rename / revision of that part and we found that keeping a part family in one driver greatly improves the quality of the driver because incremental fixes are done centrally.

I would assume that minor checks for driver versions would allow to run the same driver against both. Check the MPU6000 driver for an example (its supporting pretty much any of the ICM devices under the sun).

We have in the past had cases where not very well maintained drivers caused significant issues and the more different drivers we have, the more we prime ourselves for it.

@LorenzMeier
Copy link
Member

And many thanks for the hard work on the contribution! I know this must have taken time to write and is much appreciated!

@imcnanie
Copy link
Contributor

Fantastic work!

@flochir
Copy link
Contributor Author

flochir commented Apr 20, 2018

Thanks! I will look into the MPU9250 and MPU6000 drivers and see if I can integrate ICM20948 support. I wasn't aware those supported a range of devices, thanks for the hint!

@flochir
Copy link
Contributor Author

flochir commented Apr 20, 2018

After a quick glance, the AK8963 submodule of MPU9250 seems quite similar to AK09916.
However while the MPU9250 itself seems similar in its function to ICM20948, its register map is quite different, e.g. registers for whoami (0x75 != 0x00) or pin configuration for i2c bypass (0x37 != 0x0F).

Would you say it makes sense to use different register maps in one driver based on device type?

@LorenzMeier
Copy link
Member

@flochir In our experience yes, as the overall logic / operation is the same. You can also think of it in terms of the engineering process: Within Invensense there is also a continuous iteration on the components where they start off with the old design and then change it. So all the tacit knowledge in the driver for the old part usually applies also to the new part.

@flochir
Copy link
Contributor Author

flochir commented Apr 20, 2018

All right, I'll try to come up with an integration into MPU9250.

@copperscopernicus
Copy link

result

Hello, I am trying to read out the values of ICM 20948 using an i2c configurable FTDI cable and Visual Studio. I am reading the output registers directly and the accelerometer, gyro output values look fine with a bit of tolerance but the magnetometer values are weird. Please have a look and shed some light on what might be causing this. Thank you

Regards,
Nike

@flochir
Copy link
Contributor Author

flochir commented Oct 31, 2018

@copperscopernicus you could compare your sensor initialization and readout code to PR #10116, the mag works fine with that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants