Notifications
Clear all

BN-880 Compass Calibration

30 Posts
3 Users
2 Likes
3,680 Views
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 168
Topic starter  

Looking for some guidance on calibrating the compass that is included in the BN-880.  Here is a picture of the vehicle I am using.  The BN-880 is on a pole approximately 7 inches about the micro controller.

IMG 0834

I followed the instructions in Bill's GPS video and loaded the Adafruit HMC5883L Library and ran the only example sketch available called magsensor (I did calculate my Declination Angle and added the values to the sketch).  I used my cell phone compass and aligned the vehicle to 0 degrees.  I compared the sketch output to the compass on my phone and there was a significant difference.

 Here is the sketch output and a picture of the vehicle and cell phone compass.  Heading = 4.68 and Degrees = 268 ish (would love to understand the difference between heading and degrees).

  

magsensor Output

 

image0

 I downloaded the Arduino-HMC5883L-master library and ran the HMC5883L_calibrate sketch which gave me the x-offset of 14 and a y-offset of -174.  I added those values into the HMC5883L_compass sketch and this was the serial monitor output.  The output is the same as the magsensor sketch at 268.

HMC5883L compass output

I would expect the BN-880 compass to read the same as my cell phone compass.  Are there any recommendations as far as a next step?  Are there other calibration sketches I should run?  Did i miss (screw-up) something?

Thanks!


   
Quote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

I would not expect a cell phone compass to be very accurate at least until it was calibrated and even then I would be happy with +- 20 degrees. Bearing is relative to something, degrees in your case is the magnetic compass reading.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 168
Topic starter  

@ronalex4203 

Good point on the phone.  I checked using a real compass, and it read 10 degrees versus o.  The phone was off 10 degrees, but that means the BN-880 is off approximately 100 degrees.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@huckohio I did a search and found the following, is this of any help?

Screen Shot 2021 11 07 at 05.41.23

This is probably what you want https://github.com/iNavFlight/inav/wiki/GPS--and-Compass-setup

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 168
Topic starter  

@ronalex4203 

Thank you for the reply.  I read the iNavFlight wiki and checked the readings with a compass at the cardinal points.  This is what the BN-880 reported:

Cardinal point = N   BN-880 reading = 287 (should be 0/360, difference of 73 degrees)

Cardinal point = E   BN-880 reading = 168 (difference of 78 degrees)

Cardinal point = S   BN-880 reading = 85 (difference of 95 degrees)

Cardinal point = W   BN-880 reading = 5 (difference of 95 degrees)

It's strange that the variance between N & E is almost the same and that the variance between S & W is the same.  Not sure I can derive any meaning from these results.  As I continued to read the wiki, it seems that the adjustments they mention are made within the iNavFlight program.  

Would it matter that I am taking these readings in the basement?  The vehicle is approximately 17 inches away from my LED monitor.  No other powered devices are near the vehicle.  Not sure what to make of the difference in readings from N/E and S/W.

Mike

 


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 168
Topic starter  

@ronalex4203 

Are you familiar with Flight Controllers?  I was reading the iNavFlight GitHub readme, and it claims that iNavFlight is a "fully configurable mixer that allows to run any hardware you want: multirotor, fixed wing, rovers, boats and other experimental devices."  It sounds like I could use a flight controller in a ground vehicle.  Did I read that correctly?


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@huckohio I think there are 2 explanations but they really don't matter. First, is this a 1%, 5%, 10%, 20% accurate device? Your readings for 0 is 5, for 90 is 85, for 180 is 168, for 270 is 287. All of those are inside the 10% or silver tolerance. I can't visualize your test setup, the position and distance away your house basement main steel support beam may be or any one of a myriad of magnetic disturbances. If it was me, get the calibration done so the readings as they are agree with the correct cardinals, ie N is close to 0. I am sure S will be then ok, but you may need to flip E & W. The link I posted above will help.

