File Exchange

image thumbnail

Simulink Support Package for LEGO MINDSTORMS EV3 Hardware

Run models on LEGO MINDSTORMS EV3.



Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware enables you to create and run Simulink models on LEGO MINDSTORMS EV3 hardware. The support package includes a library of Simulink blocks for configuring and accessing LEGO MINDSTORMS EV3 sensors, actuators, and communication interfaces. It also enables you to interactively monitor and tune algorithms developed in Simulink as they run on the LEGO MINDSTORMS EV3.

This support package is functional for R2014a and beyond.

Comments and Ratings (17)

ian Van

Ben Wang

Using R2018a. I always got this. Please help me.

### Generating code into build folder: D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw
### Invoking Target Language Compiler on ev3_lft.rtw
### Using System Target File: E:\Program Files\MATLAB\R2018a\rtw\c\ert\ert.tlc
### Loading TLC function libraries
### Initial pass through model to cache user defined code
### Caching model source code
### Writing header file ev3_lft_types.h
### Writing header file ev3_lft.h
### Writing header file rtwtypes.h
### Writing source file ev3_lft.c
### Writing header file ev3_lft_private.h
### Writing source file ev3_lft_data.c
### Writing header file rtmodel.h
### Writing source file ert_main.c
### TLC code generation complete.
### Evaluating PostCodeGenCommand specified in the model
### Using toolchain: MinGW64 | gmake (64-bit Windows)
### 'D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw\' is up to date
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>call "\\benson\E$\Program Files\MATLAB\R2018a\bin\win64\checkMATLABRootForDriveMap.exe" "\\benson\E$\Program Files\MATLAB\R2018a" 1>mlEnv.txt
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>for /F %a in (mlEnv.txt) do set "%a"\n
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>set "MATLAB_ROOT=H:"\n
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>set "ALT_MATLAB_ROOT=H:"\n
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>set "MATLAB_BIN=H:\bin"\n
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>set "ALT_MATLAB_BIN=H:\bin"\n
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>cd .
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>if "" == "" ("E:\Program Files\MATLAB\R2018a\bin\win64\gmake" MATLAB_ROOT=H: ALT_MATLAB_ROOT=H: MATLAB_BIN=H:\bin ALT_MATLAB_BIN=H:\bin -f all ) else ("E:\Program Files\MATLAB\R2018a\bin\win64\gmake" MATLAB_ROOT=H: ALT_MATLAB_ROOT=H: MATLAB_BIN=H:\bin ALT_MATLAB_BIN=H:\bin -f )
"C:\TDM-GC~1\bin/gcc" -c -ansi -pedantic -Wno-long-long -fwrapv -m64 -O0 -I -I -I -I -I -I -c -nostdinc -DMODEL=ev3_lft -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DRT -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTERMFCN=1 -DONESTEPFCN=1 -DMAT_FILE=0 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=ev3_lft -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -ID:/MATLAB/LegoFirstTry -IC:/ProgramData/MATLAB/SupportPackages/R2018a/toolbox/target/supportpackages/ev3/include -ID:/MATLAB/LegoFirstTry/ev3_lft_ert_rtw -IH:/extern/include -IH:/simulink/include -IH:/rtw/c/src -IH:/rtw/c/src/ext_mode/common -IH:/rtw/c/ert -I"/.." -I"/.." -I"/.." -IH:/toolbox/target/codertarget/rtos/inc -IC:/ProgramData/MATLAB/SupportPackages/R2018a/toolbox/target/supportpackages/ev3/src -o "ev3_lft.obj" "ev3_lft.c"
In file included from ev3_lft.c:16:0:
ev3_lft.h:18:18: fatal error: math.h: No such file or directory
compilation terminated.
gmake: *** [ev3_lft.obj] Error 1
D:\MATLAB\LegoFirstTry\ev3_lft_ert_rtw>echo The make command returned an error of 2
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' 不是内部或外部命令,也不是可运行的程序
### Creating HTML report file ev3_lft_codegen_rpt.html
### Build procedure for model: 'ev3_lft' aborted due to an error.
Error(s) encountered while building "ev3_lft":
### Failed to generate all binary outputs.

Pradeep KS

MATLAB R2018a is out!!

1. Measure data using LEGO EV3 blocks: You can now read data from the LEGO® MINDSTORMS® EV3 brick using these blocks
* Battery: Measures the voltage of the battery located in the EV3 brick.
* Timer: Measures the elapsed time from the time the EV3 brick starts running the Simulink® model.

2. Measure data using LEGO EV3 Compatible NXT Sensor blocks: You can now measure data from the LEGO NXT sensors connected to the LEGO MINDSTORMS EV3 brick using these blocks
* NXT Touch Sensor: Reads the state of the NXT touch sensor.
* NXT Ultrasonic Sensor: Measures the distance between the NXT ultrasonic sensor and the nearest object in front of the sensor.
* NXT Gyro Sensor: Measures the rate of rotation (yaw) along the single axis of the HiTechnic NXT gyro sensor.
* NXT Sound Sensor: Reads the sound level measured by the NXT sound sensor.

Hi Prof Perruquetti.
I created a Tech Support Case to investigate the compilation issue. One of our engineers will be in touch soon.
Greg DA

Hello I am using Matlab 2018a on a mac book pro (Mac OS High Sierra), I dowloaded and installed "Simulink® Support Package for LEGO® MINDSTORMS® EV3 Hardware". Then I open "ev3_drive_openloop" and then deploy to hardware.
I get the following message:

