Hi all,
I have continued working on my Arduino project to measure vibration using the ADXL335 accelerometer (see the previous post here). At this point, I have been capable of reading the Frecuency at which a calibration exciter is vibrating (160Hz) using the Arduino as a DAQ and procesing the data using Excel.
Now, I would like to measure the acceleration that is provieded by the calibration exciter (please, check the datasheet here ). According to the specifications, the acceleration is 10m/s^2.
At this point, I have tried to use the following formula:
z_acc = (((Zread - 326)*9.81)/330);
where Z read is the readed value from the analog input for the Z axis, and 326 the value given by default by the sensor in that axis due to the gravity force.
My point is that I am capable of reading "something" but I am not getting those 10m/s^2. ¿Could any body help me?
I attach the code that I am using, as you can see, now I am not using the "calibration" function
//ADXL335 calibration+acc test
int Xread = 0;
int Yread = 0;
int Zread = 0;
int average = 10;
int i;
double z_acc = 0;
//key to calibrate
boolean key = true;
//Calibration offsets;
#define readings 100
int Z_calib[readings];
long Z_calib_sum;
int Z_calib_value = 326;
void setup()
{
Serial.begin(115200);
}
void loop()
{
if (key == false)
{
calibrate();
}else{
Zread = analogRead(A2);
z_acc = (((Zread - 326)*9.81)/330);
Serial.println(z_acc);
}
}
void calibrate()
{
for (i = 0; i<=readings; i++)
{
Z_calib[i] = analogRead(A2);
delay(1);
}
for (i = 0; i<=readings; i++)
{
Z_calib_sum += Z_calib[i];
}
Z_calib_value = Z_calib_sum/readings;
key = false;
}