Go to Post Saying that something cannot be done, is always good inspiration for someone to find a way to do it. - Josh Hambright [more]
Home
Go Back   Chief Delphi > Technical > Programming > C/C++
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 01-13-2011, 08:36 PM
ProgrammerMike7 ProgrammerMike7 is offline
Registered User
AKA: Mike
FRC #2200 (MMRambotics)
Team Role: Programmer
 
Join Date: Jan 2010
Rookie Year: 2010
Location: Canada
Posts: 13
ProgrammerMike7 will become famous soon enoughProgrammerMike7 will become famous soon enough
ADXL345_I2C Help

Hello everyone! I have been trying to get the ADXL345 accelerometer working. I have it connected to the I2C spare outputs. Here is my code:

Code:
#include "WPILib.h"

class MyRobot : public IterativeRobot {
	ADXL345_I2C myAccel;
	DriverStationLCD *driverStation;
public:
	MyRobot():
		myAccel(4, ADXL345_I2C::kRange_2G)
	{
		driverStation = DriverStationLCD::GetInstance();
	}
	void TeleopInit() {
		GetWatchdog().SetEnabled(true);
		driverStation->Clear();		
	}
	void TeleopPeriodic() {
		GetWatchdog().Feed();
		
		char xAccelChar[100];
		char yAccelChar[100];

		sprintf(xAccelChar, "Accel X: %f", myAccel.GetAcceleration(ADXL345_I2C::kAxis_X));
		sprintf(yAccelChar, "Accel Y: %f", myAccel.GetAcceleration(ADXL345_I2C::kAxis_Y));
		
		driverStation->Clear();
		driverStation->PrintfLine(DriverStationLCD::kUser_Line1, xAccelChar);
		driverStation->PrintfLine(DriverStationLCD::kUser_Line2, yAccelChar);
		driverStation->UpdateLCD();
		
	}
};
START_ROBOT_CLASS(MyRobot);
When I run this program, the display on the driver station reads:
Accel X: 0.00000
Accel Y: 0.00000

No matter how much the accelerometer is moved around, these values do not change. Does anyone have any ideas as to what I can do to make the accelerometer work?
__________________
Wait (-1)
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 03:54 AM.

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