Go to Post Nothing worth gaining was ever obtained without effort. - Jaine Perotti [more]
Home
Go Back   Chief Delphi > Technical > Programming > Java
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 11-02-2012, 20:06
LukeS LukeS is offline
4272 mentor, 1024 alumnus
AKA: Luke Shumaker
FRC #4272
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Indianapolis, IN
Posts: 60
LukeS is an unknown quantity at this point
Trouble with the AXDL345_I2C accelerometer.

I apologize in advance for creating another accelerometer thread, but none of the others were able to help me, and I didn't want to hijack l0stboy's, in case we're having different problems.

My problem is the one most people are having: I always read 0.0 on all axis.

I have the module connected to the I2C port on the sidecar, yes I2C closest to the NXT connector, not the digital outs next to it.

We are using the new flat ribbon cable to talk to the DSC. One of the connectors was flipped, but we fixed it, per the instructions on the KoP site. It has been verified working by using two PWM servos, and two digital encoders.

I have verified that the pins are connected one-to-one from the accelerometer to the sidecar. I have tested the cable using an ohm-meter, and have while it is connected measured 5.1V on the "5V" pin, and 4.7V on the "SDA" and "SCL". I do not have easy access to an oscilloscope, but can get one if truly necessary.

Looking at the spec sheet for the ADXL345, and the WPILibJ source code, we noticed that the read bit is not set during I2C.read(), so I tried replacing
Code:
registerAddressArray[0] = (byte) registerAddress;
with
Code:
registerAddressArray[0] = (byte) (registerAddress | 0x01);
To clarify, why I did this is because the spec sheet (from Analog Devices) says
Quote:
the 7-bit I2C address for the device is 0x1D, followed by the R/W bit. This translates to 0x3A for a write and 0x3B for a read.
However, this did not fix the problem either.

We have also tried replacing the accelerometer, but it didn't work either.

Here is the code I am running to test the accelerometer:
Code:
package edu.wpi.first.wpilibj.templates;

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

public class RobotTemplate extends IterativeRobot {

	ADXL345_I2C accel;

	public void robotInit() {
		accel = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k2G);
	}

	public void teleopPeriodic() {
		ADXL345_I2C.AllAxes vals = accel.getAccelerations();
		System.out.println(
				" X: " + vals.XAxis+
				" Y: " + vals.YAxis+
				" Z: " + vals.ZAxis);
	}
}
Any help is greatly appreciated.
Reply With Quote
  #2   Spotlight this post!  
Unread 11-02-2012, 23:15
sand500 sand500 is offline
Registered User
FRC #3540 (Wildcat Robotics)
 
Join Date: Jan 2011
Rookie Year: 2011
Location: United States
Posts: 81
sand500 is an unknown quantity at this point
Re: Trouble with the AXDL345_I2C accelerometer.

we had this same problem, when we switched to the flat cable, it worked for a while, but it doesnt work now.
Reply With Quote
  #3   Spotlight this post!  
Unread 12-02-2012, 00:57
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Trouble with the AXDL345_I2C accelerometer.

Ours is working (albeit very noisy) with the default code so the library does not need changing.

- do you have your sidecar power connected?
- did you average some readings and save a zero G offset (not your problem yet)
- are you sure the accelerometer is not plugged in backwards?

I'm not a java expert but should accel be a pointer if you are going to instantiate the class with 'new'?

HTH
__________________
Fast, cheap or working - pick any two!
Reply With Quote
  #4   Spotlight this post!  
Unread 12-02-2012, 03:13
LukeS LukeS is offline
4272 mentor, 1024 alumnus
AKA: Luke Shumaker
FRC #4272
Team Role: Mentor
 
Join Date: Mar 2009
Rookie Year: 2009
Location: Indianapolis, IN
Posts: 60
LukeS is an unknown quantity at this point
Re: Trouble with the AXDL345_I2C accelerometer.

Quote:
Originally Posted by wireties View Post
Ours is working (albeit very noisy) with the default code so the library does not need changing.
Thank you, that is good to know. Now, I am curious though, how it works at all if I'm reading the spec sheet correctly.

Quote:
Originally Posted by wireties View Post
- do you have your sidecar power connected?
Yes, as verified by it running several servos (as mentioned), and on all the power LEDs. However, it was pointed out to me shortly before I left today that it had 24V going in to it (it should have 12V), so that may be the issue. My mind is blown that it was properly running the servos at the correct voltage with twice the voltage running in to it.

Quote:
Originally Posted by wireties View Post
- are you sure the accelerometer is not plugged in backwards?
Yes, we must have checked that 100 times today.

Quote:
Originally Posted by wireties View Post
I'm not a java expert but should accel be a pointer if you are going to instantiate the class with 'new'?
In Java anything that's not a primitive (various sized ints, 32&64 bit floats, boolean and char) is automatically a pointer (or "reference" in Java-speak).
Reply With Quote
  #5   Spotlight this post!  
Unread 12-02-2012, 07:33
wireties's Avatar
wireties wireties is offline
Principal Engineer
AKA: Keith Buchanan
FRC #1296 (Full Metal Jackets)
Team Role: Mentor
 
Join Date: Jan 2006
Rookie Year: 2004
Location: Rockwall, TX
Posts: 1,170
wireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond reputewireties has a reputation beyond repute
Send a message via AIM to wireties
Re: Trouble with the AXDL345_I2C accelerometer.

Quote:
Originally Posted by LukeS View Post
Thank you, that is good to know. Now, I am curious though, how it works at all if I'm reading the spec sheet correctly.
In other systems where I have used I2C, the read/write increment for the address is automagically added/removed by the I2C transceiver - perhaps that is the case here? The I2C clock and data lines originate on the 9403/FPGA so I can't tell looking at the sidecar schematic.


Quote:
Originally Posted by LukeS View Post
Yes, as verified by it running several servos (as mentioned), and on all the power LEDs. However, it was pointed out to me shortly before I left today that it had 24V going in to it (it should have 12V), so that may be the issue. My mind is blown that it was properly running the servos at the correct voltage with twice the voltage running in to it.
They all are 5V beasts (6V for servos) I think but it is surprising the 24V did not heat up the regulators a bit.

Good luck!
__________________
Fast, cheap or working - pick any two!

Last edited by wireties : 12-02-2012 at 07:43.
Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:37.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


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