Connecting BT using NXC
Friday, May 30th, 2008As happend several time in the past, this forum topic proved what I considered ‘impossible’ (and has been telling this “truth” over and over in the forum..) is simple… this time it is the ability to connect a BT device programatically within NXC (and the standard firmware). This ability has long been possible in alternative firmware (pbLua, RobotC etc.) by so far I allways thought it can’t be done in NXT regular firmware. As it turns out - I was wrong.
Thanks to our forum user ronmcrae for sending this code:
asm { dseg segment
args TCommExecuteFunction // define argument structure for syscall
dseg ends
set args.Cmd INTF_CONNECT // request bluetooth connection initiation
set args.Param1 0 // assumes the first entry in the table
set args.Param2 1 // connect on channel 1
syscall CommExecuteFunction,args} // and make it happen
On another site (www.mindstormsforum.de) I found an alternative code (see post here):
void connect() {
CommExecuteFunctionType args;
args.Cmd = INTF_CONNECT;
args.Param1 = 0; // device index
args.Param2 = 1; // connection indexSysCommExecuteFunction(args);
}void disconnect() {
CommExecuteFunctionType args;
args.Cmd = INTF_DISCONNECT;
args.Param1 = 1; // connection indexSysCommExecuteFunction(args);
}task main() {
connect();
Wait(5000);
disconnect();
}
I didn’t test this, and can’t read the post neither.. but it seems a cleaner way (no asm segement) to do the same thing.
All these have one drawback - they assume the NXT you want to attach to is in the position 0 in the stored ‘past connections’ table on the Master NXT. Now I suppose there’s no way to find an NXT by name on this list, or am I wrong again
?
btw. since at the moment the LabVIEW SysCall is limited to a predefined set, I couldn’t figure out a way to do the same in LV (and then in an NXT-G block). Again - I might be wrong… but I am more confident on this one, unfortunatly.
Guy Ziv
Posted in news, hacking | Comments Off
List of NXT related books
Thursday, May 22nd, 2008David J. Perdue, author of “The Unofficial LEGO MINDSTORMS NXT Inventor’s Guide” made a web page with a list of all available NXT books. Check it out here: http://www.booksnbots.com/
Posted in news | Comments Off
Running nxtOSEK from “standard” NXT
Thursday, May 22nd, 2008As Sivan published, he and John made possible to run native ARM codes from RAM. This requires an “enhanced” firmware version is compatible with NXT-G, LabView and NXC but can also run native codes. Takashi Chikamasa has now made a beta version of nxtOSEK which support this enhanced firmware. You can write a code, complie it using nxtOSEK and run on the firmware John Hansen made.
Here’re more details from Takashi:
I just uploaded a beta version of nxtOSEK (v2.02b0) which supports the enhanced NXT firmware:
https://sourceforge.net/project/showfiles.php?group_id=196690&package_id=274370&release_id=601108nxtOSEK application is stored in Flash and it copied and executed from RAM. Once nxtOSEK is executed, NXT is fully controlled by nxtOSEK application, so there is no difference between nxtOSEK in ramboot and nxtOSEK in the enhanced firmware.
There are several benefits in case of using the enhanced LEGO standard firmware:
- You can use NXT-G, NXC/NBC and nxtOSEK without replacing the firmware.
- You can upload multiple nxtOSEK applications to a NXT.
- Support for Windows Vista (I guess)If you wanted to write larger application over 64Kbytes, you could use NXT BIOS instead of the enhanced firmware. (max. 224Kbytes Flash are available for your C/C++ application with nxtOSEK)
For more detailed information about this new feature, please check readme.txt in the zip file.
P.S. nxtOSEK v2.02 also supports LATTEBOX NXTe RC servo controller such as leJOS has done. NXT becomes more than just a LEGO (even it’s already enough great), but a multi-purpose embedded platform!
Posted in news | Comments Off
Running on the Bare Metal, the Easy Way
Monday, May 19th, 2008John Hansen and I created a way to start programs that run on the bare metal (directly controlling the processor) from an almost-standard firmware.
If you ever wished to program the NXT at the lowest and most powerful level, but did not want (or could not) deal with SAM-BA, the native boot loader, then this project is just what you were looking for you. You will be able to build C programs using the free GCC compiler suite and run them on the NXT. When the program terminates (or when you press the little reset button hidden in the Technic hole below the USB socket), the NXT returns to the standard firmware. You never lose the ability to download and run a NXT-G or NXC program. You can learn a great deal about embedded programming by trying this out.
Perhaps more importantly, if you are the developer of a programming environment that normally gets installed on the bare metal, this project would be useful for you too. It would allow users to invoke your programming environment from the (almost) standard firmware.
The complete details and code to get you started are available here. The code includes a small set of device drivers that currently support the motors, analog sensors, the key pad, the display, and sound.
I’ll try to support the code on the Software Forum here at nxtasy.org (but feel free to send email if I don’t respond).
Posted in firmware, projects, news | Comments Off
Small press release about FLL
Tuesday, May 13th, 2008This press release talks about Kjeld Kirk Kristiansen and the FLL Program.
Josh
Posted in news, events | Comments Off
Remote launching programs
Sunday, May 11th, 2008As many of you know NXT-G is built upon LabView. This means that everything possible with LabView and the NXTToolkit can be encapsulated into an NXT-G block. Doing so, however, is usually hard work (especially if you want to do it right, i.e. have good control panel and icon drawing interface).
Here’s a project in progress. A few weeks ago I looked into the internal of the toolkit VI ‘Write Message’ which send BT string from master to slave devices and vise versa:

