Contention?

Hello,

I have a UNO SMD edition and am reading the MMA7455 Tri-axial accelerometer using I2C communication.
Using the same program, when I plug in an Adafruit Datalogger, the 7455 doesn't communicate anymore. As a test, all references to the SD card and the RTC are commented out, with and without the Datalogger plugged in. With the Datalogger plugged in, I cannot even read the Mode register of the 7455. When I remove the Datalogger, I can read everything (i.e Mode, Status, g level, etc).
I suspect there is something with the Datalogger messin' up comm, even with all references to SD and RTC commented out. I don't have a schematic for the Datalogger, so don't know what pin (or function) is active. The UNO and the Datalogger works with other shields, like the BMP085 Barometric sensor, etc. Any suggestions/insight will be appreciated.

Thanks,
Steve

What is the I2C address of the MMA7455. Does it conflict with anything on the Datalogger?

[edit] and have you tried an I2C scanner with and without the logger connected?

Pete

From the Adafruit store website about the Datalogger-
"This board/chip uses I2C 7-bit address 0x68."

The MMA7455 Accelerometer address is 0x1D.
In the program: "#define I2C_ADDRESS 0x1D // address "

I am not sure what the scanner is that you mentioned. Is this something I can purchase?

Thanks for any further thoughts or suggestions.
Steve

Okay, I found the scanner.
Without the Datalogger and just the 7455 accel connected, the scanner reports address 0x1D
Datalogger and 7455 accel, scanner reports address 0x1D and address 0x68.

Two different addresses, shouldn't be a problem, no?
S.

The scanner can see both the datalogger and 7455 so there's no conflict with the addresses. In that case, there's some other problem. You should post your code (in tags).

Pete

Here is the code, hope I am posting it correctly...

//------------- MMA7455 3 Axis Accel -----------
//
//  26 Apr 2014     debug        SP
//----------------------------------------------

//#include <SD.h>                                 // SD and RTC commented out
//#include "RTClib.h"

#include <Wire.h>
#include <SoftwareSerial.h>

#define I2C_ADDRESS                    0x1D     // accel address
#define MMA7455_XOUTL            0x00     // MMA7455 Registers
#define MMA7455_XOUTH            0x01
#define MMA7455_YOUTL            0x02
#define MMA7455_YOUTH            0x03
#define MMA7455_ZOUTL            0x04
#define MMA7455_ZOUTH            0x05
#define MMA7455_XOUT8            0x06
#define MMA7455_YOUT8            0x07
#define MMA7455_ZOUT8            0x08
#define MMA7455_STATUS           0x09
#define MMA7455_DETSRC         0x0A
#define MMA7455_TOUT             0x0B
#define MMA7455_I2CAD            0x0D
#define MMA7455_USRINF          0x0E
#define MMA7455_WHOAMI       0x0F
#define MMA7455_XOFFL            0x10
#define MMA7455_XOFFH           0x11
#define MMA7455_YOFFL            0x12
#define MMA7455_YOFFH           0x13
#define MMA7455_ZOFFL           0x14
#define MMA7455_ZOFFH          0x15
#define MMA7455_MCTL            0x16
#define MMA7455_INTRST         0x17
#define MMA7455_CTL1              0x18
#define MMA7455_CTL2             0x19
#define MMA7455_LDTH            0x1A
#define MMA7455_PDTH           0x1B
#define MMA7455_PW               0x1C
#define MMA7455_LT                 0x1D
#define MMA7455_TW               0x1E

#define greenLED 8                     // "L1" Green
#define redLED 9                         // "L2" Red

//RTC_DS1307 RTC;                        // define the Real Time Clock
const int chipSelect = 10;               // 10;
SoftwareSerial mySerial(6,7);        // RX, TX, LCD
//File logfile;                                    // the logging file
String m;
byte xval, yval, zval, sval, mval, r, d;
double dX,dY,dZ, ix, iy, iz, hx, hy, hz;
int Loop;

void error(char *str)
{
 Serial.print("error: ");
 Serial.println(str);
  while(1);
}

