# Huge spikes and sudden offset in accelerometer data (FRDM-K64F & ADXL357)

I'm working with vibration analysis on electric motors (AC). I have a mBed FRDM-K64F with a EVAL-ADXL357 connected to it - mounted onto a motor.

The device samples from the FIFO 4000 times per second, and afterwards converts the samples to m/s^2 and transmits them to our server. It does this one time per hour.

The first 4000 samples (after the microcontroller has been reset) look like this (converted to m/s^2) - The data here looks fine, except for the huge spikes:

The following 4000 samples look like this:

And the third, and following, package(s) of 4000 samples look like this:

When I reset the microcontroller the same "process" happens again.

The piece of code I use to sample from the accelerometer is the following:

SPI accl(PTD2, PTD3, PTD1); //mosi, miso, sclk
DigitalOut cs(PTD0); //Chip Select
int idRawData = 0;
uint32_t axisMeasures[37000];
Ticker tickRawData;
float sampleRateRawData = 0.00025;

void tickFuncRawData() {

cs = false;
accl.write((0x11<<1) | 0x01);
for(int i = 0; i < 9; i++) {
axisMeasures[i+idRawData*9] = accl.write(0xAA);
}
cs = true;

idRawData++;

if (idRawData == 4000) {
tickRawData.detach();
}
}

tickRawData.attach(&tickFuncRawData, sampleRateRawData);


In order to find out what causes the problem, I have implemented some "printf" logging to output data at various stages in the sampling and converting process, and these are the first 9 entries in the axisMeasures array, from the third package of 4000 samples (the third chart):

No. 0. Value = 86  //x
No. 1. Value = 102 //x
No. 2. Value = 65  //x
No. 3. Value = 85  //y
No. 4. Value = 86  //y
No. 5. Value = 32  //y
No. 6. Value = 88  //z
No. 7. Value = 27  //z
No. 8. Value = 192 //z


The corresponding x, y and z values converted to m/s^2 are:

270.96, 267.62, 276.32


So basically the problem is that huge spikes and later a huge offset are/is gradually "added" to the samples. These extremely high values are not generated naturally by the vibration coming from the motor.

I hope you can help me solve this issue. Please let me know if your need more information AND please bear with me - I'm not so experienced when it comes to electrical engineering :-)

Thanks!