AnsweredAssumed Answered

ADXL345 -  Measure the acceleration of gravity for example, but not generated by a reference vibration pattern

Question asked by microar on Apr 25, 2016
Latest reply on Apr 27, 2016 by STallur

Hello

I'm making a vibration meter with the ADXL345. Which measures the acceleration of gravity for example, but not generated by a reference vibration pattern PCB brand, model 394C06, which produces a signal at 159.2Hz and 1G .
I use SPI 4-wire communication with a sampling rate of 800 in the range of 2G.
The system initially measured the offset you have and then uses it to compensate for soft displacement and bring to zero the measurement, this works well, the measurement unlit generated is very low almost 0g.
Use the data ready interrupt to alert the micro (ATTiny1634) I have the information available.
Data captured for 1 second (800 samples which they rest each offset), performed and indicated the average value.
This works for me if the value is that of gravity by moving the plate with the sensor, but if I put it on vibration generated not is almost nothing.

Code:
Sensor configuration by SPI is:

SPI_WR(DATA_FORMAT,RANGE_2G); // FULL_RES Bit 13-BIT MODE,4-wire SPI,right-justified mode with sign extension
SPI_WR(FIFO_CTL, Bypass);
SPI_WR(INT_MAP,0x00);
SPI_WR(BW_RATE, BRate_800);
SPI_WR(INT_ENABLE,DATA_READY);  //Data Ready


The start of measurement is:

SPI_WR(BW_RATE,BRate_800);
SPI_WR(POWER_CTL, MEASURE);
SPI_WR(INT_MAP,0x00);
SPI_WR(INT_ENABLE,DATA_READY);


Reading SPI data is:

unsigned int data[6]={0,0,0,0,0,0};
CS_L; 

    SPI_RD(ADXL_M_Lee|addr);

  // CalibraX, CalibraY, CalibraZ= Offset

    for(uint8_t i=0; i<veces; i++)

    {

// spi_transfer(0x00);
data[i] = SPI_RD(DEVID);

    }

    CS_H;

 

valor16=((((int)data[1]) << 8) |(int)data[0]);
DatosX=valor16-CalibraX;
valor16=((((int)data[3]) << 8) |(int)data[2]);
DatosY=valor16-CalibraY;

 

valor16=((((int)data[5]) << 8) |(int)data[4]);
DatosZ=valor16-CalibraZ;

 


Can be wrong ?.

Outcomes