Sunday, October 6, 2013

Week 7: The NXT has arrived!

I've received the NXT this week, and I am happy to report I've begun experimenting with my hardware.

After some software setup on the NXT side (The RobotC firmware must be burned to the NXT), I began by physically connecting the two devices. I did this by following the schematic referenced in my week 3 post, in which I fashioned a DIY connector after cannibalizing a sensor cable. My immediate goal is to establish simple communications, so I made my adapter pin-compatible to plug directly into the ChipKit itself.

A picture of my connector, note the 82KOhm pull ups soldered onto the header pins
....and socketed into the ChipKit
With the physical connection out of the way, I proceeded to program each board with slightly modified but conceptually identical code to the one provided by the DexterIndustries site. Because Blogger doesn't handle formatting well, and because I'm going to include more polished electronic copies of my code in my final overview anyway, I'm not going to paste the code here as it would just waste space. I will however post the link to the code templates I'm using down below. The important part is that the Arduino and the NXT have been programmed for bidirectional I2C communication, with the NXT acting as the master device. This code follows the Lego spec for comms detailed in last week's post.

One really important thing is that the code posted on the dexter site seems to be designed for Arduino 1.0 or above. This is evident through the use of the v1.0 Wire.read() method, which is not available in the 022 libraries. Now the equivalent 022 method is Wire.receive(), which I've substituted into my code. Again this change is really important to note, because the ChipKit isn't talking with the NXT and I'm not sure why.

That brings us to the present, where I'm almost entirely certain that the messaging logic of my code is functioning correctly. My prediction is that some fault exists where I2C is handled, and thus I've hooked up my Saleae logic analyzer to the SDA/SCL lines. It appears that while the NXT it driving the SCL clock line correctly, there isn't any data being passed on the SDA data line. This indicates a fault with the NXT as the current RobotC code should initiate communications with an I2C packet addressed to the Arduino. However nothing is being sent, so here we are...

I'm going to continue analyzing the issue, until I can get the I2C into a working state everything is stuck on this.


http://www.dexterindustries.com/howto/connect-the-arduino-and-the-lego-mindstorms-together/