In my last posting (Accelerometer placement — where and why ) I discussed tradeoffs to be considered when choosing where to locate an accelerometer in your design. THIS posting does the same thing, but for magnetometers. This posting also builds on topics previously discussed in Hard and soft iron magnetic compensation explained  as well as material presented at Design West 2012 .
For the purposes of this discussion, we’ll consider the following use model: magnetometer as the magnetic component in an electronic compass. In this case you desire to measure the earth’s magnetic magnetic field, which ranges from 25 to 65 microTeslas, depending upon your location upon the earth. This is a relatively weak field, and can easily be rendered unmeasurable unless you pay attention to magnetic issues during your system design. Magnetic sensors used for consumer and industrial applications have ranges much larger (>1000mT) than the earth field to be able to deal with hard and soft iron interference on the measured field.
In our context:
If you don’t have any of the above elements in your design, you can probably stop reading now. But unfortunately, most designs DO have to deal with these issues. Let’s start with general guidelines:
Although we can mathematically compensate for many soft iron impacts, it’s still best to avoid them when we can. As an example, let’s consider the effects of a small piece of steel on the value of the magnetic field measured nearby. Assume 1″ by 1″ by 0.02″ thick steel as shown in Figure 1A below. If you were to look at that piece of steel from the side, you have the view shown in Figure 1B.
For our simulation, I assumed an earth’s magnetic field of approximately 40 microTeslas, which is free to rotate over a range of 0 to 180 degrees during the simulation. This is equivalent to holding the field static, and rotating the sensor (which is what happens in the real world). The red line in Figure 1C represents a range of points in which I’ll measure the magnetic field intensity for each of those variations in field direction. The results were extracted and summarized via Excel, and are shown in Figure 2 below.
Next, let’s consider impacts on magnetic field resulting from wires and traces on your PCB. We can use the Biot-Savart law to estimate the effect of wire and trace currents on sensor readings. For long wires and traces, Biot-Savart can be simplified to:
This can be re-arranged to:
If you know the field magnitude you can afford to ignore and the distance from your sensor to trace/wire, then you can use Equation 2 to calculate the maximum wire/trace current in mA.
As an example, let:
By now, you should understand that adding a magnetic sensor to your design should be done early in the design cycle, and with careful consideration with respect to surrounding elements in the physical design. Do this, and your chances of being bitten by problems during product debug and evaluation will be greatly reduced.