ET-MMA7331L (3-Axis Analog Output Accelerometer)
ET-MMA7331L
ET-MMA7331L
This sensor can give an output for accelerometer in 3-axis (X, Y, Z) with analog output. You can set g-force to measure as 4g or 12g and you can convert output from voltage to g unit by using this equation.
for Voffset is VDD/2 (VDD is power source voltage) and for sensitivity please use the value from this following table.
Table 1: Sensitivity and g-select
After you get Vout by using ADC then you can calculate back to get g-value for each channel (X, Y, Z)
Important: Voltage tolerant of this module is 3.6V, if you work on a 5V MCU please be careful
Sample Code:
//Accelerometer
#define X_OUT A8
#define Y_OUT A9
#define Z_OUT A10
#define Voffset 337 // 3.3/2 = 1.65v -> 1.65*1023/5 = 337.59
#define sensitivity 63 // 0.308 -> 0.308*1023/5 = 63.0168
float x_value = 0;
float y_value = 0;
float z_value = 0;
void setup() {
//Accelerometer Initial
pinMode(X_OUT, INPUT);
pinMode(Y_OUT, INPUT);
pinMode(Z_OUT, INPUT);
}
void loop() {
// Read Accelerometer
x_value = float(analogRead(X_OUT) - Voffset) / sensitivity;
y_value = float(analogRead(Y_OUT) - Voffset) / sensitivity;
z_value = float(analogRead(Z_OUT) - Voffset) / sensitivity;
Serial.print("G x: ");
Serial.print(x_value);
Serial.print("G y: ");
Serial.print(y_value);
Serial.print("G z: ");
Serial.println(z_value);
delay(1000);
}
This program will read value from sensors and calculate g-value back and print out through serial port.
For pin configuration is Pin(6) Sleep = 1 , Pin(8) Self Test = 0 and Pin(7) g-Select you can choose according to table1
Pin Layout:
Reference: Datasheet
Comments
Post a Comment