Always High vibration in Z axis IIS3DWB accelerometer
I have got 2 new IIS3Dwb IC from same lot , I made custom PCB for those, connected to shaker and getting acceleration values and showing it through my own developed application.
Problem: Z axis seems defecting /sensitive much higher than x and y axis irrespective of vibration direction orientation.
When no vibration present every axis values seems ok and showing 1g level of gravity.
Both ic s showing same issue
Tried magnet, glue mount but no improvement.
Tried different vibration source , different vibration frequency
Changing pcb orientation didn’t help.
Not using int pins, mcu controlling sampling speed 12.5 khz sampling speed and 6.3khz bandwidth with 16g sensitivity.
Using single axis mode, fifo disabled
Pcb layout below.
When no vibration getting 1g so I believe my g conversion math is ok.
Below is my code in arduino IDE ( not complete code pasted due to length)
//IIS3DWB
#define IIS3DWB_WHO_AM_I 0x0F // should be 0x7B
#define IIS3DWB_CTRL1_XL 0x10
#define IIS3DWB_CTRL3_C 0x12
#define IIS3DWB_CTRL4_C 0x13
#define IIS3DWB_CTRL5_C 0x14
#define IIS3DWB_CTRL6_C 0x15
#define IIS3DWB_CTRL7_C 0x16
#define IIS3DWB_CTRL8_XL 0x17
#define IIS3DWB_OUT_TEMP_L 0x20
#define IIS3DWB_OUT_TEMP_H 0x21
#define IIS3DWB_OUTX_L_XL 0x28
#define IIS3DWB_OUTX_H_XL 0x29
#define IIS3DWB_OUTY_L_XL 0x2A
#define IIS3DWB_OUTY_H_XL 0x2B
#define IIS3DWB_OUTZ_L_XL 0x2C
#define IIS3DWB_OUTZ_H_XL 0x2D
#define IIS3DWB_FIFO_CTRL4 0x0A
----then---
SPI.begin();
SPI.beginTransaction(SPISettings(5000000,MSBFIRST,SPI_MODE3));
writeRegister(IIS3DWB_CTRL1_XL,0x04); // power down and 16g mode
writeRegister(IIS3DWB_FIFO_CTRL4,0x00); // disable fifo
writeRegister(IIS3DWB_CTRL8_XL,0x00); // low pass 6.3khz
writeRegister(IIS3DWB_CTRL6_C,0x01); // single axis mode start with x
writeRegister(IIS3DWB_CTRL1_XL,0xA4); // power on again and 16g mode START WITH 16G
---------then -----
SPI.begin();
SPI.beginTransaction(SPISettings(5000000,MSBFIRST,SPI_MODE3));
writeRegister(IIS3DWB_CTRL1_XL,0x04); // power down and 16g mode
writeRegister(IIS3DWB_CTRL6_C,0x01); // single axis mode x axis
writeRegister(IIS3DWB_CTRL1_XL,0xA4); // power on again and 16g mode START WITH 16G
delay(50);
for(int j=0; j<2048; j++){ ///////loop
////TURN ON ACC
//
memset(rawData, 0, sizeof(rawData)); // reset
readBytes(IIS3DWB_OUTX_L_XL, 6, &rawData[0]); // Read the 6 raw accel data registers into data array
x = (int16_t)(((int16_t)rawData[1] << 8) | rawData[0]) ; // Turn the MSB and LSB into a signed 16-bit value
// make a string for assembling the data to log:
accvalue[j] = x;
}
SPI.end();
------then smilarly for y and z-----
SPI.begin();
SPI.beginTransaction(SPISettings(5000000,MSBFIRST,SPI_MODE3));
writeRegister(IIS3DWB_CTRL1_XL,0x04); // power down and 16g mode
writeRegister(IIS3DWB_CTRL6_C,0x03); // single axis mode z axis
writeRegister(IIS3DWB_CTRL1_XL,0xA4); // power on again and 16g mode START WITH 16G
delay(50);
for(int j=0; j<2048; j++){ ///////loop
memset(rawData, 0, sizeof(rawData)); // reset
readBytes(IIS3DWB_OUTX_L_XL, 6, &rawData[0]); // Read the 6 raw accel data registers into data array
z = (int16_t)(((int16_t)rawData[5] << 8) | rawData[4]) ;
prevCycle = startCycle+6350;
delay(10); /// sampaling timing controll
// make a string for assembling the data to log:
accvalue[j] = z;
}
currentMillis =micros()-bMillis;
accvalue[2050] =currentMillis;
////TURN OFf acc
//SPI.end();
-----------some more functions -----------
////// accelerometer access fuction
void readBytes(uint8_t reg, uint8_t count, uint8_t * dest)
{
digitalWrite(accspi, LOW);
SPI.transfer((reg & 0x7F) | 0x80);
SPI.transfer(dest, count);
digitalWrite(accspi, HIGH);
}
void writeRegister(char registerAddress, char value) {
digitalWrite(accspi, LOW);
SPI.transfer(registerAddress);
SPI.transfer(value);
digitalWrite(accspi, HIGH);
}
I compared IIS3dwb output with LIS3DSH output placing same place same orientation , when shaking at 500 hz lis3dsh showing y axis is having high g and its correct as shaker is shaking in Y axis. However IIS3dwb showing Z axis is sensing higher g values than y axis. Which is surely not true. To crosscheck I changed axis orientation against vibration orientation, but still z axis is sensing high g




In fft view also all axis showing correct frequency but z axis is showing much higher amplitude

Now I am clueless what is wrong, is both IC faulty? or something wrong in settings
Thanks for reading any help appreciated.
