Go to Post Thank God for the Technokats. - Koko Ed [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, 18:16
l0stboy l0stboy is offline
Registered User
FRC #4064 (InZombiacs)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 22
l0stboy is an unknown quantity at this point
Accelerometer java code problems. Returns zero.

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package edu.wpi.first.wpilibj.templates.subsystems;

import edu.wpi.first.wpilibj.ADXL345_I2C;
import edu.wpi.first.wpilibj.command.Subsystem;
import edu.wpi.first.wpilibj.templates.RobotTemplate;
import edu.wpi.first.wpilibj.Accelerometer;

/**
*
* @author Developer
*/
public class ADXL extends Subsystem{
public ADXL()
{
super("accelerometer");

}

protected void initDefaultCommand()
{

}
public void printAcceleration()
{
ADXL345_I2C.AllAxes aa = RobotTemplate.getADXL().getAccelerations();
System.out.println("X: " + aa.XAxis);
System.out.println("y: " + aa.YAxis);
System.out.println("z: " + aa.ZAxis);
}

}
here is our code. We're not sure why our accelerometer outputs zeros. Is it initialized right? Is there a better way to get the axis values?

We're calling it from RobotTemplate, where the accelerometer is initialized as:adxl = new ADXL345_I2C(1, ADXL345_I2C.DataFormat_Range.k2G);



We're wired to the I2C on the sidecar using a pair of double-female wires (0V,SCL,SDA,5V) so we're pretty sure we don't have wiring issues.
__________________

Pedro
Ocala InZombiacs

Last edited by l0stboy : 11-02-2012 at 19:20. Reason: wiring details, new code
Reply With Quote
  #2   Spotlight this post!  
Unread 12-02-2012, 08:51
java4first java4first is offline
(Java) Programming Mentor
AKA: Stu
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 2011
Location: Goffstown, NH
Posts: 56
java4first is an unknown quantity at this point
Re: Accelerometer java code problems. Returns zero.

For what it's worth - we're having exactly the same problem. The connectivity in the wiring is there, the pin connections are correct, and the test code doesn't get much simpler. But it seems to be a common issue if you look at other threads.
Reply With Quote
  #3   Spotlight this post!  
Unread 14-02-2012, 05:59
java4first java4first is offline
(Java) Programming Mentor
AKA: Stu
FRC #0501 (Power Knights)
Team Role: Mentor
 
Join Date: Nov 2010
Rookie Year: 2011
Location: Goffstown, NH
Posts: 56
java4first is an unknown quantity at this point
Re: Accelerometer java code problems. Returns zero.

For what it's worth - in our case, the fix for this was to switch from the 'round' cable to the ribbon cable in connecting the digital sidecar to the cRIO module. We did that and all of a sudden starting getting values.

We are using the older 8-slot cRIO, and two of the 3 wire PWM cables (with two wires in each) to connect the accelerometer to the I2C connection on the sidecar.

Our test code was pretty much the same as the first posting.
Reply With Quote
  #4   Spotlight this post!  
Unread 14-02-2012, 07:07
Intel i7 Intel i7 is offline
Registered User
FRC #3540 (Wildcat Robotics)
Team Role: Driver
 
Join Date: Feb 2010
Rookie Year: 2010
Location: N.C.
Posts: 39
Intel i7 is an unknown quantity at this point
Re: Accelerometer java code problems. Returns zero.

The weird thing is if I remember correctly our problem was fixed by switching to the flat cable, but nothing else worked with the flat cable for us
__________________
Driver
Programmer
Webcoder/Designer

Code:
http://www.chiefdelphi.com/forums/showthread.php?t=102329
Making our own custom dashboard system/framework!
Reply With Quote
  #5   Spotlight this post!  
Unread 15-02-2012, 15:16
l0stboy l0stboy is offline
Registered User
FRC #4064 (InZombiacs)
Team Role: Programmer
 
Join Date: Jan 2012
Rookie Year: 2012
Location: United States
Posts: 22
l0stboy is an unknown quantity at this point
Re: Accelerometer java code problems. Returns zero.

We have always been using the flat cable, but the problem persists.
__________________

Pedro
Ocala InZombiacs
Reply With Quote
  #6   Spotlight this post!  
Unread 17-02-2012, 22:51
StephenNutt StephenNutt is offline
Registered User
FRC #0172 (Falgor)
Team Role: Mentor
 
Join Date: Jan 2009
Rookie Year: 2007
Location: Falmouth, ME
Posts: 37
StephenNutt is an unknown quantity at this point
Re: Accelerometer java code problems. Returns zero.

I had terrible issues trying to read the accelerometer. The eventual solution was to use a short I2C cable between the accelerometer and the digital breakout board. Keep it under 12", if that does not work make one that is 6" long and see if that help.

Good luck, I feel your pain

Steve
Reply With Quote
  #7   Spotlight this post!  
Unread 18-02-2012, 12:28
Herbblood's Avatar
Herbblood Herbblood is offline
Knowledgeable
AKA: Ally
FRC #3044 (OxBE4)
Team Role: Programmer
 
Join Date: Oct 2011
Rookie Year: 2008
Location: Ballston Spa
Posts: 247
Herbblood is an unknown quantity at this point
Re: Accelerometer java code problems. Returns zero.

We had the same problem and switching to a ribbon ccable fixed it, but are you sure that aa.XAxis); is right? we do "x is" +accel.getAcceleration(ADXL345_I2C.Axes.kX); well about that,
__________________
Off to WPI!
Go OxBE4
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 13:30.

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