Magnetometer ADC problem

Hi everybody.

I am now trying to acquire Analog signals from a commercial magnetometer. This magnetometer has analog outputs and a LCD display.

I checked the value of the analog outputs with a multimeter and the value measured fits very well with the display values (less than 1% error).

However, with my arduino board I get always signals which are about 5% lower (and this error means about 4 digital steps in my case) just connected the BNC Magnetometer outputs to the arduino Analog inputs).

I have tried using the 3.3 V source as reference (because it measured 690 digital steps instead of 675) but I got even worse (lower) results.

I do not know if there could be an input resistance problem, I tried increasing it with no different results.

I attach the last program I used:

unsigned long time;
void setup() {

  • Serial.begin(9600);*
  • Serial.flush();*
  • analogReference (DEFAULT);*
    }
    void loop() {
  • time=millis();*
  • // I connect the 3.3 V source to pin A3 and use it as reference.*
  • float bitref = analogRead(A3);*
  • Serial.print(bitref,DEC);*
  • Serial.print("\t");*
  • Serial.print(time);*
  • Serial.print("\t");*
  • analogRead(A0);*
  • delay(10);*
    _ float sensorValue = analogRead(A0)*(3.3/bitref);_
  • Serial.print(sensorValue,DEC);*
  • Serial.print("\t");*
  • analogRead(A1);*
  • delay(10);*
    _ sensorValue = analogRead(A1)*(3.3/bitref);_
  • Serial.print(sensorValue,DEC);*
  • Serial.print("\t");*
  • analogRead(A2);*
  • delay(10);*
    _ sensorValue = analogRead(A2)*(3.3/bitref);_
  • Serial.println(sensorValue,DEC);*
    }

thank you in advance.

When you say this:

I have tried using the 3.3 V source as reference (because it measured 690 digital steps instead of 675) but I got even worse (lower) results.

did you modify on-board connection, as DEFAULT reference is 5V (or what is your board) ?
Have a link to magnetometer datasheet?

Dear magician,

When I say "I have tried using the 3.3 V source as reference (because it measured 690 digital steps instead of 675) but I got even worse (lower) results." I mean that I did what is written in the code used I read the 3.3V and set them as my new reference to calculate the output voltage. The DEFAULT voltage is 5 V. my board is ATMEGA 168.

About datasheets, I am afraid I will not find it. It was just bought to "alphalab inc." and they did all electronics, and they did not give me any information about the electronics. It just has three BNC outputs and they should give from -2 to +2 V (depending on magnetic field direction) with an accuracy of 0.5% (which, except for Arduino, it was the case). Do not worry for the negative values, I will try to mend that later, I found a direction to have all outputs positive.

thank you

However, with my arduino board I get always signals which are about 5% lower (and this error means about 4 digital steps in my case) just connected the BNC Magnetometer outputs to the arduino Analog inputs).

Have you measured your arduino's actual +5vdc Vcc voltage? This value, used as the default A/D reference voltage is rarely exactly +5vdc and will vary depending if your board is powered via your PC's USB voltage or the on-board +5vdc voltage regulator if externally powered. a 5% Vcc tolerance is still within spec. However if it's at least a consistent 'offset' one can correct for it via software.

Lefty

I'm not worry about -2V, hope you read Atmega168 data regarding analog inputs voltage limits.
What I try to clear is:

  • how device powered, +5, +3.3 or something else?
  • are the on-board of magnetometer any voltage regulator IC?
  • does output signals get affected by changing power supply voltage?
    Chart Vout / Vpow would be very helpful.
  • what output resistance/impedance?
  • what is wide-band in Hz?

When you say accuracy 0.5% , what voltage/temperature/load_resistance range it is true for?

Can you read marking on the chips of magnetometer, so I can try to download datasheet from net?

Dear Retrolefty,

My use of the word "reference" was not very clear, please rename 3.3 V as "calibration voltage" and 5 V is "reference voltage". The reference of my Arduino is ALWAYS 5 V. Now I will tell you the whole story:

