Calibrating the MMA7361L accelerometer

Hello everybody.

I bought a MMA7361L accelerometer for a controller project.
I tried to read the X, Y and Z with my Arduino Uno.
Then I found out the X axis (in a horizontal stand by) is shifted around 1°.

Here is the code I used. A simple SerialReader from the ardunio examples librery.
I devided the 3 axis by 1000 to have an easy-to-read result.

/*
  AnalogReadSerial
 Reads an analog input on pin 0, prints the result to the serial monitor.
 Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
 
 This example code is in the public domain.
 */

// the setup routine runs once when you press reset:
void setup() {
  // initialize serial communication at 9600 bits per second:
  Serial.begin(9600);
}

// the loop routine runs over and over again forever:
void loop() {
  // read the input on analog pin 0:
  int sensorValue1 = analogRead(A0);
  // read the input on analog pin 1:
  int sensorValue2 = analogRead(A1);
  // read the input on analog pin 2:
  int sensorValue3 = analogRead(A2);
  // read the input on analog pin 19:
  int sensorValue4 = analogRead(19);
  // print out the value you read:
  Serial.print("\t");
  Serial.print("\t");
  Serial.print(" X = ");
  Serial.print(sensorValue1 / 100);
  Serial.print("\t");
  Serial.print("\t");
  Serial.print(" Y = ");
  Serial.print(sensorValue2 / 100);
  Serial.print("\t");
  Serial.print("\t");
  Serial.print(" Z = ");
  Serial.print(sensorValue3 / 100);
  Serial.print("\t");
  Serial.print("\t");
  Serial.println();
  delay(0.0001);        // delay in between reads for stability
}

Now, below is the result from the Serial Monitor.
You can see the X axis at 3. I thaught it would be 1 or 0.

		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		

Then, this is the results when I lean the accelerometer from horizontal to the left, back to horizontal, then to right and back to horizontal.

		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 2		 Z = 2		
		 X = 3		 Y = 2		 Z = 2		
		 X = 4		 Y = 2		 Z = 2		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 3		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 4		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 4		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 3		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 3		
		 X = 4		 Y = 2		 Z = 2		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 5		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 5		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 5		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 3		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 3		 Z = 4		
		 X = 4		 Y = 2		 Z = 2		
		 X = 4		 Y = 2		 Z = 3		
		 X = 4		 Y = 3		 Z = 2		
		 X = 4		 Y = 2		 Z = 2		
		 X = 4		 Y = 2		 Z = 3		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 4		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 4		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 4		
		 X = 4		 Y = 2		 Z = 1		
		 X = 4		 Y = 2		 Z = 3		
		 X = 3		 Y = 2		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 0		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 2		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 0		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 0		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 2		 Y = 1		 Z = 2		
		 X = 2		 Y = 1		 Z = 1		
		 X = 2		 Y = 2		 Z = 3		
		 X = 2		 Y = 1		 Z = 1		
		 X = 2		 Y = 1		 Z = 3		
		 X = 2		 Y = 2		 Z = 1		
		 X = 2		 Y = 2		 Z = 4		
		 X = 2		 Y = 2		 Z = 1		
		 X = 2		 Y = 2		 Z = 4		
		 X = 2		 Y = 2		 Z = 1		
		 X = 2		 Y = 2		 Z = 3		
		 X = 1		 Y = 2		 Z = 2		
		 X = 1		 Y = 2		 Z = 2		
		 X = 1		 Y = 2		 Z = 3		
		 X = 1		 Y = 2		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 2		 Z = 1		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 1		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 1		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 4		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 3		
		 X = 1		 Y = 3		 Z = 2		
		 X = 1		 Y = 2		 Z = 3		
		 X = 1		 Y = 2		 Z = 1		
		 X = 1		 Y = 2		 Z = 4		
		 X = 1		 Y = 2		 Z = 1		
		 X = 1		 Y = 2		 Z = 4		
		 X = 1		 Y = 2		 Z = 1		
		 X = 1		 Y = 2		 Z = 3		
		 X = 1		 Y = 2		 Z = 1		
		 X = 2		 Y = 2		 Z = 2		
		 X = 2		 Y = 2		 Z = 2		
		 X = 2		 Y = 2		 Z = 1		
		 X = 2		 Y = 2		 Z = 3		
		 X = 2		 Y = 2		 Z = 1		
		 X = 2		 Y = 2		 Z = 3		
		 X = 2		 Y = 1		 Z = 1		
		 X = 2		 Y = 2		 Z = 3		
		 X = 2		 Y = 1		 Z = 1		
		 X = 2		 Y = 1		 Z = 3		
		 X = 2		 Y = 1		 Z = 1		
		 X = 2		 Y = 1		 Z = 2		
		 X = 2		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 0		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 0		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 2		 Z = 1		
		 X = 3		 Y = 2		 Z = 3		
		 X = 3		 Y = 2		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 2		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 0		
		 X = 3		 Y = 1		 Z = 4		
		 X = 3		 Y = 1		 Z = 0		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 1		 Z = 1		
		 X = 3		 Y = 1		 Z = 3		
		 X = 3		 Y = 2		 Z = 1

