File Exchange

image thumbnail

VU-LEGO Real Time Target

version (1.42 MB) by James Peyton Jones
A user-friendly Blockset for embedding real time Simulink designs on the LEGO Mindstorms NXT brick.


Updated 23 Apr 2012

View Version History

View License

The Villanova University LEGO Real Time Target (VU-LRT) enables rapid implementation of Simulink-based designs on the LEGO Mindstorms NXT platform. It is similar in aim to the Embedded Coder Robot (ECRobot) package by Takashi Chikamasa, but is more consistent with the Real Time Workshop development pathway, and is less constrained by ECRobot's function call / data store architecture. An automated installer is shipped with VU-LRT - see the README.pdf in the download. Examples include motor speed control, a line-following robot, and a re-implementation of the NXTway-GS self-balancing two-wheeled robot.

VU-LRT was developed as an NSF and MathWorks funded project aimed at exploiting Simulink code generation tools and low-cost hardware platforms, (such as the LEGO MindStorms NXT), for educational purposes. In R2012a, the MathWorks added code generation capabilities to core Simulink without the need for additional toolboxes thereby providing a more cost-effective solution for bringing rapid prototyping into the classroom. The MathWorks also provided a free LEGO MindStorms NXT Target support package which delivers similar functionality to VU-LRT, but which is now professionally supported by the MathWorks. As a result, VU-LRT will no longer be actively maintained after the R2011b release and the authors will be transitioning their own courses to the new R2012a Simulink and MathWorks LEGO MindStorms NXT Target support package. The authors wish to thank the many enthusiastic supporters of VU-LRT who have developed so many creative projects with VU-LRT. We hope and expect that this creativity will continue to expand and flourish using the new MathWorks tools that have become available.

Cite As

