Using Motor Shield V2 & Compass

Adafruit Ethernet, Motor, Proto, Wave, Datalogger, GPS Shields - etc!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
project_science
 
Posts: 190
Joined: Sun May 04, 2014 1:26 pm

Using Motor Shield V2 & Compass

Post by project_science »

Hi,

I'd like to use the Adafruit's Motor Shield V2 (https://learn.adafruit.com/adafruit-mot ... rduino/faq) and Compass (https://learn.adafruit.com/adafruit-hmc ... g-and-test) on the Leonardo. (They will also be used with the Arduino Wireless Shield, http://arduino.cc/en/Main/ArduinoWirelessShield, and the Adafruit Ultimate GPS Shield.)

I know they both use I2C, which means they are going to be attached to D2, D3 for SDA and SCL lines.

I haven't used I2C for this purpose before, so I want to make sure their addresses are different?

Also, since the Motor Shield V2 accessing pins D2, D3 directly, do I just attached the wires from the compass directly into the stacked headers on the shield (or whichever shield is on top, probably the Ultimate GPS shield will be above the Motor Shield) to D2, D3, or would I want to run the wires to a breadboard and use some resistor across them first?

If I use resistors across both SDA and SCL for the compass, what strength should they be?

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using Motor Shield V2 & Compass

Post by adafruit_support_bill »

Those devices have different i2c addresses, so they can be used on the same bus. No additional pullup resistors are necessary. You can connect to the i2c bus via the headers, or use the breakout holes next to the headers on the motor shield. The motor shield also has a prototyping area suitable for sensors such as that.

One thing to be aware of: Electric motors have permanent magnets and/or coils that will affect the local magnetic field and can skew the readings from a magnetometer. be sure to locate the magnetometer well away from the motors.

User avatar
project_science
 
Posts: 190
Joined: Sun May 04, 2014 1:26 pm

Re: Using Motor Shield V2 & Compass

Post by project_science »

ok, thanks. Any recommendation how far above the motors to mount the compass? I'm prob just gonig to run a 4 motor test at different heights with the compass to look for any offsets when motors are on but curious if there's a rec. for it.

Also, I haven't used the breakout pins on the boards before. Since the Ultimate GPS shield will prob. be the top shield (which the compass would then link to), are those breakout same pins linked to the pins on the header? I'm assuming this means that the headers and the breakout pins access the same pins, but wasn't sure.

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using Motor Shield V2 & Compass

Post by adafruit_support_bill »

There is no universal rule - it depends on the motor. In the last magnetometer project I did, I found I needed to keep the magnetometer at least 6" away from the motor to avoid problems - it was a relatively small motor.

The breakout pin rows on both the motor shield and gps shield run parallel to the headers and are directly connected to the adjacent header pins.

User avatar
mkkb
 
Posts: 27
Joined: Fri May 09, 2014 10:53 am

Re: Using Motor Shield V2 & Compass

Post by mkkb »

Hi! I'm actually having a problem with using the motorshield V2 and the magnetometer shield. I struggle to initialize the motorshield/magnetoshield when the magnetometer is pinned to A4 and A5. Note that the magnetometer isn't Adafruits but something that looks identical from eBay I think, it is the HMC5883L. How can I debug this, or do the Arduino init function in a "bulletproof" way? My program just freezes at the call:

if(!mag.begin())
{
/* There was a problem detecting the HMC5883 ... check your connections */
Serial.println(F("Ooops, no HMC5883 detected ... Check your wiring!"));
while(1);
}

And it is not doing the Serial.print either. But if I unplug the I2C pins it runs immediately.

Any help is very much appreciated.
BR Kristian

User avatar
adafruit_support_bill
 
Posts: 88091
Joined: Sat Feb 07, 2009 10:11 am

Re: Using Motor Shield V2 & Compass

Post by adafruit_support_bill »

There should be no address conflict between the HMC5883 and the motor shield. I would verify that the HMC5883 works independent of the shield first.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino Shields from Adafruit”