Programming with MAG3110 Magnetometer

For Flowcode users to discuss projects, flowcharts, and any other issues related to Flowcode 5.
To post in this forum you must have a registered copy of Flowcode 5 or higher.

Moderator: Benj

Post Reply
Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Programming with MAG3110 Magnetometer

Post by Brendan »

I am a seasoned professional experienced in hardware and host software design, only recently adding embedded coding to my arsenal with Flowcode v5.4 professional.

I'm currently working on a new project using the MAG3110 magnetometer, but (embarrassingly) I'm having difficulties interpreting/translating the necessary I2C transactions from the datasheet to Flowcode. For the record, the datasheet is here... http://www.freescale.com/files/sensors/ ... AG3110.pdf

I'm currently working with the supplied 16F88 PIC (5V logic) and, as per page 12 of the datasheet, I need to configure the device for 'multibyte read' in fast (80Hz) mode. I am using pins 7 and 10 for SDA and SCL respectively, with appropriate pull-ups either side of level translators which is all working fine.

Any pointers on the component macro's and their necessary configurations to extract MSB readings from all axes would be so much appreciated - or preferably an example if anyone's worked with this particular device before. Armed with a working example I can quickly start to move beyond this impasse for the rest of the project and other operating modes.

Many thanks in advance.

Brendan

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: Programming with MAG3110 Magnetometer

Post by Brendan »

Thanks to everyone showing interest in my post, but I've sussed it and working just fine now :D

I would however suggest better coverage of I2C in the help.

If you code in C then a review of the code helps users establish what's going on. However, Flowcode is all about providing embedded accessibility to users who don't, and I2C is a primary interface commonly used in modern electronics devices that make for more succinct and interesting projects.

My project is a personal invention for commercial exploitation and must therefore remain confidential, though I'll be happy to provide a working Flowcode example of MAG3110 register addressing and reads to anyone interested once I've matured the project a bit.

All the best,
Brendan

User avatar
Enamul
Posts: 1772
Joined: Mon Mar 05, 2012 11:34 pm
Location: Nottingham, UK
Has thanked: 271 times
Been thanked: 814 times
Contact:

Re: Programming with MAG3110 Magnetometer

Post by Enamul »

I was just looking at your first post..when I reached to second post..I got it solved that's great. Your project seems interesting. I will have a look at the MAG3110 Magnetometer.
Enamul
University of Nottingham
enamul4mm@gmail.com

Brendan
Posts: 243
Joined: Tue Nov 27, 2012 12:53 pm
Location: Cambridge, UK
Has thanked: 140 times
Been thanked: 118 times
Contact:

Re: Programming with MAG3110 Magnetometer

Post by Brendan »

Thanks Enamul :)

The MAG3110 is a popular well-specified 3-axis magnetometer (AKA electronic compass) with a host of control registers to suit a variety of applications. New to Flowcode myself I had over-simplified the task somewhat, so started off by simply focusing on reading the ID register to initially get the I2C working. Suffice to say, a great exercise into I2C with Flowcode.

It's a novel alternative to hall sensors when you need much greater sensitivity, offering 100kHz or 400kHz I2C and XYZ read speeds up to 80Hz with minimum oversampling, presenting a variety of interesting project opportunities for Flowcode users. The magnetometer is available pre-mounted on an inexpensive board, produced by Olimex (part code: 'MOD-MAG').

I should add however that it's a 3.3V logic device so needs regulation and non-inverting bidirectional level-shifting to work with the 5V-only Matrix EB-006-xx board, otherwise will be destroyed. Extremely simple to do with just a 3.3V LDO regulator, two logic level MOSFETs, and four resistors - all powered from and interfaced with the EB-006 via 40-way ribbon. It should also be possible to power the magnetometer, regulator, and level shifters, from an available port pin if required.

All the best,
Brendan
MAG3110, interfaced to EB-006-08 via level-shifters
MAG3110, interfaced to EB-006-08 via level-shifters
Magnetometer_Project.jpg (11.29 KiB) Viewed 4121 times

Post Reply