"### Starting build procedure for model: ev3_drive_openloop
Code Generation 1
Elapsed: 3 sec
usr/local/carlson-minot/crosscompilers/bin/arm-none-linux-gnueabi-gcc -c -MMD -MP -MF"ev3_drive_openloop.dep" -MT"ev3_drive_openloop.o" -O2 -Iusr/local/carlson-minot/crosscompilers/arm-none-linux-gnueabi/libc-2014.05-29-sysroot/usr/include -Iusr/local/carlson-minot/crosscompilers/lib/gcc/arm-none-linux-gnueabi/4.8.3/include -Iusr/local/carlson-minot/crosscompilers/lib/gcc/arm-none-linux-gnueabi/4.8.3/include-fixed -IEV3Source -IEV3Source -IEV3Source -c -nostdinc -DMODEL=ev3_drive_openloop -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DUNIX -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DRT -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=ev3_drive_openloop -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DUNIX -I/Users/perruquetti/Desktop/Calcul/MATLAB/mesMatlab -I/Users/perruquetti/Desktop/Calcul/MATLAB/mesMatlab/ocuments/MATLAB/SupportPackages/R2018a/toolbox/target/supportpackages/ev3/include -I/Users/perruquetti/Desktop/Calcul/MATLAB/mesMatlab/ev3_drive_openloop_ert_rtw -I/Users/perruquetti/Desktop/Calcul/MATLAB/mesMatlab/ocuments/MATLAB/SupportPackages/R2018a/toolbox/target/supportpackages/ev3/ev3demos -I/Applications/ -I/Applications/ -I/Applications/ -I/Applications/ -I/Applications/ -IEV3Source/.. -IEV3Source/.. -IEV3Source/.. -I/Applications/ -I/Users/perruquetti/Desktop/Calcul/MATLAB/mesMatlab/ocuments/MATLAB/SupportPackages/R2018a/toolbox/target/supportpackages/ev3/src -o ev3_drive_openloop.o ev3_drive_openloop.c
/bin/sh: usr/local/carlson-minot/crosscompilers/bin/arm-none-linux-gnueabi-gcc: No such file or directory
gmake: *** [ev3_drive_openloop.o] Error 127
### Build procedure for model: 'ev3_drive_openloop' aborted due to an error.
Error(s) encountered while building "ev3_drive_openloop":
### Failed to generate all binary outputs."

It seams that the cross compiler (probably part of the thirdpart) was not dowloaded and installed. I check if "usr/local/carlson-minot/crosscompilers/bin/arm-none-linux-gnueabi-gcc" does and exist and it was not the case. I tried to install it manually... but did not succeed. Can you provide me some help with this problem ? (I am Professor at Ecole Centrale and teaching control and robotics: thus I know that this package is working with release 2017b on windows for my students).
Thanks best regards

I am using MATLAB 2017b (on MacOS). After setting

the connection mode to bluetooth,
and the ev3 id I read on the brick,
when I try to deploy on target hardware the ev3_getting started demo, I get the following error :

### Build procedure for model: 'ev3_gettingstarted' aborted due to an error. The following error occurred during deployment to your hardware board: Instrument Control Toolbox is required for this functionality.

This toolbox is not in the requirements EV3 2017B reqs for the EV3 Support Package, therefore my question.

Edit : I was able to deploy using USB mode, without error wrt the ICT toolbox

Mohith Prabhu

@ Wendell Capili
Simulink Support Package for LEGO Mindstorms EV3 is supported on Mac starting from R2016a release.
Details can be found here :

Is there no version for macOS? I am installing but this is what I am getting:

Simulink Support Package for LEGO MINDSTORMS EV3 Hardware cannot be installed on this system.
It requires:

Base Product: Simulink
Host Platforms: Win32,Win64,Linux64

Marco Biroli

I take back what I previously said about the 2016a version. The 2017a is much more well rounded and solved nearly all the problems I had. It's great to see all the effort that went in this add-on in just a year ! Keep it up !

Marco Biroli

There is no way as of 2016a to read distance from an infrared sensor, furthermore it could note manage to retreive data while the program runs in external mode, but maybe i'm just not good with this yet

I always get the Message, when i try to install the package:

There was a problem installing the support package. To resolve this issue, contact Technical Support

I have MATLAB R2016b.

What is the Problem here?

Pradeep KS

Hi, I was trying to install the support file for my MATLAB, I own the 2014a release, but everytime I try I always get this error message:

"MATLAB Support Package for LEGO MINDSTORMS EV3 Hardware is not available for this release of MATLAB."

So, what I need to do? It is because I don't have the data acquisition toolbox?

I was trying to install the support file for MATLAB ( I already have the support package for Simulink). Here's the link:

However, I got this error:
The file you are trying to view is not in a published state.

How can I get this support package ? And do I need it if I already have the Simulink support package ?


John (view profile)

Is there a way to get this to work on Mac platform as I get an error

Brian McKay

@J S: Sorry, but the Simulink Support Package for Lego MINDSTORMS EV3 Hardware is only available for release R2014a onwards; there is no support package for R2013b and older releases.


J S (view profile)

how should i install it in 2013b version?
(my school haven't got the latest vertion yet)

MATLAB Release Compatibility
Created with R2014a
Compatible with R2014a to R2018a
Platform Compatibility
Windows macOS Linux
Tags Add Tags

More Files in the  Maker Community

MATLAB Online Live Editor Challenge

Win cash prizes and have your live script featured on our website

Learn more

Download apps, toolboxes, and other File Exchange content using Add-On Explorer in MATLAB.

» Watch video