nagimov / adxl345spi

ADXL345 three-axis accelerometer reader (SPI interface)
GNU General Public License v3.0
62 stars 23 forks source link

sometimes the values are all zeroes when running adxl345spi #7

Closed KevinBaileyCrum closed 3 years ago

KevinBaileyCrum commented 3 years ago

when running sudo adxl345spi command occasionally I run into issues whereby all my values are 0.

example :

pi@raspberrypi:~/adxl345spi $ sudo adxl345spi
time = 0.000, x = 0.000, y = 0.000, z = 0.000
time = 0.200, x = 0.000, y = 0.000, z = 0.000
time = 0.400, x = 0.000, y = 0.000, z = 0.000
time = 0.600, x = 0.000, y = 0.000, z = 0.000
time = 0.801, x = 0.000, y = 0.000, z = 0.000
time = 1.001, x = 0.000, y = 0.000, z = 0.000
time = 1.201, x = 0.000, y = 0.000, z = 0.000
time = 1.401, x = 0.000, y = 0.000, z = 0.000
time = 1.601, x = 0.000, y =``` 0.000, z = 0.000
time = 1.801, x = 0.000, y = 0.000, z = 0.000
time = 2.001, x = 0.000, y = 0.000, z = 0.000
time = 2.202, x = 0.000, y = 0.000, z = 0.000
time = 2.402, x = 0.000, y = 0.000, z = 0.000
time = 2.602, x = 0.000, y = 0.000, z = 0.000
time = 2.802, x = 0.000, y = 0.000, z = 0.000
time = 3.002, x = 0.000, y = 0.000, z = 0.000
time = 3.202, x = 0.000, y = 0.000, z = 0.000
time = 3.402, x = 0.000, y = 0.000, z = 0.000
time = 3.603, x = 0.000, y = 0.000, z = 0.000
time = 3.803, x = 0.000, y = 0.000, z = 0.000
time = 4.003, x = 0.000, y = 0.000, z = 0.000
time = 4.203, x = 0.000, y = 0.000, z = 0.000
time = 4.403, x = 0.000, y = 0.000, z = 0.000
time = 4.603, x = 0.000, y = 0.000, z = 0.000
time = 4.803, x = 0.000, y = 0.000, z = 0.000
25 samples read in 5.03 seconds with sampling rate 5.0 Hz
Done

sometimes this happens halfway through the command. For example when running sudo adxl345spi -f 3200

code snippet cut
time = 0.814, x = -0.047, y = -0.125, z = 1.016
time = 0.814, x = -0.031, y = -0.516, z = 1.242
time = 0.815, x = -0.031, y = -0.133, z = 1.016
time = 0.815, x = -0.016, y = -0.133, z = 1.008
time = 0.815, x = 0.000, y = -0.164, z = 0.969
time = 0.816, x = -0.016, y = -0.117, z = 1.000
time = 0.816, x = -0.102, y = -0.109, z = 1.047
time = 0.817, x = 0.117, y = -0.172, z = 1.047
time = 0.817, x = 0.000, y = -0.148, z = 1.023
time = 0.818, x = -0.031, y = -0.141, z = 1.000
time = 0.818, x = -0.023, y = -0.141, z = 1.000
time = 0.818, x = -0.031, y = 0.156, z = 0.992
time = 0.819, x = 0.000, y = -0.148, z = 1.023
time = 0.819, x = -0.039, y = -0.148, z = 1.031
time = 0.820, x = -116.270, y = -116.457, z = -0.457
time = 0.820, x = 0.000, y = 0.000, z = 0.000
time = 0.820, x = 0.000, y = 0.000, z = 0.000
time = 0.821, x = 0.000, y = 0.000, z = 0.000
time = 0.821, x = 0.000, y = 0.000, z = 0.000
time = 0.822, x = 0.000, y = 0.000, z = 0.000
time = 0.822, x = 0.000, y = 0.000, z = 0.000
time = 0.822, x = 0.000, y = 0.000, z = 0.000
time = 0.823, x = 0.000, y = 0.000, z = 0.000
time = 0.823, x = 0.000, y = 0.000, z = 0.000
time = 0.824, x = 0.000, y = 0.000, z = 0.000
time = 0.824, x = 0.000, y = 0.000, z = 0.000
time = 0.824, x = 0.000, y = 0.000, z = 0.000
time = 0.825, x = 0.000, y = 0.000, z = 0.000
time = 0.825, x = 0.000, y = 0.000, z = 0.000
time = 0.826, x = 0.000, y = 0.000, z = 0.000
time = 0.826, x = 0.000, y = 0.000, z = 0.000
... zeros continue

typically once im in an ALL ZEROES phase the only way to get out of this is to reboot the pi.

any ideas as to why? Suggestions? It is very hard for me to determine exactly when/why/what behavior causes these errors. Trying to keep finding a repeatable occurrence but cannot.

nagimov commented 3 years ago

The fact that it locks in a buggy state and reports only zeros until the next reboot points to a likely issue with SPI driver rather than the adxl reader code. Can you retry with a fresh install of latest Raspbian?

KevinBaileyCrum commented 3 years ago

turns out our cabling was too long and we lost the spi register