when you go deep into the internal codes (here’s one good use for the NXTToolkit. Unlike regular NXT-G implementation VIs these VIs are not password protected!) you find that for master BT devices the message string is converted into a ‘BT packet’ by this code fragment:

As some may recognize, this is a Direct Command message format. The 0×80 0×09 start means BT Write Message telegram w/o reply (unfortunatly the master BT can’t request reply, since the firmware does not support it. If it could, there’ve been many more possible uses for the kind of “trick” I show here). It then adds the mailbox, the message length and the message itself. All this is converted into a byte array and sent over BT using a VI called ‘BT Write Buffer’ (not shown).
Having seen this, I started thinking - what if I send other Direct Command telegrams from the master NXT to a slave NXT? As I said earlier, only non-reply telegrams are possible. Among the possible telegrams is the ‘Run Program’ command (0×00 command). Indeed, if I have a program called ‘remote’ on the slave NXT running the following code on a master NXT executes ‘remote’:

As I said in the beginning, this can be cast into an NXT-G block which can either run a program by name on a connected NXT, or stop the current program (0×01 Direct Command). The question is - will it be useful for anything? I will be happy to get your feedback on this at this forum topic.
Guy Ziv
Posted in personal, news, software | Comments Off
LEGO NXT Warriors
Sunday, May 11th, 2008I think long ago some MCPs were playing with a similar concept, but I never saw real results. This guy did a very nice job, combining NXT and Bionicle in a very convincing way. I wonder how far it can go - adding maybe US to each horse, and maybe sending BT messages between the two?
There’s a topic here on this project.
Posted in projects, news | Comments Off
Daniele Benedettelli’s book
Saturday, May 3rd, 2008
“Creating Cool Mindstorms NXT Robots” by Daniele Benedettelli has come out with some delay. The author and editor’s wise decision to take their time to do this book has purified the contents and enhanced its quality… which can be only described with the attribute : excellent !
Danny has developed a handful sophisticated LEGO robots to which he gave life through control- and behaviour-based programs. The reader is led through slowly growing degrees of difficulty and complexity from “Quasimodo” to “JohnNXT”, while learning about the essence of NXT C-programming and concepts as diverse as finite state machine, hysteresis, underactuation, line following, Boolean operators, decision tables… All these topics are well-woven to form a balanced patch-work of knowledge that has characterized so many good robot books. You consequently learn by doing.
The author astutely combines NXT-programming with remarkable LEGO studless building in order to realize and describe more and more complex robots. With a note of humour the reader is accompanied through all the designs, where he has the impression of participating in the development of each prototype, which definitely is one of the best didactical choices. The graphics of this book are of high quality.
The absolute high-light of course is JohnNXT, the LEGO incarnation of the famous “Short circuit”-movie robot. Daniele uses two NXTs (pardon : three!) for this project. Two NXTs control the robot and communicate with each other over the RS485 high-speed connection. A third NXT is used in a “Remote Control” project and sends its commands via Bluetooth to the robot. But JohnNXT also can survive quite autonomously through a behaviour-modelled program.
Well done Danny !
Posted in news | Comments Off
Lego Pong with NXTCam
Friday, May 2nd, 2008Here is an interesting robot from wayneage that plays Pong using a NXTCam camera to track a ball in real time. The NXTCam continuously sends the location (coordinates) of the ball to the NXT brick. The robot keeps adjusting its position to hit the ball when it is close enough. Before the robot starts, the NXTCam is taught the colours to track using another program called NXTCamView (this is not shown in the video). As you can see it works quite well - nice work!
Posted in general, video, development, news, Projects | Comments Off