Use google to determine your local magnetic deviation, that can be a lot more than you might imagine. Also make sure it is current as the N mag pole is galloping towards Siberia. Where I live on Vancouver Island the  magnetic declination is +16 degrees 11 minutes in other words East of true north try entering your location in the following web site https://www.magnetic-declination.com.

I have a handful of those BN-880 modules, if I have some time I will see if I can quickly hook one up to see what readings I get.

 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@huckohio Sorry, I do not know that field. I have some level of interest and was given one decades ago, but the legal requirements were more than I wanted to deal with. I have boards/chips for GPS, Gyro, accelerometer but they are for my RV to determine level and other things. What I said earlier is general knowledge, the specifics I quoted were from 5 mins of google time.

My GPS module is like https://www.amazon.ca/dp/B09HSMRH5V?tag=amz-mkt-chr-ca-20&ascsubtag=1ba00-01000-org00-mac00-other-nomod-ca000-pcomp-feature-pcomp-feature-pcomp-wm-11&ref=aa_pcomp_xim1 but I bought 10 from China for that price.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@huckohio Are you using Bill's video/blog/code? 

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
huckOhio
(@huckohio)
Member
Joined: 5 years ago
Posts: 168
Topic starter  

@ronalex4203 

Not sure I am following your post "Your readings for 0 is 5, for 90 is 85, for 180 is 168, for 270 is 287. All of those are inside the 10% or silver tolerance. "  My reading when the sensor is facing North is 287 - a variance of 73 degrees.  The variations for east was 78 degrees and for south & west was 95 degrees.

I did determine the magnetic deviation and added that into the code.

"Are you using Bill's video/blog/code? "  Yes, I started with Bill's article on GPS where he had a sketch for the BN-880.  I also used another library (mentioned in my original post) that had a calibration sketch.  The readings were consistent between the two libraries.  

I may purchase another sensor to compare sesults.

Thanks again!


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @huckohio

Would it matter that I am taking these readings in the basement

As the BN-880 gets its info from GPS, then you really need a clear view of the sky.  I have played with other GPS sensors and it was not until I stuck the aerial out of the window that I any proper results, and even then I should really have placed it away from the building with a clear all-round view of the sky.  

Its on with the long-johns and out in to cold for you 😎 


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@byron I thought that unit had a magnetometer for it's 2nd compass function.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @ronalex4203

I thought that unit had a magnetometer for it's 2nd compass function.

I think so too.  But I think it gets its bearing from the GPS calculation and then the compass is adjusted to agree, else one could be working with conflicting bearing data.


   
ReplyQuote
Ron
 Ron
(@zander)
Father of a miniature Wookie
Joined: 3 years ago
Posts: 6662
 

@byron I think you got that wrong. He likely has NO GPS signal in the basement, his compass is based on magnetism, why would it be adjusted? In looking at his OP and picture I see a lot of metal and it is more metal in one dimension. He should test with the device dismounted from the vehicle.

First computer 1959. Retired from my own computer company 2004.
Hardware - Expert in 1401, and 360, fairly knowledge in PC plus numerous MPU's and MCU's
Major Languages - Machine language, 360 Macro Assembler, Intel Assembler, PL/I and PL1, Pascal, Basic, C plus numerous job control and scripting languages.
Sure you can learn to be a programmer, it will take the same amount of time for me to learn to be a Doctor.


   
ReplyQuote
byron
(@byron)
No Title
Joined: 5 years ago
Posts: 1112
 
Posted by: @ronalex4203

I think you got that wrong.

Quite probably 😀 .  And I quite agree that its no good calibrating a compass with all that metal around. (so its still best done outdoors out in the cold, wrap up warm @huckohio)

 However I thought the purpose of the compass was for situations where the GPS signal fails like when the bot has just gone under some trees and then the bot can continue on its merry way for a while based on its compass, so the bearing readings need to be co-ordinated in some way.


   
huckOhio reacted
ReplyQuote
Page 1 / 2