Pages: [1] 2   Go Down
Author Topic: Sparkfun 9 DoF sensor stick problems.  (Read 4304 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi, I bought one of these: http://www.sparkfun.com/products/10183
which has an ADXL345 accelerometer that I am trying to communicate with over I2C. I wired it up to an Arduino like this:

+5V -> Vcc
0V -> Gnd
A4 -> SDA
A5 -> SCL

And my code so far is:

Code:
#include <Wire.h>

const int ACCEL_ADDRESS = 0x1D;
const int ACCEL_POWER_CTL = 0x2D;
const int ACCEL_DATAX0 = 0x32;
const int ACCEL_DATAX1 = 0x33;
const int ACCEL_DATAY0 = 0x34;
const int ACCEL_DATAY1 = 0x35;
const int ACCEL_DATAZ0 = 0x36;
const int ACCEL_DATAZ1 = 0x37;

const int MAGNO_ADDRESS = 0x1E;

const int GYRO_ADDRESS = 0x38;

void setup()
{
  Serial.begin(9600);
 
  Serial.println("Starting I2C.");
  Wire.begin();
  Serial.println("I2C started. Starting accelerometer.");
  Wire.beginTransmission(ACCEL_ADDRESS);
  Wire.send(ACCEL_POWER_CTL);
  Wire.send(0x08);
  Wire.endTransmission();
  Serial.println("Accelerometer starter. Looping.");
}


void loop()
{
  // X accel.
  Wire.beginTransmission(ACCEL_ADDRESS);
  Wire.send(ACCEL_POWER_CTL);
  Wire.endTransmission();
  Wire.requestFrom(ACCEL_ADDRESS, 1);
  while (!Wire.available());
  int highx = Wire.receive();
  Wire.beginTransmission(ACCEL_ADDRESS);
  Wire.send(ACCEL_DATAX1);
  Wire.endTransmission();
  Wire.requestFrom(ACCEL_ADDRESS, 1);
  while (!Wire.available());
  int lowx = Wire.receive();
  Serial.println((highx << 8) | lowx);
}

But I don't get any response from the device (it never gets past the first Wire.available() loop). Can anyone say what I am doing wrong? I read some mention of disabling pull-up resistors in twi.cpp which I also tried, but it made no difference, and I've also tried the driver from the FreeIMU library which didn't work either.

This is very annoying, especially as it cost about £60. Have I got a dud board? Any ideas?

Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you have the two pull-up resistors that I2C requires?  If they aren't on the 9 DoF board you will have to add them to the A4 and A5 pins.
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I thought you had to disable those... or do I need to disable the internal ones and add external ones to 3.3V? I don't even have a 3.3V source. :-/ And also if I previously ran it with the internal pull-ups enabled, will that have damaged the devices? If so that is pretty -ing annoying given that there is no warning about this anywhere on sparkfun, or the wire library, and that *really* shouldn't be the default.

Is there any way to bodge a 3.3V source, perhaps using a voltage divider? I'm not concerned about power usage.
Logged

Massachusetts, USA
Offline Offline
Tesla Member
***
Karma: 180
Posts: 8108
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I just checked the schematic and it includes pull-up resistors so that's OK.

The schematic shows 3.3v power going to the chips.  Perhaps you should not connect it to +5v.

ADXL345 Supply voltage range: 2.0 V to 3.6 V

HMC5843:
    AVDD Referenced to AGND  3.3v Max
    DVDD Referenced to DGND  2.0v Max

ITG-3200:
    Operating Voltage Range:  2.1v - 3.6v
Logged

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Dammit. So basically all I had to do was modify twi.cpp so it didn't use the 5V pull-ups, and it would have been fine, but now the chips are dead?

It seems pretty damn stupid that they'd have a voltage regulator so you can run Vcc off 5V, but then not even tell you that you'll damage it if you connect it straight to the 5V arduino. And whoever wrote twi.cpp deserves some significant blame too... Code shouldn't break hardware by default.
Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 312
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

No, they are not dead. Just disable the pullups (see my guide How to disable internal Arduino ATMEGA pullups on SDA and SCL with I2C bus ) and check that your connections are like these and you should be fine.
Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 312
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, it's perfectly fine to connect the power to 5V as that board has an integrated voltage regulator which will take care of lowering it to the 3V3 used by the sensors.
Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 312
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Regarding the pullup enabling in Wire, well.. I had already opened an issue on the issue tracker asking the developers to fix that.. but nobody gave it a s**t ... You may wanna comment there if you think I was right.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the replies. Fabio, what makes you think they aren't dead, given that I connected them to the 5V pull-ups and the datasheet for the ADXL345 says SDA and SCL can't go above Vdd (3.3V) plus a tiny bit? And if they aren't dead, then I can't see why my code didn't work with the internal 5V pull-ups disabled (it seems the schematic shows 3.3V pull-ups built into the sensor board).
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Also, I hooked it up to an oscilloscope. It seems like the address is sent, but the ACK bit isn't set by the ADXL345. Also note that it is 3.3V (vertical division is 2V).

Logged

Torino, Italy
Offline Offline
Sr. Member
****
Karma: 2
Posts: 312
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
what makes you think they aren't dead

Because I ran a triple breakout board IMU with your same sensors without LLC and with pullups enabled for about 5 months.. that was when I still was learning stuff.. about one year ago.. those three sensors still works perfectly. I'd say that you may shorten their life but a couple tests with the pullups on doesn't fry them.

What board are you using? Can you post a picture of your connections?
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

That is slightly reassuring. I'm using the RBBB (Really Bare-Bones Board) arduino. Here is a photo:



I really appreciate the help btw.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 1
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Do you see the blue LED on the 9dof stick light up? Your photo shows it off.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 26
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes it does. I have since connected it to a bus pirate, and it shows the two other chips (gyro and magnetometer) responding, but the accelerometer was not. So definitely a faulty part.

I emailed cool components and they said they would send me a replacement.
Logged

Cwmbran, UK
Offline Offline
Newbie
*
Karma: 0
Posts: 31
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

Couple of questions relating to the above which I hope aren't stupid questions, but please bare in mind that I'm still quite new to all this.

I have a 9DOF stick that I want to connect to my Arduino ADK, which as far as I can see is effectively the same as an Arduino Mega.

If Im understanding it right I need to connect the SDA and SCL to pins 20 and 21 on the Mega board.

I understand about disabling the pullup resisitors too (I think).

Where I'm confused is:

1) Why would I want to connect the 9DOF stick to 5volt when I have a 3.3volt source on the Arduino board

and

2) In the post by Fabio Varesano it appears to be suggested the SDA and SCL wires should be connected the 3.3volt rail using 2.2k resistors - but I don't understand why.

Thanks in advance.

Chris.
Logged

Pages: [1] 2   Go Up
Jump to: