Go to Post [*]"Dewtoxification" is a real plague among teenagers. - JesseK [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

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #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
 


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 08:32.

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