Go to Post Why does school have to get in the way of more important things like FIRST? When would we ever need to know about the stuff there teaching in here? - Briansmithtown [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

 
Reply
Thread Tools Rate Thread Display Modes
  #16   Spotlight this post!  
Unread 23-01-2013, 20:08
ekapalka's Avatar
ekapalka ekapalka is offline
Registered User
FRC #3216
 
Join Date: Dec 2012
Location: Bermuda
Posts: 277
ekapalka has a spectacular aura aboutekapalka has a spectacular aura about
Re: ADXL345_I2C Help

bump. We're having the same issue. Here's ou code:
Code:
#include <WPILib.h>
class DefaultRobot : public SimpleRobot
{	
	ADXL345_I2C *acc;                       
public:
	DefaultRobot(void)
	{	
		acc = new ADXL345_I2C (4, ADXL345_I2C::kRange_2G);
	}
	void Autonomous(void)
	{
			while(IsAutonomous())
			{
			}				
	}
	void OperatorControl(void)
	{
		DriverStationLCD *dsLCD = DriverStationLCD::GetInstance();
		while (IsOperatorControl())
		{	
			while (true)
			{
				float x = acc->GetAcceleration(ADXL345_I2C::kAxis_X);
				float y = acc->GetAcceleration(ADXL345_I2C::kAxis_Y);
				float z = acc->GetAcceleration(ADXL345_I2C::kAxis_Z);
				dsLCD->PrintfLine((DriverStationLCD::Line) 1, "x=%f  y=%f  z=%f", x, y, z);
				dsLCD->UpdateLCD();
				Wait(1.0);
			}
		}
	}
};

START_ROBOT_CLASS(DefaultRobot);
We're not experts. This is our first year programming in C++, and were a little short on time, so there wasn't much time for testing.... If anyone happens to know how to fix it (without any extra effort), we'd love to hear about it. Thanks!
Reply With Quote
  #17   Spotlight this post!  
Unread 10-02-2013, 23:58
tandeson tandeson is offline
Registered User
FRC #3662
 
Join Date: Feb 2013
Location: Everett,WA
Posts: 1
tandeson is an unknown quantity at this point
Re: ADXL345_I2C Help

We've been using the ADX345_SPI class, and we tried to use ADXL345_I2C without any luck.

however, I was reading though the part datasheet tonight, and I think the issue is that you have to hold the Chip Select line high to select I2C mode.

See page 18 of the part datasheet:
http://www.analog.com/static/importe...ts/ADXL345.pdf

We'll probably stick to the SPI mode because we've got it working. Though we're considering modifying the class slightly from what WPI provides. (We'd like to add a calibration function, as described in the User's Guide).

If you get it to work in I2C mode, I'd be interested in hearing about it.
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:41.

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