Hi folks,
I’m writing KX132 data into an array (1024 samples) that I want to use for FFT calculations. Currently, I have the output data rate of the KX132 is set to 200 Hz (although, the issue is the same at 400 Hz). The problem I’m seeing is that the first ~200 samples are read into the array variable just fine, but after 200 only 1 out of about 10 KX132 data readings are written (the other values are initialized 0’s.
Code:
for(int i=0; i<samples; i++)
{
if (kxAccel.getRawAccelBufferData(&myRawData, 0) == true) // Change the ‘1’ to a ‘0’ for 8-bit data.
{
kxAccel.convAccelData(&myData, &myRawData); // Manually convert the raw data to floating point
vReal = myData.zData;
Serial.println(vReal,4);
Serial.println(micros());
}
while(micros() - microseconds < sampling_period_us){
//empty loop
}
microseconds += sampling_period_us;
}
Any insights would be greatly appreciated.