Chief Delphi

Chief Delphi (http://www.chiefdelphi.com/forums/index.php)
-   Sensors (http://www.chiefdelphi.com/forums/forumdisplay.php?f=173)
-   -   ADXL345 accelerometer problems (http://www.chiefdelphi.com/forums/showthread.php?t=100324)

ggorsuch 15-01-2012 22:40

ADXL345 accelerometer problems
 
We are having trouble getting our accelerometer to work. I have it hooked up to the digital sidecar with I2C, and am getting no reading from it.
We are using the 8 slot crio with java. Everything has been updated to the latest.

Any ideas?

kinganu123 15-01-2012 22:46

Re: ADXL345 accelerometer problems
 
We need more info
How is it wired? What is it wired to? How are you programming it (what is the code)?

ggorsuch 15-01-2012 23:36

Re: ADXL345 accelerometer problems
 
It is wired using the 4 i2c pins of the accelerometer to the 4 i2c pins on the digital sidecar.
Here is our code:
Code:

package edu.wpi.first.wpilibj.templates;


import edu.wpi.first.wpilibj.IterativeRobot;
import edu.wpi.first.wpilibj.*;
import edu.wpi.first.wpilibj.ADXL345_I2C.AllAxes;

public class RobotTemplate extends IterativeRobot {
    ADXL345_I2C accelerometer;
   
    public void robotInit() {
        accelerometer = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k4G);
    }
    public void autonomousPeriodic() {
        ;;
    }
    public void teleopPeriodic() {
        AllAxes ac = accelerometer.getAccelerations();
        System.out.println("X: "+ac.XAxis+" Y: "+ac.YAxis+" Z: "+ac.ZAxis);
    }
   
}


zaphodp.jensen 15-01-2012 23:44

Re: ADXL345 accelerometer problems
 
And all of the wires are straight through? (VCC to VCC, SCL to SCL, SDA to SDA, GND to GND)

And can you get a voltage on SDA and SCL? They should be around 5 volts.

If possible, an oscilloscope would be useful in determining whether or not the I2C bus is working. You should hook up a probe to the SDA line, and confirm that the bits are changing.

ggorsuch 15-01-2012 23:46

Quote:

Originally Posted by zaphodp.jensen (Post 1106536)
And all of the wires are straight through? (VCC to VCC, SCL to SCL, SDA to SDA, GND to GND)

Yes, they are.

zaphodp.jensen 15-01-2012 23:48

Re: ADXL345 accelerometer problems
 
Just checking... ;) And the voltage?

ggorsuch 15-01-2012 23:50

Not sure about the voltage.
I will check it tomorrow.

ggorsuch 16-01-2012 13:31

There is about 4.6 volts on the sda and scl.
I am getting a square wave on the scope, but not really sure what I am looking for.

ggorsuch 16-01-2012 14:27

Got it working!
Used the flat db37 cable included in this years Kop, instead of the old round one.

abrightwell 16-01-2012 16:25

Re: ADXL345 accelerometer problems
 
Interesting. We are having the same problem. We tried replacing the old round cable with the flat one and nothing worked. I'm certain that the flat cable is either bad or just needs to be re-built (currently working on that one). However, I'm curious why the flat cable would work in your situation as opposed to the round cable.

We have hooked our accelerometer up to an o-scope and all seems fine.

Does anyone else have any other suggestions?

ggorsuch 16-01-2012 16:30

Quote:

Originally Posted by abrightwell (Post 1107057)
Interesting. We are having the same problem. We tried replacing the old round cable with the flat one and nothing worked. I'm certain that the flat cable is either bad or just needs to be re-built (currently working on that one). However, I'm curious why the flat cable would work in your situation as opposed to the round cable.

We have hooked our accelerometer up to an o-scope and all seems fine.

Does anyone else have any other suggestions?

Did you flip around the connector as described on the KoP website?

abrightwell 16-01-2012 16:54

Re: ADXL345 accelerometer problems
 
That's what we just did and sure enough it worked. Makes sense as when we Ohm'ed it out, pin 1 went to pin 15 on the other end. I didn't think to check the KoP website, but I'm definitely going to check it out. It still seems like a curious situation that the flat works for the accelerometer but the round doesn't. :-/ Oh well, I'll take it at face value for now.

Thanks for the follow up!

Bob649 05-02-2012 20:31

Re: ADXL345 accelerometer problems
 
Hello all,
We are having the same problem. We are using Java, and I can see traffic on the i2c bus with a scope, but no way to decode it. Signal integrity looks ok, clocking as expected and I can see packets, but no analyzer to decode the traffic.

Symptom is no values returned. We don't have labview and so far I am unable to find the wiring diagram or any diagnostic. Based on this thread I also tried both flat and round cables between cRio and side car.

I used the code in one of the threads and it is simple enough that shouldn't be the issue.

If anyone has it working can you post a photo of the sidecar wiring?

Also, do we have to provide our own pullup resistor on CS? The datasheet says one is required for i2c, but it an external one does not seem to help the situation. Could be two problems though.

Thanks in advance!

Bob

Bob649 07-02-2012 02:57

Re: ADXL345 accelerometer problems
 
Hello all,
(Apologies if replying to myself is bad form, just wanted to let this thread know the problem was solved.)

Hello all,
I found it - it was multiple faulty cables to the sidecar. The only one that works is a new flat cable from this year that I repaired according to the instructions on the KoP site. It looks like I probably had two problems at the beginning and after I fixed the other one, had the faulty cable issue. Once I got it running, it has been stable.

I will post some photos is anyone is interested in seeing some documentation of an end to end system including some scope shots of traffic.
I guess the "bad" cables must be good enough for the low order PWMs and other channels we were using to fool me.

So the moral of the story, even if you are sure your round cable is good, ONLY use a new flat cable without a twist until you get it working. Then switch other items one at a time so if it stops working you know what it was that went wrong.

Thanks to all who replied!

Bob

Alan Anderson 07-02-2012 07:59

Re: ADXL345 accelerometer problems
 
Quote:

Originally Posted by Bob649 (Post 1121531)
Hello all,
(Apologies if replying to myself is bad form, just wanted to let this thread know the problem was solved.)

It's definitely good to follow up with the resolution. That way others who find this thread when searching for information on a similar problem can see how it was fixed.

Quote:

So the moral of the story, even if you are sure your round cable is good, ONLY use a new flat cable without a twist until you get it working.
We've been using an official round cable on our programming testbed for months. It wasn't until a week ago that we tried the I2C connection to an ADXL345, and it took a couple of hours of failure before I remembered some people describing making it work with a ribbon cable instead. So I repaired the KOP cable (chipped of a little plastic by accident in the process), swapped it in, and had instant success.

Has anyone managed to use I2C with the original white 37-pin cable?


All times are GMT -5. The time now is 08:09.

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