Memsic magnetometers

I've recently got a little board from SureElectronics, DC-SS504. It has a Memsic MMC2120MG magnetometer on it together with a PIC which provides a simplified serial interface. I, however, was interested in the raw I2C protocol, which was also provided on the board's pins. The datasheets from Memsic describe the protocol in a very obscure and hard-to-understand way. So here I tried to summarize my findings in (hopefully) plain English.

The device works over I2C ("fast" mode, i.e. 400 kHz max)
The slave address is determined by the last digit (x in MMC212x) :
0: 0x60, 1: 0x64, 2: 0x68, 3: 0x6C

The chip has several byte-sized registers.

00 control register
01 most significant byte x axis
02 least significant byte x axis
03 most significant byte y axis
04 least significant byte y axis
05 most significant byte z axis (MMC312xM only)
06 least significant byte z axis (MMC312xM only)

Control register is read/write, the rest is read-only.

To read or write register, first send its address then read or write. The address is incremented automatically so sequential reads can be done without resending the new address.

Chip operations are initiated by writing into the corresponding control register's bit. The following bits are defined:

bit 0: TM (take measurements)
set to get measurements (i.e. send 0x01)
bit is reset when measurement is done, so you can use it
to check if the operation is finished
bit 1: SET (set coil)
set to send a large current through the set/reset coil
should be done if sensor was affected by a large magnetic field (>5.5 gauss)
also after power on
result can be checked same as above
bit 2: RESET (reset coil)
same as above but sends current in the opposite direction
set/reset should be interleaved in "low-power mode", whatever that is
bits 3-6: reserved
bit 7: not described

For example, to take the measurements:
1. write 0 (control register address), then 0x01 (take measurements)
2. wait at least 5 ms for the measurement to complete
3. write 0 again (control register address), then read the register value
4. check the bit 0. If it's still set (measurement in progress), repeat from 3.
5. read x msb
6. read x lsb
7. read y msb
8. read y lsb
9. (if MMC312xM) read z msb
10. (if MMC312xM) read z lsb

N.B.: ADC resolution is only 12 bits, so four high bits of values will be 0.

I wrote a class wrapping all that, also adding calibration functionality. Here's the demo program: DC-SS504


2 comments

11 Oct 2010

Did you find anywhere to buy the three axis device (either on a eval board or bare devices)?

11 Oct 2010

Found one in some Polish shop, of all places. Also, this company seems to offer it but not sure if they'll sell to private users. You can also try contacting Memsic, maybe they advise some places.

You need to log in to post a comment