So as you can see, the X axis goes this way (witch I think is wrong or bad shifted)
^3 / <4 / ^3 / >1 / ^3.
if I lean it by the left or wright too much and exceed the very vertical “0”, it goes like I was doing the opposite movement.

Testing the MMA7361L in my project, when I turn to the left or right, in both case the processing test turns left.

Do I have to calibrate somehow the MMA7361L or change my accelerometer ?

If someone has a solution, I take.
Thanks.

Hello,

From our experience, the MMA7361L generally does not need to be calibrated. You are losing a lot of precision by dividing your readings by 100. Could you make your program print the unmodified values from analogRead() for now? There are a couple other things to keep in mind as well:

  • Each reading is centered at VDD/2, so if you are powering the accelerometer with 3.3V, you should expect to read about 1.65 V on an axis when it is not detecting any acceleration.

  • You should expect the accelerometer to detect 1 G of upward acceleration due to gravity even when it is at rest.

How do you have the accelerometer oriented? (Is the board lying flat on a table?) Can you show us a picture or diagram of how you have the MMA7361L connected to your Arduino?

- Kevin

Thanks for your post Kevin.

void setup() {
  Serial.begin(9600);
}

void loop() {
  int sensorValue1 = analogRead(A0);
  int sensorValue2 = analogRead(A1);
  int sensorValue3 = analogRead(A2);
  Serial.print("\t");
  Serial.print("\t");
  Serial.print(" X = ");
  Serial.print(sensorValue1);
  Serial.print("\t");
  Serial.print("\t");
  Serial.print(" Y = ");
  Serial.print(sensorValue2);
  Serial.print("\t");
  Serial.print("\t");
  Serial.print(" Z = ");
  Serial.print(sensorValue3);
  Serial.print("\t");
  Serial.print("\t");
  Serial.println();
  delay(0.0001); 
}

That’s it.

