Search under this category:
NXT Repository/Tutorials/
A MyBlock primer (with a side of math)
Last update: Friday, August 4th, 2006Introduction to MyBlocks in NXT-G by Brian Davis.
Advanced NXT-G Block Techniques - Part I
Last update: Friday, December 22nd, 2006As promised, I will try to describe for you some “advanced” features of NXTToolkit NXT-G block coding. These features were either omitted from the documentation and examples or just wasn’t put at all due to lack of time and NI desire for clarity. In any case, these are “unofficial” and thus “unsupported” by NI. What does that mean? It means that (a) NI uses these techniques a lot in the NXT-G blocks you have, and (b) they may change the VIs at will without telling us… Anyway, till that happens, there are some very useful tricks you can use to make impressive, smart and user friendly (i.e. Kids friendly) NXT-G Blocks.
So, the first question I’ll answer is:
How to disable/enable a control if NXT-G diagram terminal is wired ?
Look at the following picture showing the diagram of the Config VI:
There are several simple steps which you should follow to make the necessary changes:
1. Increase the size of the SubVI Propery node at the left, and select “Terminals[]” property for the new element.
2. Add a VI called “IsTerminalWired.vi”. This VI resides in “LabView\vi.lib\addons\NXTToolkit\Block Templates\Support” directory. Recommended: copy the file into your Block directory, NI may change/remove it in future versions.
3. Wire the Terms[] output and create a constant string with the label of the control/indicator in the Implementation VI you want to check if wired.
4. Right click the control in the Config front panel, select “Create/Propery Node” from the popup menu.
5. Move the new propery node, change it to “Disabled” and set it to Write mode (again, by right clicking on it).
6. Wire the “Disable if Wired” terminal of IsTerminalWired to the Disabled propery node.
That’s all, folks! A very useful trick, which is used extensively in standard NXT-G blocks.
Advanced NXT-G Block Techniques - Part II
Last update: Saturday, January 6th, 2007
In this post I’ll describe another useful trick for NXT-G Block programmers. Often it is convenient to have several actions in one block. For example, my Array Block has “read”, “write” and “create/resize” actions selectable from a dropdown list. However, not allways the same terminals are needed. In the above example, read and write mode need a “Position” input terminal, while create/resize mode requires a “Size” input terminal. Here I’ll describe how one can use a single terminal, and dynamically rename it when the action is changed.
Advanced NXT-G Block Techniques - Part III
Last update: Monday, February 26th, 2007In one of my previous posts I discussed how the NXT-G compiler does code optimization. Among the optimizations done automatically by the NXT-G compiler is ignoring implmentation VI diagram parts which are never reached by the program. In particular, say you have a Switch connected to a constant - only the case given by the constant will be compiled. One can take advantage of this when creating NXT-G blocks with multiple possibile actions. For instance, my Fixed-Point operations block has 6 actions - addition, subtraction, multiplication, division and conversion from Numeric to Fixed-Point and vise versa. The “FP Block.vi” implementation VI has all 6 in a switch, with a constant holding the current action. Note that this constant MUST resides in the “top” VI, not a SubVI, otherwise it will be common to all copies of the block in the NXT-G diagram.
This nice feature, however, posses some difficulties. To manipulate the value of controls in the Config VI and Draw VI of your block, you invoke the “Get Control Value” of the VI:

However, this DOES NOT work for constants, even after you figured out what is the label of your constant (right-click the constant and select “Properties” to set it).
A similar problem occours in writing new values. The “Set Block Param.VI” supplied by the toolkit does not work for constants.
Using VI scripting I’ve written two VIs that allow reading and writing a constant value in implementation VIs. Reading is done by “Get Const Value.VI”:

