SparkFun Forums 

Where electronics enthusiasts find answers.

Have questions about a SparkFun product or board? This is the place to be.
By fll-freak
#148004
SDA to SDA, SCL to SCL.

Mag compasses are a pain. If you are testing indoors, any ferrous metals or wiring in the walls can generate enough magnetic field to cause the robot to veer in funny ways (if holding a constant heading). Outdoors it is less of a problem, but buried cables and ferrous metals (like cars) can be an issue. Proper calibration/compensation for hard and soft magnetic anomalies will need to be performed to get back the accuracy to lose with ferrous metals in the area.
By sora62896
#148005
Hmmmm.......I am testing indoors in my basement (that's where my room is and our workshop is) and I have my three computers......might be a problem.......but It has worked in the basement before.........still odd how it is inconsistent.......And I am using this on my mega 2560.....so pin 20 and 21 are my scl and sda......I looked and thought I saw a second pair of those pins.....would they make any difference?

Thanks!
By fll-freak
#148009
It is possible for a micro to have two or more I2C ports as well as SPI, UARTS, or other device interfaces. You just need to know what bus it is on and use that interface for communication. The fact that you are getting any data means you are on the right bus. You just have a calibration and or interference problem.
By fll-freak
#148018
"Foil" is a bit of a lose term. The thinnest stuff I have seen in 0.006" thick and more like thin sheet stock than anything like aluminum foil.

I have seen it for sale on eBay (Search for Ultraperm a different maker of a Mu Metal). It can also be purchased as a designer's kit from MuShield. Stuff is quite expensive ($50 for an 8*11" sheet).
By fll-freak
#148100
sora62896 wrote:just to block out the magnetic noise?
"Just" is strange word to use for a physical effect physicists still do not have a handle on yet!

What you need is a material that will absorb and direct the field. If MuMetal is out, then get thyself to a hardware store and buy the thinnest sheet ferrous material you can. Aluminum, tin, copper, brass will not work. You need to have a magnet stick to it. Now carefully roll it into a tube. Do not form a spiral. Cut the metal for a perfect match or just a tiny overlap. Now clean the edges and bring them into contact. Slide it over the servo. If this does not work, you can add a layer of cardboard and place another tube of metal over than. Repeat as needed. Submitted without direct experience, just book learning.
By fll-freak
#148119
If your turn off the servo and wait for the motor to stop, then you should be abale to get a mag reading with all the normal issues of having a distorted field (not a fluctuating one). You can try to use a gyro to integrate heading rate to maintain a heading. This only works in a system without a lot of vibration and only over a short amount of time (seconds, not minutes). You also need to sample the gyro as fast as possible to keep any semblance of accuracy.
By sora62896
#148369
here's my problem with having the servo turned on and off only when needed; The servo isn't fully rotational--it is just used to control the front wheels on my robot. I also have a larger DC motor in the rear that drives the car. These are both large contributing factors that affect the compass. There are other sensors I will be using as well (they will have to be put in interrupts) that have an affect on the dc motor and servo as well. I can't have the robot take a reading, go, then stop and take another reading again because it would be too jolty and wouldn't be as accurate or as fast as I would have wanted. I'm still having difficulty with the orientation of the car while just running the servo. The servo turns to go the correct direction in two points rather than one. It should turn left to go to 90 degrees if it is above 90 degrees and turn right if it is under 90 degrees (I think that's correct). I don't really know how to describe it-- but it shouldn't be turning at 180; it should be turning at 270. Does that make sense?
By fll-freak
#148370
Magnetometers can be a serious pain in the fanny. I spent 4 years on a project that used one as one of its primary sensors and know your pain. Just picking the wrong type of stainless steel (there are hundreds of chemistries) would effect the sensor. Replacing the batteries (different ferrous metal mass) would affect the sensor. A zipper in your clothing would (drum roll please) affect the sensor.

Now your problem is several orders of magnitude worst. You have magnets and coils to contend with. You are trying to record the sounds of a butterfly sitting in the exhaust plume of a rocket motor. If a MuMetal shield is too expensive, then your only option is one of separation, or picking a different sensor(s).

As for your 1-2 point 180-270 problem, I do not follow. Perhaps you can provide more detail.
By sora62896
#148371
I'm running some tests with my code now; awaiting results to see for accuracy--would a regular compass show the same results of how the earth's magnetic field is being altered (rather blocked out)? If I hold a compass at different points, wouldn't that work better to show the "sweet spots" and where the magnetic field's are being most altered?