The results without deviding :

		 X = 329		 Y = 360		 Z = 136		
		 X = 326		 Y = 359		 Z = 132		
		 X = 329		 Y = 366		 Z = 141		
		 X = 330		 Y = 367		 Z = 141		
		 X = 326		 Y = 360		 Z = 138		
		 X = 323		 Y = 356		 Z = 133		
		 X = 324		 Y = 364		 Z = 136		
		 X = 330		 Y = 368		 Z = 140		
		 X = 329		 Y = 358		 Z = 135		
		 X = 324		 Y = 362		 Z = 132		
		 X = 327		 Y = 361		 Z = 135		
		 X = 343		 Y = 363		 Z = 135		
		 X = 375		 Y = 355		 Z = 148		
		 X = 379		 Y = 356		 Z = 149		
		 X = 404		 Y = 370		 Z = 152		
		 X = 441		 Y = 369		 Z = 172		
		 X = 451		 Y = 375		 Z = 184		
		 X = 460		 Y = 355		 Z = 197		
		 X = 429		 Y = 379		 Z = 203		
		 X = 481		 Y = 363		 Z = 240		
		 X = 449		 Y = 374		 Z = 269		
		 X = 499		 Y = 344		 Z = 276		
		 X = 492		 Y = 348		 Z = 291		
		 X = 454		 Y = 363		 Z = 308		
		 X = 502		 Y = 363		 Z = 327		
		 X = 487		 Y = 360		 Z = 322		
		 X = 481		 Y = 352		 Z = 316		
		 X = 479		 Y = 357		 Z = 305		
		 X = 494		 Y = 363		 Z = 323		
		 X = 488		 Y = 364		 Z = 318		
		 X = 491		 Y = 356		 Z = 318		
		 X = 483		 Y = 361		 Z = 310		
		 X = 486		 Y = 355		 Z = 326		
		 X = 492		 Y = 354		 Z = 331		
		 X = 503		 Y = 354		 Z = 322		
		 X = 479		 Y = 356		 Z = 310		
		 X = 503		 Y = 367		 Z = 280		
		 X = 445		 Y = 368		 Z = 268		
		 X = 492		 Y = 370		 Z = 242		
		 X = 468		 Y = 352		 Z = 230		
		 X = 467		 Y = 361		 Z = 211		
		 X = 472		 Y = 358		 Z = 205		
		 X = 425		 Y = 368		 Z = 175		
		 X = 430		 Y = 370		 Z = 176		
		 X = 432		 Y = 360		 Z = 182		
		 X = 444		 Y = 356		 Z = 174		
		 X = 431		 Y = 363		 Z = 183		
		 X = 433		 Y = 355		 Z = 148		
		 X = 412		 Y = 364		 Z = 143		
		 X = 419		 Y = 351		 Z = 152		
		 X = 396		 Y = 363		 Z = 169		
		 X = 377		 Y = 370		 Z = 154		
		 X = 374		 Y = 360		 Z = 142		
		 X = 333		 Y = 357		 Z = 110		
		 X = 310		 Y = 389		 Z = 194		
		 X = 269		 Y = 421		 Z = 147		
		 X = 204		 Y = 348		 Z = 114		
		 X = 227		 Y = 352		 Z = 148		
		 X = 237		 Y = 351		 Z = 162		
		 X = 262		 Y = 334		 Z = 206		
		 X = 208		 Y = 365		 Z = 221		
		 X = 178		 Y = 374		 Z = 220		
		 X = 156		 Y = 364		 Z = 216		
		 X = 174		 Y = 359		 Z = 237		
		 X = 199		 Y = 347		 Z = 148		
		 X = 150		 Y = 323		 Z = 287		
		 X = 160		 Y = 355		 Z = 280		
		 X = 205		 Y = 348		 Z = 290		
		 X = 177		 Y = 373		 Z = 321		
		 X = 125		 Y = 355		 Z = 314		
		 X = 129		 Y = 349		 Z = 313		
		 X = 192		 Y = 351		 Z = 315		
		 X = 169		 Y = 392		 Z = 355		
		 X = 166		 Y = 346		 Z = 328		
		 X = 135		 Y = 317		 Z = 321		
		 X = 142		 Y = 337		 Z = 336		
		 X = 177		 Y = 387		 Z = 368		
		 X = 174		 Y = 363		 Z = 366		
		 X = 146		 Y = 334		 Z = 326		
		 X = 145		 Y = 334		 Z = 316		
		 X = 170		 Y = 369		 Z = 366		
		 X = 169		 Y = 368		 Z = 364		
		 X = 175		 Y = 349		 Z = 329		
		 X = 148		 Y = 333		 Z = 315		
		 X = 161		 Y = 370		 Z = 309		
		 X = 155		 Y = 378		 Z = 297		
		 X = 185		 Y = 366		 Z = 278		
		 X = 159		 Y = 357		 Z = 265		
		 X = 162		 Y = 357		 Z = 259		
		 X = 202		 Y = 339		 Z = 255		
		 X = 204		 Y = 358		 Z = 275		
		 X = 218		 Y = 375		 Z = 305		
		 X = 206		 Y = 382		 Z = 212		
		 X = 202		 Y = 378		 Z = 195		
		 X = 219		 Y = 374		 Z = 192		
		 X = 230		 Y = 373		 Z = 189		
		 X = 239		 Y = 369		 Z = 154		
		 X = 261		 Y = 379		 Z = 149		
		 X = 283		 Y = 388		 Z = 153		
		 X = 295		 Y = 383		 Z = 126		
		 X = 304		 Y = 370		 Z = 141		
		 X = 301		 Y = 364		 Z = 144		
		 X = 316		 Y = 381		 Z = 137		
		 X = 327		 Y = 376		 Z = 143		
		 X = 308		 Y = 360		 Z = 135		
		 X = 302		 Y = 363		 Z = 116		
		 X = 336		 Y = 377		 Z = 157		
		 X = 345		 Y = 388		 Z = 164		
		 X = 324		 Y = 367		 Z = 135		
		 X = 298		 Y = 347		 Z = 110		
		 X = 324		 Y = 362		 Z = 132		
		 X = 348		 Y = 385		 Z = 159		
		 X = 326		 Y = 373		 Z = 142		
		 X = 305		 Y = 352		 Z = 120		
		 X = 311		 Y = 355		 Z = 128		
		 X = 329		 Y = 385		 Z = 152		
		 X = 323		 Y = 381		 Z = 150		
		 X = 307		 Y = 363		 Z = 132		
		 X = 301		 Y = 357		 Z = 124		
		 X = 320		 Y = 378		 Z = 144		
		 X = 332		 Y = 382		 Z = 157		
		 X = 311		 Y = 372		 Z = 134		
		 X = 300		 Y = 356		 Z = 123		
		 X = 307		 Y = 375		 Z = 135		
		 X = 323		 Y = 383		 Z = 153		
		 X = 312		 Y = 374		 Z = 143		
		 X = 298		 Y = 363		 Z = 130		
		 X = 303		 Y = 363		 Z = 129		
		 X = 312		 Y = 383		 Z = 140		
		 X = 318		 Y = 383		 Z = 149		
		 X = 306		 Y = 368		 Z = 133		
		 X = 292		 Y = 366		 Z = 124		
		 X = 315		 Y = 374		 Z = 146		
		 X = 319		 Y = 383		 Z = 147		
		 X = 310		 Y = 374		 Z = 141		
		 X = 295		 Y = 364		 Z = 128		
		 X = 306		 Y = 369		 Z = 135		
		 X = 316		 Y = 386		 Z = 150		
		 X = 313		 Y = 373		 Z = 144		
		 X = 299		 Y = 370		 Z = 130		
		 X = 301		 Y = 368		 Z = 128		
		 X = 314		 Y = 388		 Z = 149		
		 X = 312		 Y = 382		 Z = 146		
		 X = 303		 Y = 370		 Z = 134		
		 X = 296		 Y = 367		 Z = 131		
		 X = 314		 Y = 375		 Z = 144		
		 X = 318		 Y = 384		 Z = 150		
		 X = 311		 Y = 374		 Z = 139		
		 X = 296		 Y = 363		 Z = 129		
		 X = 305		 Y = 371		 Z = 138		
		 X = 318		 Y = 386		 Z = 148		
		 X = 309		 Y = 377		 Z = 139		
		 X = 299		 Y = 367		 Z = 133		
		 X = 292		 Y = 373		 Z = 127		
		 X = 315		 Y = 385		 Z = 146		

