DuinoMite Project: Measuring Earths Magnetic Field with MAG3110


Image

MAG3110 is nice digital 3-axis magnetometer. We built MOD-MAG which is board with MAG3110 and UEXT so this magnetometer can easily be connected to any of our development boards. The example here is with DuinoMite-Mini.

MAG3110 is pretty sensitive with 0.1 uT resolution and have full scale +-1000uT. For reference the Earth magnetic field varry from equator to poles in range 25-65 uT, so it’s possible to measure Earth’s magnetic field with MAG3110 and make for instance Compass or to scan infield for buried metal objects which affect Earth magnetic field or make tons of other interesting projects.

WiKi as usuall is great source for information on Earth magnetic field: http://en.wikipedia.org/wiki/Earth’s_magnetic_field

The complete MAG3110 data sheet is available at Freescale web: http://www.freescale.com/files/sensors/doc/data_sheet/MAG3110.pdf

Geomagnetic storms influence our life and you can read more for them here http://en.wikipedia.org/wiki/Geomagnetic_storm, moderate and intensive Geomagnetic storms could be detected and monitored with MAG3110.

For finer resolution magnetic fields are measured with fluxgate magnetomeres which can sense down to 0.01 uT, here is nice article about the fluxgate magnetometers: http://www.geotech1.com/pages/mag/projects/fmx1/fmx1.pdf

MAG3110 digital interface is I2C so very easy to read it with DuinoMite.
Here is small code I wrote to test MOD-MAG which have on board MAG3110 and UEXT connector:

10 OPTION BASE 0 ‘to make sure we have base 0
20 ID = 0: DIM AXES(6) ‘ID variable and AXES array
30 I2CEN 100,100 ‘enable I2C
40 I2CRCV &H0E, 0, 1, ID, 1, 7 ‘read MAG3110 ID (C4)
50 PRINT “ID = “;HEX$(ID) ‘should print C4 if MOD-MAG is attached
60 I2CSEND &H0E, 1, 2, &H11, &H80 ‘ctrl reg2, auto resets enbl
70 I2CSEND &H0E, 0, 2, &H10, &H01 ‘ctrl reg1, active mode
80 I2CRCV &H0E, 6, AXES(0), 1, 1 ‘read 6 bytes from addr 1
90 PRINT “X =”; HEX$(AXES(0)*256+AXES(1)); TAB(10) ‘X axe
100 PRINT “Y =”; HEX$(AXES(2)*256+AXES(3)); TAB(20) ‘Y axe
110 PRINT “Z =”; HEX$(AXES(4)*256+AXES(5)) ‘Z axe
120 IF INKEY$ <> “” THEN 200 ‘end if key is pressed
130 PAUSE 300 ‘wait a little
140 GOTO 80 ‘read and print again
200 I2CDIS ‘disable I2C

Image

as you can see the magnetometer on my desk do not give steady values, this is because we are surrounded by lot of invisible magnetic noise radiated from the computers, monitors, and so on electronics around us.

1 Comment (+add yours?)

  1. ThierryP
    Mar 28, 2012 @ 15:53:44

    I’ve posted my 1st experience with this MOD-MAG here: http://www.kenseglerdesigns.com/cms/forums/viewtopic.php?f=8&t=402

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: