Logo for NXT User Guide
Version: July 25th 2009
Return to main page
See also: Reference Guide and nxt.imt Reference Guide.
Contents:
Installation
Please download the latest release from
http://webcvs.robotika.sk/cgi-bin/cvsweb/robotika/src/imagine/nxt/logo/releases/.
Uncompress the zip-file to a new directory. NXT Logo works with the standard firmware, but
it performs much better with the standard extended firmware. Please download it from the NBC site:
http://bricxcc.sourceforge.net/lms_arm_jch.zip,
and then install it on your NXT using the BricX (Tools - Download Firmware).
If you do not want to upgrade the firmware, you can use the standard firmware, but then you
need to use the file logo_standard.rxe
(or recompile the logo.nbc without the -EF switch).
After unpacking the contents of the archive, you can simply run the setup.exe utility and
follow the instructions shown (the utility will backup the files from your NXT, install NXT Logo interpreter
into NXT flash).
Linux users: type 'make' first to compile the setup and utitlities. Start setup using './setup'
Remember to turn on the BlueTooth functionality on your NXT (from the main menu: BlueTooth - On, BlueTooth - Visibility - Visible),
and setup the virtual serial port connection on your PC (from the BlueTooth icon, find new device and notice the outgoing
virtual serial port name). If you do not plan to use BlueTooth, i.e. you will download all NXT Logo programs over USB cable
and start them by NXT buttons, you need to copy NXT files manualy, the setup utility won't work.
It is recommended and much more convenient to use the BT functionality.
If you do not want to use the setup utility (this currently includes Linux users), you need to download the files reserved.dat
and reslen.dat to the NXT brick - for example with the help of BricX. Also download the
logo.rxe program (if you are using
logo_standard.rxe, rename it to logo.rxe first).
Linux users: Setup a bluetooth connection with NXT at some virtual serial port device, for example using bluez-utils. Once connected, (for example to /dev/rfcomm0) you can procede further. The directory misc/remote contains a remote1 utility and an example program for Berkley Logo (UCBLogo) that makes it possible to talk to NXT Logo from Berkely Logo.
Your first NXT Logo program
Let us start programming in NXT Logo directly - without the use of Imagine Logo.
Prepare a text file with a NXT Logo program, for example:
to "prog []
[
cs
tone 880 100 3
wait 200
tone 440 100 3
wait 200
tone 880 100 3
wait 200
print "hello
wait 2000
cs
]
Save the program to file prog.lgo.
It can contain multiple functions/procedures and it can also contain commands at the top level
(outside of to) that should be executed immediately. The main procedure should be called
prog, and it can be started using the NXT buttons directly. Now download the program
to the NXT (either using NXT Explorer in NBC or using the NXT Logo utility nxtcp).
Start the Logo program at NXT manually. Logo will determine that Imagine Logo is not connected
to its BlueTooth port, so it will display a menu on the display:
NXT Logo menu
> Load
Run
BT Slave
Use the arrow buttons to navigate in the menu. Load loads (evaluates all expressions in)
the program prog.lgo. Run calls the prog procedure, and BT Slave
will leave the manual menu and wait for remote BT connection. Now you can load and start the
program you have just prepared...
For interactive control over BlueTooth, you can use the windows console utility remote.exe that you
find in the main NXT Logo directory.
Direct control of NXT robots using Imagine NXT Controller
- First make sure you install NXT as a Bluetooth device on your computer - search for BlueTooth devices,
add the virtual serial port, and write down its name (the outgoing port). You will have to specify
pin code (i.e. 1234) on both sides PC and NXT of the Bluetooth connection.
If your system supports crypted serial ports, disable that feature (do not use crypting).
- Run the nxtnet.exe program, keep it running and minimize its window. You can close it anytime you
do not need to communicate with NXT from Imagine. You can then start it again just before you start
communication with NXT from Imagine. Alternately, you can also start it directly from Imagine
using if 33 > (runprog "nxtnet.exe 4) [print [could not start nxtnet.exe]].
- Open the nxt.imp project from Imagine Logo (if you are not using English version of Imagine,
you need to tell your Imagine to understand English version of commands,
i.e. when loading Imagine, specify the /en switch).
- Specify the correct virtual serial port: double click on the COMXX text, change it to the
correct port and press the ESC key.
- Now try to connect to NXT by pressing the "Connect to NXT" button. If everything goes well, the
status text under the button will change to "ok".
- If your robot has some motors attached, you can try turning them on and off using the buttons
in the upper part of the project page. Use the sliders to speed up/slow down. Use the controls at the
bottom to poll the values of the sensors (you need to turn the polling on and off by the pollX buttons
after you configure the sensor type).
Direct control of NXT robots from your own Imagine projects
If you like to control the NXT robots from your Imagine projects without downloading Logo programs
to NXT, i.e. without the use of NXT Logo interpreter, you can use the nxt.imt loadable project. From
command prompt in Imagine (or from your Imagine project), issue the following command:
load "nxt.imt
After this, a large set of predefined procedures are available for you. They are discribed in a separate
document: nxt.imt Reference Guide.
For instance, type
nxt_ls
to list the files in the NXT flash, or
nxt_playsound "false "Woops.rso
to play the specified sound (without repetitions).
similarly, you can use
nxt_download "filename.txt
to download any file to NXT flash memory (for example your own text file with a logo program).
Interfacing Imagine with the NXT Logo interpreter
- Follow the steps in the direct control section.
- If you used the setup utility described above, Logo interpreter is already installed in NXT brick, and you
can skip to the next step.
(The interpreter consists of the file logo.rxe and two datafiles reslen.dat and reserved.dat).
If you for some reason remove these files from NXT flash, you can download them again from Imagine
by clicking the "Download Logo" button (these files need to be in the same directory as your nxt.imp project).
If you can see the message "finished writing, closing file" for all three files without any error, Logo is ready to be
started. If you see message "no space", you need to use BricX NXT Explorer, or nxtrm utility, or simply
run setup utility again, and remove some unnecessary files, such as Try*, all kinds of sounds, pictures, etc.
You can get them back anytime by downloading the standard firmware using LEGO software. We are sorry about this,
but it is the memory limitation of NXT that we all have to cope with. Once all three files are downloaded correctly, you
can proceed with the next step.
- Now click "Run Logo" button (next time you start from here). NXT Logo will be started, and it will wait a short time to see if
you want a manual menu despite that you are connected with Bluetooth - in that case, press the square
orange NXT button.
- Once the logo is started you can use the command line in the middle of the screen to
evaluate logo expressions on NXT. Use the "..." button to evaluate longer, multiline expressions
(for example to define procedures). The expression is evaluated always after you press the
"Evaluate" button. If the resulting expression is a list with numbers, you can use the "Plot" button
to visualize it in a chart. Use the "..." button to view longer resulting expressions. Feel free to modify
the Imagine NXT Controller projects for your needs, or create your own projects... Simply reuse the
loadable nxt.imt component in your projects.
Debugging features
Coming soon...
Currently, it is possible to dump the memory image and display it using the catcore utility.
It will not help you much though, unless you are a NXT Logo developer.
Support and NXT Logo internals
Please send us all your questions, bug reports, comments, and ideas to ppetrovic (at) acm.org.
For internals, please, look at the specification.txt file. You can browse our CVS for more...
Known issues
- When communicating between Imagine and NXT, make sure you are not running any other application that communicates with NXT
- for example BricX. If you do, unexpected behavior can happen as those programs may send packets to NXT at unexpected times.
- If you are having trouble downloading logo using Imagine (getting some strange errors), it can mean that there is not enough
space for the logo.rxe or the .dat files. In that case, you may need to go to NBC's NXT Explorer and remove
some sound or image files or older program files that you do not need. (or use nxt_ls and nxt_delete commands to
list and remove the files that are not needed).
Also, NXT sometimes has a confused filesystem, after some errors occured, so turning it off and on sometimes really helps.
- Please tell us if your problem is not listed here at (ppetrovic (at) acm.org).