Go to Post We will be stressed, we will be angry. But we need to hold ourselves to a higher standard, we need to be role models and inspirations to students. - Andrew Schreiber [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 03-02-2014, 07:59
kylelanman's Avatar
kylelanman kylelanman is offline
Programming Mentor
AKA: Kyle
FRC #2481 (Roboteers)
Team Role: Mentor
 
Join Date: Feb 2008
Rookie Year: 2007
Location: Tremont Il
Posts: 186
kylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to allkylelanman is a name known to all
I2C Arduino Port (Wii MotionPlus)

I'll start off by saying prior to this season our team has had no prior knowledge of I2C.

We successfully were able to talk to a LSM303D using the standard calls in the WPILib I2C class.

We are now trying to integrate with a Wii MotionPlus. We have a working setup with an Arduino. In hopes of eliminating the Arduino we tried to port the Arduino sketch to C++. Our limited knowledge of I2C has made this a little bit of a challenge.

Code:
/* Arduino */
void receiveData(){
  Wire.beginTransmission(0x52);    //now at address 0x52
  Wire.send(0x00);		     //send zero to signal we want info
  Wire.endTransmission();
  nunchuck)
  Wire.requestFrom(0x52,6);	  //request the six bytes from the WM+
  for (int i=0;i<6;i++){
    data[i]=Wire.receive();
  }
}
I realize there is additional initialization that needs to happen. But that is straight forward. The 2 new concepts that the LSM303D did not require but that the Wii MotionPlus does are:
1. Sending data over I2C with no register as a target.
2. Receiving data over I2C with out a particular register as a source.

Code:
/* WPILib */
        // _wmp is an instance of I2C
	uint8_t buffer[6];
	_wmp->Transaction(0x00, 1, buffer, sizeof(buffer);
Are these code snippets functionally equivalent? If not what are the equivalent of requestFrom() and read() in the WPILib?

Thanks in advance to anyone that can assist us.

Kyle
__________________
"May the coms be with you"

Is this a "programming error" or a "programmer error"?

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 12:49.

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