and writing by a similar “Write Const Value.VI”. Both VIs can be downloaded here.
Advanced NXT-G Block Techniques – Part IV
Last update: Thursday, April 12th, 2007Motivated by a recent post in our forum regarding data logging, I started writing a series of posts on data logging options for the NXT. I also began working on a Datalog NXT-G Block dedicated to this purpose. During the block development, however, I encountered some serious performance issues regarding Array usage in the LabView NXTToolkit compiler (and hence in NXT-G) which I’ll describe in this post. Future posts will describe existing and new solutions for data logging.
Custom Icons for Custom NXT-G Blocks
Last update: Tuesday, September 5th, 2006Here’s how to build your own icon for NXT-G MyBlocks.
Digital I/O on Input Port - part I
Last update: Friday, April 13th, 2007
Perhaps the least documented or used feature of the NXT is the possibility of direct digital input/output using pins 5 and 6 of the input ports. When working in “Custom” sensor type, these two bits can be manipulated directly using IOMapRead and IOMapWrite ‘invoke’ commands in NXTToolkit, which in principle means a NXT-G block can also control these pins. At startup these pins are set as digital input.
In the image above you can see a nice application - using a input port to get rotation readout from the built-in tachometer encoders of the NXT motor. These encoders are usually connected to pins 5 and 6 of the output ports, and they change from 0 to 1 with a small phase difference in a 2 degrees cycle. Below is a simple (and not perfect!) LabView code which monitors the encoders (assumed connected to port 1) and counts up/down showing the rotation count on screen (click to enlarge):
To use other ports, one need to specify the currect IOMap position - offset 12 for port 1, 32 for port 2, 52 for port 3 and 72 for port 4.
In the next posts I will detail more on the hardware internals involved and digital output from the input port, as well as how to do the same tricks with RobotC (whose next planned release is supposed to support input from these two bits very easily).
Driving NXT Straight - Movie
Last update: Wednesday, August 2nd, 2006“Fll-Freak” Skye Sweeney published this video demonstration showing how well the NXT drives in a straight line.
FFL tutorial on NXT-G
Last update: Tuesday, August 8th, 2006INSciTE published this tutorial on NXT-G, aimed at FFL participants (i.e. 9-14 years old kids).
Getting Started with Bluetooth - Movie
Last update: Wednesday, August 2nd, 2006“Fll-Freak” Skye Sweeney published this video demonstration, showing how to turn the Bluetooth communication on, how to connect to it from NXT-G and how to download programs to your NXT.
GPS with RobotC
Last update: Sunday, September 16th, 2007
Dick Swan, the developer of RobotC, sent me a sample code for using a BT GPS with NXT using RobotC. The code can be downloaded here. As one can see in the image, it displays time, position and other data on the NXT LCD display. This code requires a RobotC version which is still not public, which can be rechived directly from Dick Swan (dickswan at sbcglobal dot net).
How easy is it doing GPS communcation with RobotC? Well - very easy. You first turn the BT to ‘Raw Mode’ by setBluetoothRawDataMode() command. Then you simply read data (say one char) from the BT like a regular serial port with nxtReadRawBluetooth(BytesRead[0], 1). The rest of the code is GPS specific message parsing etc.
I was also astonished how easy is it to connect BT device programatically in RobotC. The three lines at the end of the code:
setSessionPIN(”1234″);
bBTSkipPswdPrompt = true;
btConnect(2, kGPSName);
Is all you need! It defines the PIN code to use, tell the NXT not to show password dialog and connect to a preset device (given by a const string kGPSName).
HiSpeed communication between multiple NXTs
Last update: Saturday, February 2nd, 2008
Mark made this wonderful demo showing how you can use port 4 (RS485) to communicate between multiple (three, in this demonstration) NXTs. The video explains well how this is done, and show how to connect two NXTs (via a regular cable), 4 NXTs via mindsensors.com port splitter, and even wiring NXTs 100 feet apart!
The NXTs were programmed using NXC, and the source codes can be downloaded here. The codes are modified versions of John Hansen sample RS485 files.
UPDATE: Philo sent me the following comment:
It is a common but very bad practice to use only two wires to connect RS485 devices: the ground should be conneced too, even though RS485 uses differential lines. Though it can work, as exemplified in the video, ommitting the ground may cause subtle failures and even dramatic ones (destroyed RS485 driver).
The drivers used in the NXT withstand a ground potential difference of only -7V to +12V. This might be exceeded if the connected NXTs have other external connection, eg to the mains via the battery/adapter.
ISOGAWA Yoshihito’s “LEGO Technic Tora no Maki”
Last update: Sunday, September 30th, 2007ISOGAWA Yoshihito, who has already written one NXT book and one Technic/Mindstorms book (both in Japanese), has released a beautiful LEGO Technic book in PDF format. The book is available for download; you are asked to pay $10 if you decide to use the book. The book shows a wide range of Technic mechanisms and small constructions. The mechanisms range from simple gear reductions to suspensions, clutches, and much more. The creations include many different vehicles and walkers, all fairly simple to reproduce. The book uses many different LEGO parts, some new (NXT motors, Power Functions motors and battery boxes) and some old (RCX motors, small pneumatic cylinders, the solar cell). In some cases, the book shows how to build essentially the same construction with two different kinds of motors or other specialized parts. The book covers basically all the kinds of mechanisms that you can build with Technic: gears, chains, pulleys, pneumatic, and so on. There is essentially no text, just pictures to illustrate principles and mechanisms. The graphics are beautiful, with clever icons to indicate chapters.
Browsing through the book will surely remind you why you enjoy LEGO so much!
LeJOS Tutorial
Last update: Thursday, September 13th, 2007Here’s a link for a tep-by-step tutorial explains in detail how to install java, leJOS and Eclipse on a windows computer. LeJOS is a Java VM for the LEGO Mindstorms NXT which can be downloaded here.
Any additions/suggestions/comments? Send an email to repository@nxtasy.org.
Search
Categories
Monthly Archives
- January 2010
- December 2009
- November 2009
- October 2009
- September 2009
- August 2009
- July 2009
- June 2009
- May 2009
- April 2009
- March 2009
- January 2009
- November 2008
- October 2008
- September 2008
- August 2008
- July 2008
- June 2008
- May 2008
- April 2008
- March 2008
- February 2008
- January 2008
- December 2007
- November 2007
- October 2007
- September 2007
- August 2007
- July 2007
- June 2007
- May 2007
- April 2007
- March 2007
- February 2007
- January 2007
- December 2006
- November 2006
- October 2006
- September 2006
- August 2006
- July 2006
- June 2006
