Go to Post "We just fundraised $5000 for registration, and you spent it all on balloons?" - [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 Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
Prev Previous Post   Next Post Next
  #1   Spotlight this post!  
Unread 01-14-2010, 12:07 PM
wt200999's Avatar
wt200999 wt200999 is offline
Texas Instruments
AKA: Will Toth
FRC #3005 (Robochargers)
Team Role: Mentor
 
Join Date: Mar 2006
Rookie Year: 2004
Location: Dallas, Texas
Posts: 321
wt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud ofwt200999 has much to be proud of
Send a message via MSN to wt200999
Help with 2010 Accelerometer & I2C

I am trying to implement the kit accelerometer, and I started by basing it off of the HiTechncCompass class from last years code. (I can't find the newest version, but I doubt that class has changed). The problem I am having is when I try to initialize the I2C in my robot constructor, the constructor does not finish and the robot stops responding. The console output from the serial port also does not give me any errors either. Here is the class I started, with simple functions just to see what I can get out of it:

I2CAccel.h
Code:
#ifndef __I2CACCEL__
#define __I2CACCEL__

#include "SensorBase.h"

class I2C;

class I2CAccel : public SensorBase
{
	public:
		I2CAccel(UINT32 ModuleSlot);
		~I2CAccel();
		float Get();
		
	private:
		static const kAddress = 0x3A;
		static const kReadAddress = 0x3B;
		static const kPowerSaving = 0x08;
		static const kPowerCtrl = 0x2D;
		
		I2C* m_i2c;
};

#endif
I2CAccel.cpp
Code:
#include "I2CAccel.h"
#include "DigitalModule.h"
#include "I2C.h"

I2CAccel::I2CAccel(UINT32 slot)
	: m_i2c (NULL)
{
        //Somewhere on these 3 lines it fails...
	DigitalModule *module = DigitalModule::GetInstance(slot);
	m_i2c = module->GetI2C(kAddress);
	
	m_i2c->Write(kPowerSaving,kPowerCtrl);
}

I2CAccel::~I2CAccel()
{
	delete m_i2c;
	m_i2c = NULL;
}

float I2CAccel::Get()
{
	UINT16 value;
	m_i2c->Read(kReadAddress, sizeof(value), (UINT8 *)&value);

	return (float)value;
}
I was wondering if anyone else has gotten theirs working?
__________________
Programming in LabVIEW? Try VI Snippets!

FIRST LEGO League 2004 - 2005
FRC Team 870 Student 2006 - 2009
FRC Team 3005 Mentor 2013 -
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

Similar Threads
Thread Thread Starter Forum Replies Last Post
2010 Accelerometer Documentation? JDM Sensors 13 01-18-2010 12:42 PM
Accelerometer Help? elbuo Programming 16 01-19-2009 01:01 PM
accelerometer help!! wildcats Electrical 2 01-18-2009 03:51 PM
Accelerometer Help! Questions4mQ202 Electrical 4 01-15-2009 07:44 PM
Accelerometer help Red Mage Programming 3 01-30-2008 06:49 PM


All times are GMT -5. The time now is 09:23 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