GoRobotics.net - Robotics news, robot projects

What’s NXT: The Record/Play Block

What’s NXT is a bi-weekly column written by Jim Kelly at The NXT Step Blog. Jim writes about LEGO Mindstorms NXT and all the cool news related to it.

NXT Tribot program

Last week I mentioned something called the Record/Play Block.  This is a programming block found in the Common Template.

You can use the Record/Play Block to define a period of time where anything you do with the motors of your bot (within reason) will be recorded to a small file that is stored on the Intelligent Brick.

Here’s how it works …


What’s NXT is a bi-weekly column written by Jim Kelly at The NXT Step Blog. Jim writes about LEGO Mindstorms NXT and all the cool news related to it.

NXT record/play button - Figure 1Last week I mentioned something called the Record/Play Block.  This is a programming block found in the Common Template (Figure 1)

You can use the Record/Play Block to define a period of time where anything you do with the motors of your bot (within reason) will be recorded to a small file that is stored on the Intelligent Brick.

Here’s how it works:

1. Drop the Record/Play Block on the desktop (Figure 2)NXT record/play configuration block - Figure 2

In Figure 2, I’ve placed the block on the screen. You can also see the configuration panel (I’ve cut and pasted it on the desktop so you can see it better, but it normally appears below the palette tabs, at the bottom left corner)

For the Record part, leave the "Record" button selected.   You’ll later select the "Play" button to playback a recorded file.

The "Name:" field is where you enter the name of the small file that will be stored on the NXT Brick.

The "Recording:" field allows you to specify which motors you wish to record.  By default, B and C are selected, but you can check the A box and record all three motor actions.

Finally, the "Time:" box allows you to specify the number of seconds to record.  According to the HELP files, the maximum time limit is 2147483647 milliseconds which translates to roughly 35,791 minutes or 600 hours, but I promise you that the Brick can’t hold that much :)

Okay, so after you’ve configured the block, you save the program and upload it to the Brick.  Run the program, keeping in mind how much time you configured.  During that time, you can roll the bot, move arms or legs or claws… whatever.  When the time period is up, the program ends.  If you then connect your Brick to the software and view the programs (see last week’s post on accessing the Memory tab), you also see a category called "Files" - this is where the file you named will be stored.

NNXT program - Figure 3ow for an example of how it can possibly be used.  I want my small tribot to move towards a book in the middle of the floor.  When the Ultrasonic sensor detects the book, I want the robot to turn right and go around the book, ending up behind the book and pointed away, ready to continue forward.

I created a simple program called "AvoidBook" with the Record/Play block and gave the file the name "GoAround".  I set it for 45 seconds and only to record motors B and C.  I then uploaded the small program to my tribot.  I placed the bot in front of a book where the Ultrasonic sensor will be configured to detect it.  I then pressed the RUN button and, placing my hand on the bot, I moved it manually by twisting the bot to the right and moving it forward slightly.  I then turned it left and moved it forward, past the book.  I turned the bot left again, moved it forward to be even with the book, and then turned it right… and the program ended. (Figure 3)

My small tribot has another program uploaded to it called "FindBook" -  I placed a Record/Play block in the program right after the Ultrasonic Sensor is triggered.  The Record/Play block is configured to "Play" and the filename I created ("GoAround") is put in the "Name" field. (Figure 4)

Figure 4

Now, when I run the program, the bot moves forward until the Ultrasonic sensor detects the book.  It then stops and the Record/Play block kicks in and performs the moves I recorded in the "AvoidBook" program.  That’s it!

Previous What’s NXT articles:

You can read more of Jim’s writings at The NXT Step Blog.


TrackBack URL

Leave a Comment