Giter Site home page Giter Site logo

adxl355-python's People

Contributors

gpvidal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

adxl355-python's Issues

Incorrect results

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?

Problem with read_multiple_data() function

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.

The example that you shows on READ ME is not good.

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.

Does not appear to return the correct values

The get_raw_axes() function does not appear to return the correct values when used with an ADXL355.

def get_axes(self):
"""
Gets the current data from the axes.
Returns:
dict: Current value for x, y and z axis
"""
# Reading data
raw_data = self.read_multiple_data(
[XDATA1, XDATA2, XDATA3, YDATA1, YDATA2, YDATA3, ZDATA1, ZDATA2, ZDATA3]
)
x_data = raw_data[0:3]
y_data = raw_data[3:6]
z_data = raw_data[6:9]
# Join data
x_data = (x_data[0] >> 4) + (x_data[1] << 4) + (x_data[2] << 12)
y_data = (y_data[0] >> 4) + (y_data[1] << 4) + (y_data[2] << 12)
z_data = (z_data[0] >> 4) + (z_data[1] << 4) + (z_data[2] << 12)
# Apply two complement
if x_data & 0x80000 == 0x80000:
x_data = ~x_data + 1
if y_data & 0x80000 == 0x80000:
y_data = ~y_data + 1
if z_data & 0x80000 == 0x80000:
z_data = ~z_data + 1
# Return values
return {'x': x_data, 'y': y_data, 'z': z_data}

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!

Issue with reading data

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}

Apply filtering (LP )

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?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.