AnsweredAssumed Answered

LSM303AGR reading weird values

Question asked by Theresa Lichtenberger on Mar 9, 2018
Latest reply on Mar 19, 2018 by Theresa Lichtenberger

Hey! I am using the accelerometer LSM303AGR to read some acceleration values on external interrupt. If the threshold is overcome, and interrupt will be triggered and in the ISR, I am reading the FIFO of the accelerometer (I am using STM32F405 btw). The values seem to be correct half of the time as shown below. As you can see in the third interrupt and fifo reading, the zAxis exceeded the threshold and then, out of nowhere, the axis-values are getting weird (and wrong!). They won't return back to normal and therefore, no more interrupts are triggered. If I stop, reset and run it again, no interrupts can be triggered because the values are still weird and wrong. The only thing that helps is to cut the power supply for a second and plug it in again. But even that does not help sometimes. 

readINT1_SRC: 86
FIFO samples: xAxis exceeds threshold
x: 3189.199951 y: -375.200012 z: 750.400024
x: 3564.399902 y: -187.600006 z: 1125.599976
x: 3189.199951 y: -187.600006 z: 1125.599976
x: 2251.199951 y: 0.000000 z: 1125.599976
x: 0.000000 y: -187.600006 z: 1125.599976
x: -2063.600098 y: 375.200012 z: 750.400024
x: -2814.000000 y: 562.799988 z: 750.400024
x: -3752.000000 y: 375.200012 z: 938.000000
x: -2626.399902 y: 562.799988 z: 938.000000
x: -1313.199951 y: 562.799988 z: 938.000000
x: -562.799988 y: 0.000000 z: 938.000000
x: -562.799988 y: 187.600006 z: 938.000000
x: -562.799988 y: 0.000000 z: 938.000000
x: -187.600006 y: 0.000000 z: 938.000000
x: 187.600006 y: 0.000000 z: 750.400024
x: 187.600006 y: 0.000000 z: 750.400024
x: 187.600006 y: 0.000000 z: 750.400024
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: -187.600006 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 187.600006 y: 0.000000 z: 938.000000
x: 187.600006 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 187.600006 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
x: 0.000000 y: 0.000000 z: 938.000000
readINT1_SRC: 101
FIFO samples: zAxis exceeds threshold
x: 1125.599976 y: 562.799988 z: 3564.399902
x: 187.600006 y: 938.000000 z: 4690.000000
x: -750.400024 y: 750.400024 z: 5252.799805
x: -1688.400024 y: 375.200012 z: 0.000000
x: 469.000000 y: 0.000000 z: 562.799988
x: -187.600006 y: 0.000000 z: 140.699997
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
x: 0.000000 y: 140.699997 z: -187.600006
readINT1_SRC: 86
FIFO samples: xAxis exceeds threshold
x: -3189.199951 y: 562.799988 z: 938.000000
x: 0.000000 y: -938.000000 z: 0.000000
x: -2720.199951 y: 375.200012 z: 1125.599976
x: 0.000000 y: -938.000000 z: 0.000000
x: 0.000000 y: -938.000000 z: 0.000000
x: -375.200012 y: -4127.200195 z: 2438.800049
x: -375.200012 y: -4314.799805 z: 2532.600098
x: -375.200012 y: -4314.799805 z: 2532.600098
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -375.200012 y: -4127.200195 z: 2438.800049
x: -375.200012 y: -4314.799805 z: 2532.600098
x: -375.200012 y: -4314.799805 z: 2532.600098
x: -375.200012 y: -4314.799805 z: 2532.600098
x: -375.200012 y: -4127.200195 z: 2532.600098
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -375.200012 y: -4314.799805 z: 2438.800049
x: -375.200012 y: -4314.799805 z: 2532.600098
x: -469.000000 y: -4127.200195 z: 2532.600098
x: -375.200012 y: -4314.799805 z: 2438.800049
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -281.399994 y: -4221.000000 z: 2532.600098
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -469.000000 y: -4221.000000 z: 2532.600098
x: -469.000000 y: -4221.000000 z: 2438.800049
x: -375.200012 y: -4221.000000 z: 2532.600098
x: -375.200012 y: -4221.000000 z: 2438.800049
x: -375.200012 y: -4127.200195 z: 2438.800049
x: -281.399994 y: -4314.799805 z: 2438.800049
x: -375.200012 y: -4221.000000 z: 2532.600098

 

I have attached my code to this post. So you can see the code I have written. Maybe this will help for finding a solution.

 

I appreciate every advice and help you can give me, thank you in advance!

Attachments

Outcomes