That’s for : neutral → left → neutral → wright.

[quote]- You should expect the accelerometer to detect 1 G of upward acceleration due to gravity even when it is at rest.
How do you have the accelerometer oriented? (Is the board lying flat on a table?) Can you show us a picture or diagram of how you have the MMA7361L connected to your Arduino?[/quote]
Ok for the G. I forgot this.
But why can’t I get a negative number when I lean it by the right?

I consider this as being the top and make it face “the sky”…

and that as the bottom

Thanks for your help.

I forgot somthing.

I tested the accelerometer in a controller.
I hoocked up the analog stick with the accelerometer.
The battery was almost dead (I didn’t know) and I could turn to the right.
Then the battery died. I changed them and…
The car turn only left. To have it flat forward, I had to turn right.
Changed twice the battery, back to the dead ones and, before they passed away, I could have the right turn.

May be a regulator can bring a help… nop?

As I mentioned, the outputs of the accelerometer are analog voltages centered at VDD/2. The output will be higher than VDD/2 (and lower than VDD) for positive accelerations and lower than VDD/2 (and higher than 0) for negative accelerations. The output voltage will never be negative. This is described in both the product page and the MMA7361L datasheet (found on the Resources tab), so I recommend that you read through those carefully if you have not already.

How are you powering the accelerometer? Can you show us a picture or diagram of how you have it connected?

I would not expect you to be able to use the accelerometer as a drop-in replacement for an analog stick in a controller unless you have been careful to make sure the input and output voltages are all appropriate.

By the way, the line “delay(0.0001);” in your code is not doing anything useful; the Arduino delay function takes an integer, not a float, so you are effectively calling delay() with an argument of 0. Even if it did work, 0.0001 milliseconds (100 nanoseconds) is not long enough to be meaningful delay.

- Kevin

