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

Investigate magnetometer readings #16

Open
ron-popov opened this issue Feb 7, 2018 · 16 comments
Open

Investigate magnetometer readings #16

ron-popov opened this issue Feb 7, 2018 · 16 comments
Assignees

Comments

@ron-popov
Copy link
Collaborator

Magnetometer works and all using a raspberry pi and out software module, but the readings are a bit weird.
From looking at them I noticed that they cap at around 10k, It might be a software limitation or maybe the limit of the hardware, further investigation needed.

We also don't know what are the measurement units of the values we read. The values we read are somewhere in the thousands.

@ron-popov ron-popov self-assigned this Feb 7, 2018
@ron-popov
Copy link
Collaborator Author

After some research, i discovered that the range of the magnetometer from -48 gauss to +48 gauss. We also saw that when connecting the magnetometer to the Arduino the reading is measured in milli gauss.
All we have left now is calibrate the readings (at first the magnetometer code had offsets for each of the axes) and fix the python module for correct readings.

@ron-popov
Copy link
Collaborator Author

After some more investigation, we can fairly accurately measure the magnetic field. But we also found out that the reading that the magnetometers give are not synced and each magnetometer gives a different result. Now we need to investigate who is the faulty module and which one gives the correct results.

@yotam180
Copy link
Member

Do you need another magnetometer for this testing purpose? Use them like Artificial Horizon and INU devices are used in airplanes. (See KAL8509)

@yotam180
Copy link
Member

@ron-popov Hey, how are you trying to read the bytes you receive from the i2c connection to the magnetometer? In the official documentation for a plugin I found out they tried to forcibly read it as uint16_t, but in fact the data is stored as float (Single) variable in the registers. May this be the reason you are reading data which does not make sense?

I have just connected the magnetometer and it works great, feeds sensible data and seems close to reality (or at least what my phone compass believes reality is).

@yotam180 yotam180 added the bug label Mar 24, 2018
@ron-popov
Copy link
Collaborator Author

In most of the libraries i saw and used they read 2 adjacent bytes, treated them as a whole number and multiplied them by some constant.

@yotam180 Can you upload a code snippet of what you did ?

@yotam180
Copy link
Member

I used a CPP library to actually read from the i2c port here. They seem to have it working fine.

And I simply just read the data here.

@ron-popov
Copy link
Collaborator Author

This doesn't look any different from the python libraries i used only in arduino, with the only significant difference from one library to another is how that data is being processed and the offset / bias that is applied to it.
If this works fine (constant vector length and the same value as earth's magnetic field) then we could just translate it to python, most of the i2c_write and i2c_read methods already exists, it might be a hassle but it might work while we wait for the good magnetometer.

@yotam180
Copy link
Member

Hmm. Alright. My module is working, so as long as you don't short circuit our magnetometer device I can give it to you.

Are the other magnetometers in the lab? I can test them, now when I know we have a working connection.

@ron-popov
Copy link
Collaborator Author

There is one connected to the raspberry pi zero w, you can disconnect it if you need it.
One died and there should be two more, i remember one of them was a bit tricky and gave us very weird results but test it anyway, it could be just a software issue (it was a long time ago, i don't really remember what i did back then).

Just make sure you restart the software after connecting each unit (to make sure the sensor is properly initialized)

@yotam180
Copy link
Member

Bumping this old thread because we still have to research it 🔢 @ron-popov @shaiTheKimhi

@shaiTheKimhi
Copy link
Contributor

we started making a report on this research, is the code for the magnetometer on the Arduino that we used for the gyro?

@shaiTheKimhi
Copy link
Contributor

I mean the library you used, we already tested Ron's module.

@yotam180
Copy link
Member

Can you please complete the sentence?

"is the code for the magnetometer on the Arduino that we used for the gyro [ complete here ]?"

What about the code for the magnetometer on the Arduino that we used for the gyro?

@shaiTheKimhi
Copy link
Contributor

Is it on the same Arduino?

@yotam180
Copy link
Member

Yes.

@shaiTheKimhi
Copy link
Contributor

OK

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

No branches or pull requests

3 participants