MMA7361L accelerometer - Problem with the z-axis

Thread Starter

krow

Joined May 25, 2010
49
Hello,

Not sure this has been discussed before as I couldn't find anything, but I've been having a frustrating issue with the sensor's z-axis. I've tried everything but no success. I'm basically interested in the g values, so when the sensor is upside down instead of giving me -1 it gives me a value of around -1.34g, the corresponding value in volts is 0.58V. I think those value are not an acceptable? correct me if I'm wrong. Then when the sensor is facing up, the z-axis outputs 0.6g and 2.15V. Normally it would be 1g, 2.45V.

I guess this is a pretty straightforward calculation, it took me a while to actually make the decision to ask for help, it would be embarrassing to find this is all about a careless mistake.

The setup I'm using is simple, I'm using an Arduino Uno, the accelerometer is being powered by the 3.3V pin connected to Vin. I'm using the capacitors on the outputs as shown in the datasheet. Here's the code I wrote to get the values, again, pretty straightforward:

Rich (BB code):
//void setup(){};
//void loop(){};

int myArray[]={A0,A1,A2};
float volts[3];
float g[] = {volts[0],volts[1],volts[2]};
int xVal, yVal, zVal;

void setup(){
  
  Serial.begin(9600);
  analogReference(EXTERNAL);
  
}
void loop(){
  xVal = analogRead(myArray[0]);
  yVal = analogRead(myArray[1]);
  zVal = analogRead(myArray[2]);

  volts[0] = xVal*3.3/1024; //Vref = 3.3
  volts[1] = yVal*3.3/1024;
  volts[2] = zVal*3.3/1024;
  
  g[0]= (volts[0]-1.65)/0.8; // Voff = 1.65, Sensitivity = 0.8
  g[1]= (volts[1]-1.65)/0.8;
  g[2]= (volts[2]-1.65)/0.8;
  
  Serial.print(volts[0]);
  Serial.print("\t");
  Serial.print(volts[1]);
  Serial.print("\t");
  Serial.print(volts[2]);
  Serial.print("\t");
  Serial.print(g[0]);
  Serial.print("\t");
  Serial.print(g[1]);
  Serial.print("\t");
  Serial.println(g[2]);
  
  delay(100);  
}
Any help on this issue will be much appreciated, thanks.
 
Top