Go Down

Topic: MMA7361 accelerometer and jittering values (Read 453 times) previous topic - next topic

usenetfan

Nov 23, 2017, 11:31 am Last Edit: Nov 23, 2017, 11:39 am by usenetfan
Hi all,

I have the aforementioned chip, but I was wondering why it send a lot of jittering values even if it lies flat on the table. I am using the standard sample code that is available for this chip, but I am seeing values that bounce back and forth even if the chip is motionless.

This is the code:



#include <AcceleroMMA7361.h>
AcceleroMMA7361 accelero;
int x;
int y;
int z;
void setup()
{
 Serial.begin(9600);
 accelero.begin(13, 12, 11, 10, A0, A1, A2);
 accelero.setARefVoltage(5); //sets the AREF voltage to 3.3V
 accelero.setSensitivity(HIGH); //sets the sensitivity to +/-1.5G
 accelero.calibrate();
}
void loop()
{
 x = accelero.getXAccel();
 y = accelero.getYAccel();
 z = accelero.getZAccel();
 Serial.print("\ny: ");
 Serial.print(y);
 Serial.print(" \ty: ");
 Serial.print(y);
 Serial.print(" \tz: ");
 Serial.print(z);
 //Serial.print("\tG*10^-2");
 delay(1000); //make it readable
}




Here is a sample of its output:


Calibrating MMA7361011..................................................
DONE
y: -35    y: -35    z: 75
y: -17    y: -17    z: 178
y: -8    y: -8    z: 191
y: -5    y: -5    z: 190
y: -5    y: -5    z: 183
y: -3    y: -3    z: 189
y: 0    y: 0    z: 196
y: 1    y: 1    z: 194
y: -1    y: -1    z: 188
y: -2    y: -2    z: 189
y: 0    y: 0    z: 194
y: 1    y: 1    z: 193
y: -2    y: -2    z: 188
y: -2    y: -2    z: 191
y: 2    y: 2    z: 195
y: 1    y: 1    z: 190
y: -3    y: -3    z: 190
y: 0    y: 0    z: 195
y: 1    y: 1    z: 194
y: -1    y: -1    z: 188
y: -2    y: -2    z: 188
y: 2    y: 2    z: 195
y: 1    y: 1    z: 191
y: -2    y: -2    z: 188
y: -1    y: -1    z: 193
y: 2    y: 2    z: 193
y: -1    y: -1    z: 188
y: -2    y: -2    z: 190


So my question is, is there a way to dampen the sensitivity? Ideally I would like to see the exact same value all the time if the thing doesn't move.

Many thanks!

wildbill

Try changing the setSensitivity call to setSensitivity(false).

You might want to fix your copy/paste error and show the value of the x axis too.

jremington

#2
Nov 24, 2017, 05:48 pm Last Edit: Nov 24, 2017, 05:49 pm by jremington
Quote
Ideally I would like to see the exact same value all the time if the thing doesn't move.
All sensors exhibit internal noise, so that won't happen.

You can average several values, or use a low pass filter to smooth the data, but that slows down the response.

usenetfan

Yes, I found out that using a delta between the latest value and the new one, I can adjust the sensitivity, and speed is not an issue in what I built.

Thank you both!

Go Up