Search under this category:
NXT Repository/Programming/
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 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.
Avoiding Obstacles with the Alpha Rex
Last update: Wednesday, August 2nd, 2006Jeff Owrey explains the concept of abstraction - building your code bottom up using MyBlocks to hide implementation details of lower levels. (more…)
BarCodeReader
Last update: Monday, February 5th, 2007
Claudio Ditursi has put online a great NXT project called BarCodeReader. This MyBlock and assorted files allow an NXT robot to scan a printed barcode using the light sensor, and react according to the printed barcode value. The MyBlock comes with detailed documentation, technical details, sample project and images. Great job, and thanks Caludio for making this site and documentation for sharing this with the rest of the NXT community!
Block Game on NXT
Last update: Thursday, August 3rd, 2006Here’s something different - an NBC code running a block game (a la Tetris) on the NXT display.
Any additions/suggestions/comments? Send an email to repository@nxtasy.org.