Netduino home hardware projects downloads community

Jump to content


The Netduino forums have been replaced by new forums at community.wildernesslabs.co. This site has been preserved for archival purposes only and the ability to make new accounts or posts has been turned off.
Photo

Magnetometers


  • Please log in to reply
2 replies to this topic

#1 John C

John C

    Member

  • Members
  • PipPip
  • 10 posts

Posted 12 March 2011 - 07:05 PM

Anyone here have any experience with magnetometers? Which one(s) have you used? What interface? How easy is it to work with? How well did the tilt-compensation (if any) work? TIA, John

#2 demonGeek

demonGeek

    Advanced Member

  • Members
  • PipPipPip
  • 42 posts
  • LocationCanada

Posted 12 March 2011 - 10:41 PM

Anyone here have any experience with magnetometers?

Which one(s) have you used? What interface? How easy is it to work with? How well did the tilt-compensation (if any) work?


I'm not very experienced with them but I did just get one working with my Netduino so I thought I'd share that with you ;-)

I've had a Sure Electronics Dual-axis Magnetic Sensor Module (DC-SS503) sitting around for a while and wanted to experiment with the I2C interface. It turns out to be a really simple interface and I'd recommend it not just because it's simple but also because you can chain a bunch of I2C devices on a bus which avoids using all your Netduino pins driving multiple sensors.

Anyway, like I said, I'm not an expert but I hooked it up and got some data back which changes as I rotate the device in the X or Y axes. What that data means is my next task to figure out.

This is the test code I used to initiate a measurement and read the results:

byte[] buffer = new byte[5];
int bytesWritten = 0;

// Create the I2C device (device address: 0x30, clock rate: 400Khz)
I2CDevice.Configuration i2cConfig = new I2CDevice.Configuration(0x30, 400);
I2CDevice device = new I2CDevice(i2cConfig);

// Send command to take measurements (0x00) followed by (0x01)
I2CDevice.I2CTransaction[] writeTx = new I2CDevice.I2CTransaction[] { I2CDevice.CreateWriteTransaction(new byte[] { 0x00, 0x01 }) };
bytesWritten = device.Execute(writeTx, 1000);

// Pause for (minimum) 5ms as device completes data acquisition
Thread.Sleep(10);

// Read the 5-byte response from the device
I2CDevice.I2CTransaction[] readTx = new I2CDevice.I2CTransaction[] { I2CDevice.CreateReadTransaction(buffer) };
bytesWritten = device.Execute(readTx, 1000);

Debug.Print("Internal Register: " + buffer[0].ToString());
Debug.Print("X-Axis: " + ((buffer[1] * 0x100) + buffer[2]).ToString());
Debug.Print("Y-Axis: " + ((buffer[3] * 0x100) + buffer[4]).ToString());

Make sure you have the 4.1.1 ALPHA 7 firmware.

Hope that helps.

#3 John C

John C

    Member

  • Members
  • PipPip
  • 10 posts

Posted 27 March 2011 - 01:43 PM

Exactly what I'm looking for DG. Helps a lot. Thanks!




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

home    hardware    projects    downloads    community    where to buy    contact Copyright © 2016 Wilderness Labs Inc.  |  Legal   |   CC BY-SA
This webpage is licensed under a Creative Commons Attribution-ShareAlike License.