gpvidal / adxl355-python Goto Github PK
View Code? Open in Web Editor NEWPython 3 library to connect ADXL355 PMDZ accelerometer on Raspberry Pi
Python 3 library to connect ADXL355 PMDZ accelerometer on Raspberry Pi
I dont know which unit have the output of the reading. It doesnt seem m/s^2 or g.
I think there is a problem with the two's complement implementation in this library. It is correct for positive numbers, but for negative numbers, it is incorrect. The math used to catch and convert negative numbers is:
if x_data & 0x80000 == 0x80000:
x_data = ~x_data + 1
However, this just gives a negative version of x_data, it doesn't truly take it out of 2s complement form. For example, if the number received from the sensor is "1001 0110 0000 0010 1101", the correct decimal integer of that is -434131. However, the above code gives -614445, which is incorrect.
I think it could be corrected as follows:
if x_data & 0x80000 == 0x80000:
x_data = x_data - 2**20
Am I wrong/confused on this?
There is a problem with the read_multiple_data() function in this library. It assumes you can send arbitrary register addresses to the ADXL355 and that it will give you the values in those registers. However, the ADXL355 implements an autoincrement scheme for multi-byte transactions. You send the first address, keep toggling the clock, and it will autoincrement and send the data out of the next register, then the next, etc. Subsequent addresses sent on the MOSI line will be ignored. After the first byte (which gives the start address and R/W bit), the ADXL355 ignores the MOSI line. Consequently, you can read multiple bytes, but you can only read them in order.
For example if you do read_multiple_data([0x0A, 0x09, 0x08]) you will not get back the values you think because the ADXL355 ignores the 0x09 and 0x08 bytes. Instead you will get back the values out of registers 0x0A, 0x0B, 0x0C.
Im still having problems with this code and the raspberry pi. First, the code dont run in python3 but yes in python2. Also, the ouput os the code dont match with the sensitivity of the sensor, if you see the example that you put on "read me" there are values like 787212 or 3152 and those values are out of the sensitivy range. I hope that you can help me.
Is there any option to change the sampling rate to 100hz using adxl355.py?
The get_raw_axes() function does not appear to return the correct values when used with an ADXL355.
Lines 124 to 156 in 5fcd5e4
I can open a PR with my function that I've added to your class to return gravity per axis. If you're interested, let me know!
I am getting the data from the pi as follows, but I am not sure if it is correct as you can see sometimes it gives values which is not 6 digit. Need help. Thanks.
{'x': 339884, 'y': 82937, 'z': -655690}
{'x': 384940, 'y': 91123, 'z': -983407}
{'x': 524202, 'y': 41977, 'z': 262308}
{'x': -573351, 'y': -947174, 'z': -790140}
{'x': -565167, 'y': -955370, 'z': 3728}
I want to apply low pass filter with corner frequency of 2hz, meaning remove anything above 2hz in adxl355 got accelerometer. How do I achieve that?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.