James Peyton Jones (2021). VU-LEGO Real Time Target (, MATLAB Central File Exchange. Retrieved .

Comments and Ratings (23)


I would thank you for your work.
I have a small a problem when I trie de build a simulink program.

<< The call to lrt_make_rtw_hook, during the after_make hook generated the following error: Build failed during Make all >>

Any idee to resolve this problem ?
Many thanks


Hello Guys!
I am using this toolbox.
I could recieve the data in the form of packets.
i need to save the time, to check the data recieved is being lost or not.
I tried with different simulink block but i couldnt.
Please tell me how to model the timer/clock in simulink model which will be installed on NXT and should give the data along with the time.


I use Windows 7 64bit an MATLAB 2012a 32bit.
when I build an example model, I get the following output:
Warning: Inputs must be character arrays or cell arrays of strings.
### Wrapping unrecognized make command (angle brackets added)
### <>
### in default batch file
### Creating from C:\RTtools\VU-LRT\lrt_ecrobot.tmf
### Compiled for Lego NXT successfully.
### Configuring generated makefile for cygwin...
### Writing VU_testSoundTone1.oil....
### VU_testSoundTone1.oil written successfully!
### Writing ecrobot_hooks.h...
### Cleaning up make directory...
/cygdrive/c/RTtools/nxtOSEK/ecrobot/ecrobot.mak:268: *** multiple target patterns. Stop.

James Peyton Jones

Diego: Thanks for your positive feedback. I'm afraid the Fantom driver is fundamentally 32-bit, so the mexusb code will not compile for a 64-bit platform, (see the notes in the ReadMe file, Section 3). In general, feel free to email me directly for any support issues, or if you'd like to discuss this further. James.


This tool is a really nice tool. Congratulations!. However I have some problems regarding the tool with Windows 64 bits.
I took the example "VU_testUsbTxRx". I can compile from simulink, I know that for communicating the data from USB port, I have to use the .m file "VU_testUsbRxTx.m". However it gives me the error:

"Undefined function or method 'mexusb' for input arguments of type 'char'."

I know that the function mexusb.c which is in the private directory of the nxtusb directory is there, but it is already compile in a 32 bits platform. I examined the intaller file and this file only renames the file "mexusb.c" to "mexusb.mexw32", that means that "mexusb.c" is already a compiled version. I would like to know if a can have the original file in order to compile it in the 64 bits platform. With this, I will obtain a "mexusb.mexw64" file and I will be able to read from USB port.

Thanks for everything!


First of all I want to congratulate you. This is the best blockset you can use to develop your projects with lego nxt.
Secondly I would like to know if you are going to port this blockset to linux/unix. I think many people would be very grateful to you if you make the linux/unix version. I think it can't be very difficult since the compiler is GNU ARM Compiler and you have to use Cygwin.

Michael Smith

I've done a few builds now with this blockset and software without any difficulties. I downloaded this hoping I would be able to take full advantage of the greater freedom of programming offered in the Simulink and Stateflow environment over the software supplied with the NXT. It definitely met all my expectations. My son's science tutor was very interested in these tools in order to bring NXT programming to a higher level for her older students.

Thanks for the great work!

Guillaume MARTIN

Thank you very much for this work.

The install(1) seems to works fine.

But I have problems in "Step 3" :
- When I do "Installer(6)", I have to choose between lms_arm_nbcnxc_107.rfw and lms_arm_nbcnxc_128.rfw . Whitch one do I have to choose ?
- I choosed the 128 one to try. How can I see if the new firmware is correctly installed with "install(6)" ? My Lego doesn't give me any sign of life during the download !

I have problem in "Step 4" too :
When I try an installer(7), I want to give the name "HELLO", but the response is :
...Did not appear to rename correctly:

Thank you for your help,
Guillaume Martin


This is a great tool for teaching control systems.

I just miss one feature. Is there a possibility to log/monitor data from the brick and send it to a host pc by usb connection? For example to monitor the angle of the NXTway-GS with the HT-sensor. Not in realtime of course.


This is an invaluable tool for anyone who wants to run Simulink models on the Lego Mindstorms NXT system. The underlying code of the VU-LRT blockset is certainly more straightforward and intuitive than the ECRobot blockset on which it is based. Hopefully, its development will continue well into the future.

Ye Cheng


Great start on a great tool. Need more on the USB and BT Interface blocks and would be nice to have the Magnetic Compass Sensor block (also from HiTechnic). I will be using this in the classroom to teach my students about spacecraft control.

Chin-Wen Chuang

It seems to be aa great tool for NXT training. However, when I built the model, it alway show the below message
### Writing ecrobot_hooks.h...
make: *** No rule to make target `and'. Stop.
Then, stop the building procedure. Could you advise me, please?

Stephen Williams


It's a great tool for nxt!
Is there possibility to add RS485 RX/TX and I2C blocks in the future?

Richard Primerano

This is a very nice tool for anyone interested in learning Matlab/Simulink or looking for an alternative to Lego's graphical environment.

I have looked at several other alternatives for programming the NXT (in C, Java, and Matlab), and this has been the simplest to use. This package also gives you access to many of Matlab's existing toolboxes and blocksets which is a significant advantage over other alternatives.

Frank DiJoseph

This package is well put together. The installer greatly simplifies the setup process which is depedent upon several third-party tools. The package includes some simple examples to help verify your setup. The VU-LRT implementation is much simpler to use than other parties versions.


An excellent toolset for people who want to implement and learn control system algorithms using NXT.


James Peyton Jones

Michael: The current version of VU-LRT assumes installation on the C: drive, and installation on another drive may cause this problem. We will try to remove any such assumptions in the next version, but for now please install VU-LRT on the C: drive. In general, feel free to contact me directly for support issues.

Michael Hubatka

Michael Hubatka

I was very happy to read about this project. I downloaded the installer and successfully installed all the tools. But when I build an example model, I get the following output:

### Processing Template Makefile: D:\VU_LRT\lrt_ecrobot.tmf
Warning: Inputs must be character arrays or cell arrays of strings.
### Wrapping unrecognized make command (angle brackets added)
### <>
### in default batch file
### Creating from D:\VU_LRT\lrt_ecrobot.tmf
### Compiled for Lego NXT successfully.
### Configuring generated makefile for cygwin...
### Writing VU_testSoundTone2.oil....
### VU_testSoundTone2.oil written successfully!
### Writing ecrobot_hooks.h...
/cygdrive/c/RTtargets/nxtOSEK/ecrobot/ecrobot.mak:268: *** multiple target patterns. Stop.

I use Windows 7 64bit an MATLAB 2011b 32bit.

Any suggestion?

Gautam Vallabha

MATLAB Release Compatibility
Created with R2010a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!