working on sensors off season.
trying to read one of the KOP ADXL345, connected via I2C.
Doing
this.adxl345_i2c = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k2G);
then
adxl345_i2c.getAcceleration(ADXL345_I2C.Axes.kX)
getting consistent 0 results back on all three axes.
obvious programming booboo, bug in WPILIB, or do I need to start checking wiring (sidecar cable, etc)???
cgmv123
2
We’ve never had much success with the WPI accelerometer class. This alternate was written last year, but I don’t think it was ever tested. https://github.com/team1306/BadgerbotsLib/blob/master/src/org/badgerbots/lib/Accelerometer2.java
Try setting “SetCompatibilityMode(true)” on the i2c object. That may help.
Mike
Max, Mike, thanks. I didn’t try it without setting compatibility mode
I’m getting sensible data out, the sum of the squares of the 3 axes is pretty constant, regardless of orientation.
Need to read the data sheet to see what I’m looking at for units.
…and also a nice example of interfacing arbitrary I2C devices.