Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Java (http://www.chiefdelphi.com/forums/forumdisplay.php?f=184)
-   -   Accelerometer Showing All Zeros (http://www.chiefdelphi.com/forums/showthread.php?t=100142)

flyvin 14-01-2012 10:35

Accelerometer Showing All Zeros
 
I'm trying to get the accelerometer to work using Java, but I'm having some trouble. I'm wiring it with I2C and using the "ADXL345_I2C" class. When I try to print out the x, y, and z values using "getAcceleration()", it just prints out zeros for everything.

I've gone over the wiring a bunch of times and it all looks correct to me. We also checked to voltage on the pins and it seems to change when we shake the accelerometer, so I don't think it's broken. Our java and crio are both up to date (as of today). I've never used I2C before, so there might be something obvious I'm missing. Any help would be appreciated.

abrightwell 16-01-2012 13:10

Re: Accelerometer Showing All Zeros
 
We seem to be having the same problem. We will continue to research it, if we resolve it we will report back.

youxinche95 16-01-2012 13:17

Re: Accelerometer Showing All Zeros
 
Did you wire it correctly? We had the saem problem with our gyro, but it turned out it the pwm was not supposed to be in the digi-sidecar.

Good luck!

JewishDan18 16-01-2012 19:49

Re: Accelerometer Showing All Zeros
 
You have the wires going to the special pins on the digital sidecar? There are two sets of four, and you want the set closer to the edge.

sjspry 17-01-2012 00:19

Re: Accelerometer Showing All Zeros
 
I know it doesn't add much, but our team had this same problem last year. We followed the diagram as best we could, and even asked on CD. I guess we can look forward to having the same problem this year, too :)

ggorsuch 17-01-2012 01:22

Are you using the flat ribbon db37 cable included in this years KoP, or the previous round one?

abrightwell 19-01-2012 13:27

Re: Accelerometer Showing All Zeros
 
As promised, we resolved it by following ggorsuch's recommendation. Apparently the older round cable doesn't work for this purpose. Also, be sure to follow the directions here to make sure your flat cable is "built" correctly. Again, thanks ggorsuch for your help on this issue.

ggorsuch 19-01-2012 13:48

It is weird that it doesn't work with the old cable. We had the same problem. It has worked in previous years. It must have to do with the different slot the dio module goes in.

sand500 20-01-2012 22:00

Re: Accelerometer Showing All Zeros
 
Quote:

Originally Posted by abrightwell (Post 1109065)
As promised, we resolved it by following ggorsuch's recommendation. Apparently the older round cable doesn't work for this purpose. Also, be sure to follow the directions here to make sure your flat cable is "built" correctly. Again, thanks ggorsuch for your help on this issue.

we were following that a week ago and we broke our cable... so do we really need to order another one?

sand500 20-01-2012 22:29

Re: Accelerometer Showing All Zeros
 
The sensor manual says
Quote:

Note: The ADXL345 starts in a power saving mode. You must turn it on by writing 0x08 to POWER_CTL
(0x2D) before it will do anything interesting.

so how would someone go about doing this?

nickpeq 21-01-2012 00:03

Re: Accelerometer Showing All Zeros
 
Quote:

Originally Posted by sand500 (Post 1110191)
The sensor manual says



so how would someone go about doing this?

I'm just going off the javadocs, as I've never used accelerometers.
But the "write" method of the I2C class seems useful.

theprgramerdude 21-01-2012 01:17

Re: Accelerometer Showing All Zeros
 
Does the built-in ADXL345_I2C class do this automatically when the constructor is called, or do we have to do something else, like use the I2C class?

JewishDan18 21-01-2012 01:37

Re: Accelerometer Showing All Zeros
 
Quote:

Originally Posted by theprgramerdude (Post 1110286)
Does the built-in ADXL345_I2C class do this automatically when the constructor is called, or do we have to do something else, like use the I2C class?

It does it for you; take a peak at the ADXL345_I2C source code and you can see it right there.

Code:

m_i2c.write(kPowerCtlRegister, kPowerCtl_Measure);

sand500 21-01-2012 15:45

Re: Accelerometer Showing All Zeros
 
this is what we are using for the code:

Code:

ADXL345_I2C acll= new ADXL345_I2C(2,ADXL345_I2C.DataFormat_Range.k8G);
public void teleopPeriodic()
        {       
                hi1 = acll.getAcceleration(ADXL345_I2C.Axes.kX);
                hi2 = acll.getAcceleration(ADXL345_I2C.Axes.kY);
                hi3 = acll.getAcceleration(ADXL345_I2C.Axes.kZ);
                disp(1, "" + hi1 + "                        ");
                disp(2, "" + hi2 + "                        ");
                disp(3, "" + hi3 + "                        ");
        }

disp is a custom method we made to output to the DS LCD
but this gives us just all 0

We also have the accelerometers plugged into the the 2 sets of 4 pins next to the "phone jack".

ggorsuch 21-01-2012 17:59

Re: Accelerometer Showing All Zeros
 
Quote:

We also have the accelerometers plugged into the the 2 sets of 4 pins next to the "phone jack".
You are using more than one accelerometer?


All times are GMT -5. The time now is 13:02.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi