Skip to main content
Graduate
December 6, 2023
Solved

lis2dw12

  • December 6, 2023
  • 2 replies
  • 2129 views

Hello,

I'm currently working with a custom board designed to read digital values from an accelerometer, specifically from the OUT_X, OUT_Y, and OUT_Z registers. However, I've encountered an issue: despite the accelerometer being physically stable, I am observing a significant number of peaks in the readings. These peaks consistently show an amplitude of around +/-250 units from the base level, which seems unusual.

For context, the values I'm observing are 16-bit, and I'm operating the device under a 2G high-speed setting with an 800Hz Output Data Rate (ODR). I'm aware that the effective resolution is 14 bits, as the values are left-justified, with the least significant 2 bits not holding valid information. Given this, I would normally expect any inaccuracies to be within +/-7 units, not the large deviations I'm seeing.

When I move the board, the readings for X, Y, and Z change as expected, which further puzzles me about these unexpected steady-state peaks. Are such peaks normal under these settings, or is there a potential issue I should be looking into?

Thank you for your insights.

 

image.png

    This topic has been closed for replies.
    Best answer by sde c.1

    The problem was intermittent and didn't happen often. However, when I applied a debugger at the moment the problem finally occurred, I noticed that the high byte was toggling between values when a peak occurred.

    Once I saw this, the problem became clear. It had something to do with reading the registers while the output registers were updating.

    Although the BDU bit was correctly set, there was another issue in the code. I also needed to set the IF_ADD_INC bit and send an additional 8 clock pulses to the SPI to read the entire 16 bits at once.

    Now, everything is working perfectly!

     

    2 replies

    Technical Moderator
    December 11, 2023

    Hi @sde c.1 ,

    Have you enabled the BDU bit in reg 21h?

    sde c.1Author
    Graduate
    December 12, 2023

    BDU is set.

    It seems that most of the times there are no issues, and somethimes i see these spikes.

    Maybe this can be vibration that i cannot feel myself...

     

    Technical Moderator
    December 12, 2023

    Hi @sde c.1 ,

    Yes, it seems a disturbance. Try to keep the device in an environment as isolated as possible.

    sde c.1AuthorAnswer
    Graduate
    December 15, 2023

    The problem was intermittent and didn't happen often. However, when I applied a debugger at the moment the problem finally occurred, I noticed that the high byte was toggling between values when a peak occurred.

    Once I saw this, the problem became clear. It had something to do with reading the registers while the output registers were updating.

    Although the BDU bit was correctly set, there was another issue in the code. I also needed to set the IF_ADD_INC bit and send an additional 8 clock pulses to the SPI to read the entire 16 bits at once.

    Now, everything is working perfectly!