This post introduces NXT2excel, a pc utility that allows one to send data from a NXT program to excel over BlueTooth.
NXT2excel runs on the pc. It initiates a BlueTooth connection with a NXT and writes data it receives from the NXT to an excel spreadsheet. This allows the user to examine or process the data. Users can automate the processing of the data with the use of a previously built worksheet. This makes it possible to have treal time graphs.
Disclaimer: NXT2excel is in beta stage. It might not always work as expected, it sure is not fool-proof. Use it at your own risk.
NXT2Excel is not working with NXT-G! Currently it will only work with robotC.
It is very important to terminate the NXT program before terminating the Bluetooth connection. If not, the Bluetooth connection cannot be terminated normally and the NXT will have to be shut down and started over before BlueTooth can be used again.
Port: The port number of BlueTooth. Please note that the PC and NXT must already have been paired.
Connect/disconnect: Open or close a connection with the NXT. Please open a connection before starting the NXT program and close it after terminating the NXT program.
Mailbox: The number of the mailbox the NXT is sending messages to.
Worksheet: The Excel worksheet that will be used for writing, read only. The worksheet has to be opened from Excel, after opening the worksheet one should press the reset button.
Reset: Press this button after opening a worksheet. The reset button will tell NXT2excel what worksheet to write to. It takes the worksheet that is active when pressing the reset button.
Limit observations: By default NXT2excel will add a new row in excel for every received message. The excel worksheet can grow very large as a result. By limiting the number of observations one tells the program to remove observations that are older than the limit. As a result Excel only contains the N most recent observations.
Sending data from the NXT
Data is sent from the NXT using messages. By design a NXT message can contain up to 58 bytes, 4 are used for overhead functions, leaving 54 bytes to be used. NXT2excel only handles integers, you can send up to 27 in each message. Look in the robotc documentation for detailed information about sending and constructing messages.
Alternatively you can construct and send messages using the robotc library that is provided with NXT2excel. To use this library include the file NXT2excel.c in your program. To store values in a messages you use the NXT2excelAddValue function. It takes two parameters, the first being the integer value to store, the second being the excel column number where the value should be written to. The first column is reserved for a timestamp that is automatically added to the message.
Once a message is filled it can be sent using the NXT2excelSendMessage function. This function takes no parameters.
Using excel sheets
By default NXT2excel uses a new and empty excel sheet to write data to. The data is dumped on the first sheet, see the first picture for an example. You can however specify an existing sheet as a template. This sheet will then be used to write data to. A template must not use the first sheet as this is used by NXT2excel. The second row of the first sheet always contains the most recent values. Row 4 and later contain the history of values. When referring to data in excel functions or graphs one should refer to the range A4:A5 and so on. This range will be expanded automatically by excel. This will make sure your template keeps working with increasing number of data rows. The second picture shows some real-time graphs using a template.
Please notice that NXT2excel closes excel sheets without saving them. If you want to save your data you’ll have to do so manually.
The utility comes with an example program for the NXT. It shows how to use the provided source library and robotC functions. It als has an excel template that shows you how to create a template with a graph that updates as more data is fetched from the NXT.
You can download the program from here.