[quote]By the way, the line “delay(0.0001);” in your code is not doing anything useful; the Arduino delay function takes an integer, not a float, so you are effectively calling delay() with an argument of 0. Even if it did work, 0.0001 milliseconds (100 nanoseconds) is not long enough to be meaningful delay.
[/quote]
This was a try and I forgot to replace the good value.
I wanted to see if it could change something when I was learning how all this works.
I’ll put the good one when I’ll be back at home.

When you say VDD, is it the same as VIN ?

About the datasheet ; I’m french and even if I can explain myself as well as possible, some terms and expressions turn me loose.
So I do my best to understand.

I’ll make a diagram to show how I power and connect the accelerometer.

Thanks for you patient repies.
I’ll post all this evening.

VDD is the voltage going to the VDD pin on the MMA7361L. If you are using the version of the board with a voltage regulator, VDD is supplied by the regulator and should be 3.3 V.

- Kevin

Hi.
I’ve been buzy… so…
you can check below the diagram.
Thanks.


Hello.

Thank you for the nicely-drawn wiring diagram. It looks correct to me. Are you still having trouble with the accelerometer?

–David

Yess I still have the same problem.

What I anderstand is that :

  • the signal read still be positive cause of it’s nature. (Voltage. Isn’t it?)
  • put dry like that in the controller, the accelerometer will take only one realy direction. (Left in my case - see the connection of my diagram)
  • if I want to obtain the opposite direction, I’ll have to use more components such as potar, diodes, transistors or…or another accelerometer mounted on the inverse side. :laughing:

I think the best solution is to keep the arduino Uno inside my set, configure to change the values and drive these values out by the Digital Out pins.

What’s the best according to you?

Thanks.

Yes, the nature of the signal and of the Arduino’s ADC is such that the raw reading from the accelerometer will always be positive, but it can represent a positive or negative acceleration. You will need to understand what the raw reading means in terms of voltage; see the documentation for analogRead. You will need to learn what a voltage means in terms of acceleration; see the documentation for the accelerometer. Once you know both of those things, you should be able to write an Arduino program that modifies the raw readings and does the appropriate thing with them. You do NOT need to add additonal electronics. If you have a specific question about one of the steps above, I would be happy to answer it.

I don’t understand your question about the digital out pins.

If you continue to have trouble, please post your latest code along with a description of what you would expect it to do and what it actually does. You should simplify the code as much as possible too.

–David

Thank you.
I’ll try to anderstand more the documentation and try some stuff before doing another step.
I anderstand the basics of coding in javascript but this is new for me so I must walk slowly.

Thanks, I’ll do my homework and come back when I’m a bit ahead.

annother question about this accelerometer ;
What about the Z axis?
It does not react as an altimeter.
Is it a kind of G side sensor?

Thanks.

An accelerometer measures acceleration, not position (altitude) or velocity. In this case there are three accelerometers, one for each axis or direction X, Y and Z.

Thank you.

Hi people.
Is there a way to lock the Zero G or the Self Test.
One of them looks like shifting the X axis at each accidental rumble, fixing a new reference for the pitch.
For my controller, I don’t need that shifting.

Thanks.

Hello.

What do you mean by “lock”? It sounds like you are talking more something that would be better handled by your controller, not the sensor.

- Ryan

Hi.
Long time.
Sorry, I’ve been working on something else.

@ RyanTM.
Explaining “Lock” I mean that I want the Self Test (I think) not to shift the set.
Actually, I’m trying to mod an RC Buggy’s pad for my son.
I’ve hooked the direction analog stick with the accelerometer so he can just rotate the pad left and right to make the car turn.
It works. Almost…
For example when the pad is rotated more than 90° to the left or rumbled at 90°, the 90° shift as 0°. So when after that the pad is back to real zero, the car’s tires set to -90°. So to reset it to normal, I have to rumble the pad with a -90° position.

I had a look on the web to find a solution, and found out the file below from freescale.
I’ll try to tear out of the paragraph “IMPLEMENTATION OF AUTO-ZERO WITH A MICROCONTROLLER” somthing useable. Unless you tell me it’s useless.
I’m not done yet. Hard it is.

If you have some wize advices, I’ll take them.
Thank you.
AN3447.pdf (186 KB)

I don’t think the self test feature is meant to be used during normal operation. Can’t you accomplish what you want with your microcontroller code?

- Ryan

I’m trying to do that.
I’m seeking on the web for examples witch can show me a way.