Nimachine
Frameworks
Nimachine
NXTMindstorm
I2C Wiring
- Two of the six wires in the NXT sensor ports carry the I2C clock and data signals. The NXT always serves as a master.
- Another wire carries a 4.3v supply line.
- Two more are grounded (one of them needs to be used if you use the NXT's power).
- The sixth line is an RCX-type 9v analog sensor line.
Digital (I2C) Sensors
To communicate with digital I2C devices, a 9-byte message must be forged and sent. The format of this message can be thought of as a header, a payload, and a footer.
Let's start with the 2-byte header:
- Message Length
- ???
Next, we have the 5-byte payload:
- Return mode
- Instruction class
- NXT brick port
- Transmission message length
- Receive message length
Finally we have the footer which contains 2 pieces of information, stored in 2 bytes:
- Slave I2C Address
- Register address
A typical message would hence look as follows:
char message[] = { messageLength, startByte, returnMode, opCode, nXTBrickPort, txLength, rxLength, i2CSlaveAddr, registerAddr }
Let's wrap this up with a concrete example; here we are sending a message to a ~HiTechnic accelerometer sensor...
messageLength = 0x07; //. <message-size> - <header-size> = 0x07 startByte = 0x00; //. No idea what this represents :/ returnMode = 0x00; //. See returnModeEnum opCode = 0x0F; //. See opCodeEnum nXTBrickPort = 0x03; //. 0x00 (Port 1), to 0x03 (Port 4) txLength = 0x02; //. <message-size> - <header-size> - <payload-size> = <footer-size> = 0x02 rxLength = 0x06; //. Sensor-dependent, what data will the sensor return? i2CSlaveAddr = 0x02; //. Almost always 0x02 for NXT - the I2C slave address. registerAddr = 0x42; //. Almost always 0x42 for NXT - the register address holding the latest sensor reading
The returnMode can take any of the following values:
enum { kNXTRet = 0x00, /*!< Command returns a value */ kNXTNoRet = 0x80, /*!< Command does not return a value */ kNXTSysOP = 0x01 /*!< Command is a system operation (USB only) */ }; //. returnModeEnum
The opCode can take any of the following values:
enum { kNXTStartProgram = 0x00, /*!< Start Program Op Code */ kNXTStopProgram = 0x01, /*!< Stop Program Op Code */ kNXTPlaySoundFile = 0x02, /*!< Play Sound File Op Code */ kNXTPlayTone = 0x03, /*!< Play Tone Op Code */ kNXTSetOutputState = 0x04, /*!< Set Output State Op Code */ kNXTSetInputMode = 0x05, /*!< */ kNXTGetOutputState = 0x06, /*!< */ kNXTGetInputValues = 0x07, /*!< */ kNXTResetScaledInputValue = 0x08, /*!< */ kNXTMessageWrite = 0x09, /*!< */ kNXTResetMotorPosition = 0x0A, /*!< */ kNXTGetBatteryLevel = 0x0B, /*!< */ kNXTStopSoundPlayback = 0x0C, /*!< */ kNXTKeepAlive = 0x0D, /*!< */ kNXTLSGetStatus = 0x0E, /*!< */ kNXTLSWrite = 0x0F, /*!< */ kNXTLSRead = 0x10, /*!< */ kNXTGetCurrentProgramName = 0x11, /*!< */ kNXTMessageRead = 0x13 /*!< */ }; //. opCodeEnum
We've asked for 6 bytes back, and that is because the documentation page for the accelerometer states the following:
| Address | Type | Contents |
| 42H | byte | X axis upper 8 bits |
| 43H | byte | Y axis upper 8 bits |
| 44H | byte | Z axis upper 8 bits |
| 45H | byte | X axis lower 2 bits |
| 46H | byte | Y axis lower 2 bits |
| 47H | byte | Z axis lower 2 bits |
Applications
Nimachines
The User Interface
[[Image(nm00.png]]
Kohonen's Self-Organizing Maps
[[Image(nm01.png]]
Rosenblat's Perceptron
[[Image(nm02.png]]
BenderBot
Source
git clone git://git.autonomy.net.au/nimachine Nimachine
Hardware
Device specifications (sensors, actuators) used in this project can be found in these sites...
References
- http://code.google.com/p/legonxtremote/ - The project from which the NXT portion of Nimachines is based on
- http://www.tau.ac.il/~stoledo/lego/i2c-8574/
- http://mightor.wordpress.com/
- http://www.mastincrosbie.com/Marks_LEGO_projects/LEGO_Projects.html
- A RobotC forum post
Related
Ancestors ☣ Agent ➢ Agent
Siblings ☣ Agent/ModelBased/UtilityBased
Opposite ☣ Agent/ModelBased/UtilityBased
Other ☣ Algorithm/Learning/TDL/QLearning
Comments
Attachments
-
nm00.png
(42.6 KB) - added by nima
8 months ago.
Nimachines (Application) User Interface
-
nm01.png
(29.5 KB) - added by nima
8 months ago.
Kohonen's Self-Organizing Maps OpenGL Screenshot
-
nm02.png
(18.8 KB) - added by nima
8 months ago.
Rosenblat's Perceptron OpenGL Screenshot