//*----------------------------*
//*           Setup                        *
//*----------------------------*
void setup()
{
  Wire.begin();                                     // join i2c bus 
  pinMode(redLED, OUTPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(chipSelect, OUTPUT);
  Serial.begin(9600);                            // start serial for output
  mySerial.begin(9600); 
  mySerial.write(12);                             // clear LCD
  mySerial.write(22);                            // backlight on
  digitalWrite(chipSelect, HIGH);         // tried CS both ways..
  //digitalWrite(chipSelect, LOW);
  digitalWrite(redLED, LOW);
  digitalWrite(greenLED, HIGH);
 
  WriteReg(MMA7455_MCTL, B00101);         // I2C, 2g range, Reg 0x16
  delay(200);
                     
  mval = ReadReg(MMA7455_MCTL);           // Read Mode Control Register
  mySerial.write(128); 
  mySerial.print("MODE: ");
  mySerial.print(mval, HEX);
     
  sval = ReadReg(MMA7455_STATUS);         // Read Status Register
  mySerial.print("  STATUS: ");
  mySerial.println(sval, HEX);
  delay(2000);
/*                                        // RTC stuff commented out
  RTC.begin();
  if (! RTC.isrunning()) {                  
    Serial.println("RTC is NOT running!");
    // Sets RTC date & time when sketch is compiled.
    // Uncomment it to set the time & date.
    //RTC.adjust(DateTime(__DATE__, __TIME__));   
   }
                                            // SD card stuff commented out
  mySerial.write(168);                                // for LCD position 0,0
  if (!SD.begin(chipSelect)) {                     // card is present & can be initialized
    error("Card failed, or not present");
   }
  mySerial.println("Card initialized");
  delay(1200);
  char filename[] = "LOGGER00.CSV";         // create a new file
  for (uint8_t i = 0; i < 100; i++) {
    filename[6] = i/10 + '0';
    filename[7] = i%10 + '0';
    if (! SD.exists(filename)) {
       logfile = SD.open(filename, FILE_WRITE);   
       break;                                                   // leave the loop
       }
  }
  if (! logfile) {error("couldnt create file");}
 delay(2000); 
*/

 Loop=0;                                   // Loop flag
 hx = -10;                                  // init max reading variables
 hy = -10;
 hz = -10;
}

//*----------------------------*
//*            Read                         *
//*----------------------------*
 unsigned char ReadReg(unsigned char reg)
{
  Wire.beginTransmission(I2C_ADDRESS);      // write register address first
  Wire.write(reg); 
  Wire.endTransmission();
 
  Wire.requestFrom(I2C_ADDRESS, 1);         // read the data back
  if(Wire.available())
    {
    return Wire.read();
    }
  return 0;                                                      // return zero if no data
}

//*----------------------------*
//*           Write                         *
//*----------------------------*
void WriteReg(unsigned char reg, unsigned char value)
{
  Wire.beginTransmission(I2C_ADDRESS);      // write register address first
  Wire.write(reg);
  Wire.write(value);                                            // and then write data
  Wire.endTransmission();
}

//*----------------------------*
//*            Loop                         *
//*----------------------------*
void loop()
{
  digitalWrite(redLED, HIGH);
  mySerial.write(12);                            // clear LCD
  mySerial.write(22);                            // backlight on

/*                    commented out RTC stuff
 mySerial.write(128);                            // for LCD position 0,0
 DateTime now;
 now = RTC.now();                                // fetch the time
 mySerial.print(now.month(), DEC);
 mySerial.print("/");
 m = String(now.day());
 if (m.length() < 2) mySerial.print("0" + m);
 if (m.length() > 1) mySerial.print(m);
 mySerial.print("/");
 mySerial.print(now.year(), DEC);
 mySerial.print(" ");
 m = String(now.hour());
 if (m.length() < 2) mySerial.print("0" + m);
 if (m.length() > 1) mySerial.print(m);
 mySerial.print(":");
 m = String(now.minute());
 if (m.length() < 2) mySerial.print("0" + m);
 if (m.length() > 1) mySerial.print(m);
 mySerial.print(" ");
 */

  xval = ReadReg(MMA7455_XOUT8);                 // only using X axis for now
  //yval = ReadReg(MMA7455_YOUT8);
  //zval = ReadReg(MMA7455_ZOUT8);
  
  dX = (double) xval / 64.0;                                 // calculate the 'g' values
  //dY = (double) yval / 64.0;
  //dZ = (double) zval / 64.0;
  
  if (Loop == 0)                                                    // check loop flag
    {
    ix = dX;                                                             // save initial offset
    //iy = dY;
    //iz = dZ;
    }
  else
    {
    dX = dX - ix;                                                            // zero out readings
    //dY = dY - iy;
    //dZ = dZ - iz;
    if (dX > hx) hx = dX;                                              // save maximum reading
    //if (dY > hy) hy = dY; 
    //if (dZ > hz) hz = dZ;
    }
 
  mySerial.write(148);
  mySerial.print("X: ");                 
  mySerial.print(dX, 1);                                                 // display the current reading
  mySerial.print("  hx: ");                                            // and max reading        
  mySerial.print(hx, 1);
  delay(100);
 /* 
  mySerial.write(168);  
  mySerial.print("Y: ");
  mySerial.println(dY, 1);
  mySerial.print("  hy: ");                 
  mySerial.print(hy, 1);
  
  mySerial.write(188);   
  mySerial.print("Z: ");
  mySerial.println(dZ, 1);
  mySerial.print("  hz: ");                 
  mySerial.print(hz, 1);
*/
/*  
  Serial.print(F("x: "));
  Serial.print(dx, 2);
  Serial.println();
  Serial.print(F("y: "));
  Serial.print(dy, 2);
  Serial.println();
  Serial.print(F("z: "));
  Serial.println(dz, 2);
  Serial.println("........");
*/ 
  digitalWrite(redLED, LOW);
  delay(0);
  Loop = Loop + 1;                                        // increment loop counter
  }
//---------------------------- end --------------------------