I did all measurements considering that the reference was 5 V, meaning that 5 V are 1023 digital steps. I will call the Input of my analog Pin "A0" in digital steps. So then

InputVoltage=(A0)*(5/1023)

The result was a lower Input voltage than it was written in the display of my commercial magnetometer (and I checked that value with a multimeter, and the Display was right).

Then I measured the reference voltage of my Arduino and it was lower than 5 V, about 4.90 V. BUT then:

InputVoltage=(A0)*(4.9/1023) !!!!!!!

This means, if we correct this, we obtain a lower voltage than before!!!!

There are some reports - YouTube that suggest measuring also another reference value which is the "gap voltage" (about 1.1 V). I could not find any pin in my AT MEGA 168 to measure that "gap voltage", but there is another pin where I can obtain a 3.3 V source. This is what I used to calculate accurately the InputVoltage and that is what you see in the code for all three axis of the magnetometer, and I use another pin to measure 3.3.V. I call it "reference", but THIS IS NOT THE CASE. Maybe I should have called it a "calibration value". The reference is 5 V. and my calibration value is 3.3. V. I calculate thus the InputVoltage from that calibration voltage instead of doing it from the reference, because I know that the reference will always be 1023 digital steps regardless of the real value of it.

dear Magician,

I am afraid I am not that good in electronics :sweat_smile:. The magnetometer is from alphalab and quite new: http://www.trifield.com/content/dc-milligauss-meter-3-axis/

I will try to answer your questions

Magician:
I'm not worry about -2V, hope you read Atmega168 data regarding analog inputs voltage limits.
What I try to clear is:

  • how device powered, +5, +3.3 or something else?

My AT MEGA is powered at +5 V. I used 3.3 V as a "calibration value" I think this is a clearer definition of the 3.3 V issue than reference value. (look at my reply to retrolefty).
The magnetometer has a transformer form 220 V AC to 12 V DC

Magician:

  • are the on-board of magnetometer any voltage regulator IC?

I am sorry, I do not know what "IC" means. I can send an email to alphalab to ask them about that details.

Magician:

  • does output signals get affected by changing power supply voltage?
    Chart Vout / Vpow would be very helpful.

Well, as I said, I checked the Vout of the magnetometer with other instrumentation, and I got the same results as in the display of it without changing anything (not even the socket where the transformer was plugged).

Magician:

  • what output resistance/impedance?

That is a good question. I measured it (not powered) and it was of 80 kOhm, but I do not know if that is the way of measuring it, or if I should directly ask the company.

Magician:

  • what is wide-band in Hz?

No idea, but I will take advantage to learn something new from you: what is that and why is this important?

Magician:
When you say accuracy 0.5% , what voltage/temperature/load_resistance range it is true for?

well, it is true at about 23 °C (typical Lab temperature). Arduino values where different from the (correct) display and multimeter values at the same time and in the same room, thus it was at the same temperature. The load resistance should be the same as for oscilloscopes and multimeters, I do not know how much it is, but quite high, I suppose. I believed that the load resistance is the problem, but I increased it to 10 MOhm with no different results (I just put a resistance of 10 MOhm at the input of arduino)...

Magician:
Can you read marking on the chips of magnetometer, so I can try to download datasheet from net?

I am sorry, I will not open the magnetometer because it is still in warranty... I could ask alphalab, but I am not sure if they would tell me that...

O'k, sorry, I missed "commercial" in your initial post, some of the question were addressed to hobbyist shield rather than lab equipment with warranty.
May be you should contact manufacturer regarding output impedance and band-width, but before you do that there are couple tricks to try.

I measured it (not powered) and it was of 80 kOhm, but I do not know if that is the way of measuring it, or if I should directly ask the company.

No, it's not right way. Ask for full specification/datasheet.

ote from: Magician on August 03, 2011, 10:03:47 AM

  • what is wide-band in Hz?

No idea, but I will take advantage to learn something new from you: what is that and why is this important?

It's important, because reading you getting on DMM or internal LCD display is filtered/smoothed over 1-5 sec period, the same time arduino spend 0.1 millisecond on the reading and really susceptible to interference from the power grid line 60Hz electrical and magnetic field (that could be induced directly to measuring device).
First, modify your code, taking average value from 10 - 100 readings in a loop.
Have you measure your 3.3 V, is it precise enough to calibrate input?
Take an average for it for better accuracy as well.
And , if it doesn't help, I'd suggest to put a RC filter close to analog input, to suppress an interference, serial resistor 100 k and cap 1 uF to ground.

dear magician,

I will try your tricks :)... Tomorrow I will tell you if I got some better results.

Thank you!

However, with my arduino board I get always signals which are about 5% lower (and this error means about 4 digital steps in my case)

4 counts being 5% means a count of 80 or so - 400mV? Maybe you should be using the internal 1.1V reference to get better resolution:

void setup ()
{
  ...
  analogReference (INTERNAL) ;
}

then a count of 1023 corresponds to 1.1V rather than 5V.

With such low-voltage measurements it is important that your incoming signal ground is connected direct to the arduino on a separate pin from any power supply or current load. Fortunately the board has 3 different ground connections on the headers.

Its also important that no significant current flows on the signal ground due a ground-mismatch between the instrument and the Arduino - this might be less easy to achieve - you can measure the current with a multimeter to check its negligible by putting it in current-measuring mode between the two grounds.

Both requirements are to prevent you accidentally measuing the IR voltage drop across a piece of wire (when you actually wanted to measure the voltage output of the instrument).

You might want to read this:

dear all,

great answers!

The pdf document makes me clear that an Offset in the ADC is possible.

I tried doing 100 points average with the INTERNAL reference of 1.1 V. Then I got even higher values than expected. I checked the value of the reference voltage with my multimeter and it is actually of 1.013 V (measured directly at the AREF pin). When changing this in my code I got again a lower result than expected but slightly better (3 counts). I checked the voltage drop along the BNC wires connecting the Magnetometer to Arduino, and there is indeed a difference of about 1 mV (translated to digital, about 1 count). So I am now at 2 counts below the real value (due to the voltage drop along the wire).

Is there any way except for the obvious "shorter wires" to diminish the drop voltage?

I also checked currents between grounds and it was below 0.1 microAmp (the lowest my multimeter can measure).

Could this be just an offset of the ADC?.

Thank you all for your help

The usual way to eliminate ground loops like this is to use a differential measurement.

And yes the 1.1V reference is nominal, and its not that good. If you want high accuracy you don't use the onboard ADC, you use a purpose-built instrumentation amplifier and ADC (which you already have inside the magnetometer BTW!)

Looks like there is a mistake:

However, with my arduino board I get always signals which are about 5% lower (and this error means about 4 digital

4 digital step is 4/1024 = 0.4% .
It's normal for AtMega328:

TUE Absolute accuracy Vcc = 4.0v, VRef = 4.0v 2.2 3.5 LSB
INL Integral Non Linearity Vcc = 4.0v, VRef = 4.0v 0.6 1.5 LSB
DNL Differential Non Linearity Vcc = 4.0v, VRef = 4.0v 0.3 0.7 LSB
Gain error Vcc = 4.0v, VRef = 4.0v -3.5 3.5 LSB
Offset error Vcc = 4.0v, VRef = 4.0v -3.5 3.5 LSB

3.5 LSB, I think, around 12 digital step or 1.2%.

Dear all,

From MarkT comment I suppose that the magneotmeter has an ADC inside to write the signal values on the LCD displays...

About Magician comments... well, the 5% was to respect to the real value in Volts not in counts... but yes it was really not well explained, sorry for that, (my english is not the best).

So if I understood well, the accuracy I obtained is well within the Arduino accuracy and I may be challenging Arduino asking for better results...

thank you