File Exchange

image thumbnail

Arduino_Engineering​_Kit_Hardware_Suppo​rt_18b

version 1.2 (7.43 MB) by MathWorks Maker Team
MATLAB and Simulink support for hardware components used in the Arduino Engineering Kit.

34 Downloads

Updated 17 Sep 2019

View License

Note: This version is for MATLAB release R2018b only.

For MATLAB R2018a please use this file here:
https://www.mathworks.com/matlabcentral/fileexchange/66568-arduino_engineering_kit_hardware_support

For MATLAB R2019a and later, please use this file here:
https://www.mathworks.com/matlabcentral/fileexchange/70554-arduino_engineering_kit_hardware_support_19a

This package includes MATLAB and Simulink files that allow users to communicate with and control the sensors and actuators used in the Arduino Engineering Kit, most of which are connected through the MKR Motor Carrier. This includes:
• DC motor – control up to 4 DC motors simultaneously
• Servo motor – control up to 8 servo motors simultaneously
• Encoder – read up to 2 encoders simultaneously
• Tachometer – read rotational speed from the hall sensor on the motorcycle’s inertia wheel
• BNO055 IMU sensor – read from the accelerometer, magnetometer, and gyroscope
• Ultrasonic sensor – measure the distance to an object
• LiPo Battery – read the battery voltage

Examples are included to demonstrate how to use the MATLAB functions and Simulink blocks included in this package.

Learn more about the Arduino Engineering Kit at www.mathworks.com/arduino-kit

Important notes:
1) After installing this toolbox, type the following command in MATLAB to open the ReadMe
>> edit ArduinoKitHardwareSupportReadMe.txt
2) Be sure to follow the steps in this file, as it provides instructions on downloading the Arduino library for the MKR Motor Carrier. This library is required for some of the functionality to work.

Cite As

MathWorks Maker Team (2019). Arduino_Engineering_Kit_Hardware_Support_18b (https://www.mathworks.com/matlabcentral/fileexchange/68620-arduino_engineering_kit_hardware_support_18b), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (9)

James Hill

This is part of a bug report I have filed:

In chapter 3 of the AEK it demos a few items from the Arduino IDE. When you load the IDE it informs you that your board managers are out of date. Once you have updated them it will overwrite everything in:

~/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd to the new version of 1.6.20 from 1.6.18 --> this breaks Simulink compilation. The various other hardware directories: "avr" and "sam" are also updated and become broken as well.

Thankfully, the workaround is rather simple. I just renamed the directory back to 1.6.18 and Simulink returns to working.

James Hill

Here was a solution that worked for me:

https://www.mathworks.com/matlabcentral/answers/407753-arduino-mkr1000-simulink-build-procedure-aborted-due-to-error

Basically, order of installation is important due to the version of the samd core and the make files not keeping up or poorly implemented make files that do not test for the installed version

you need samd/1.6.18. even the latest implementation is 1.6.20

if you are in a Linux environment you can type in the following at a command prompt:
find /home/gilgamesh007 -name "Arduino.h"

James Hill

=== Simulation (Elapsed: 15 sec) ===
### Starting build procedure for model: myDCMotorControl
Error:/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -std=gnu++11 -fno-threadsafe-statics -fno-rtti -fno-exceptions -Os -c -g -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=10801 -MMD -MP -MF"MW_PWM.dep" -MT"MW_PWM.o" -MMD -mcpu=cortex-m0plus -fpermissive -DF_CPU=48000000L -DARDUINO_SAMD_MKR1000 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x824e -DUSBCON -DUSB_MANUFACTURER=\""Unknown\"" -DUSB_PRODUCT=\""Genuino MKR1000\"" -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_MKR1000_ -DMODEL=myDCMotorControl -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DUNIX -DON_TARGET_WAIT_FOR_START=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DEXT_MODE=1 -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 -DMW_TIMERID=9 -DMW_PRESCALAR=256 -DMW_TIMERCOUNT=18750 -DMW_SCHEDULERCOUNTER=1 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_ANALOG_REF_=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=0 -DTID01EQ=0 -DON_TARGET_WAIT_FOR_START=1 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=myDCMotorControl -DNUMST=1 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DUNIX -I/home/gilgamesh007/MATLAB_Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files/work -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/shared/svd/include -I/home/gilgamesh007/MATLAB_Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files/work/myDCMotorControl_ert_rtw -I/usr/local/MATLAB/R2018b/extern/include -I/usr/local/MATLAB/R2018b/simulink/include -I/usr/local/MATLAB/R2018b/rtw/c/src -I/usr/local/MATLAB/R2018b/rtw/c/src/ext_mode/common -I/usr/local/MATLAB/R2018b/rtw/c/ert -I/usr/local/MATLAB/R2018b/toolbox/coder/rtiostream/src/utils -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS-Atmel/1.1.0/CMSIS/Device/ATMEL -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/cores/arduino -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/variants/mkr1000 -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinotarget/include -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinotarget/scheduler/include -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/armcortexmbase/scheduler/include -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinobase/include -I/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/shared/externalmode_daemon/include -o MW_PWM.o /home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinobase/src/MW_PWM.cpp
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinobase/src/MW_PWM.cpp:6:21: fatal error: Arduino.h: No such file or directory
#include "Arduino.h"
^
compilation terminated.
gmake: *** [MW_PWM.o] Error 1
### Build procedure for model: 'myDCMotorControl' aborted due to an error.
Error:Error(s) encountered while building "myDCMotorControl":
### Failed to generate all binary outputs.

typing the following command:
find /home/gilgamesh007 -name "Arduino.h" >> ArduinoHeader.txt
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/arduino-1.8.1/hardware/arduino/avr/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/avr/1.6.23/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/sam/1.6.12/cores/arduino/Arduino.h
/home/gilgamesh007/Documents/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.20/cores/arduino/Arduino.h

uname -a
Linux pop-os 4.18.0-15-generic #16pop2-Ubuntu SMP Fri Feb 22 17:07:14 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

If I try starting a 'sudo matlab' I run into a license issue.

I still find this error with Matlab2018b

Code Generation 1
Elapsed: 47 sec
C:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/arm-none-eabi-gcc/4.8.3-2014q1/bin/arm-none-eabi-g++ -std=gnu++11 -fno-threadsafe-statics -fno-rtti -fno-exceptions -Os -c -g -w -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -Dprintf=iprintf -DARDUINO=10801 -MMD -MP -MF"MW_arduinoI2C.dep" -MT"MW_arduinoI2C.o" -MMD -mcpu=cortex-m0plus -fpermissive -DF_CPU=48000000L -DARDUINO_SAMD_MKR1000 -DARDUINO_ARCH_SAMD -D__SAMD21G18A__ -mthumb -DUSB_VID=0x2341 -DUSB_PID=0x824e -DUSBCON -DUSB_MANUFACTURER=\""Unknown\"" -DUSB_PRODUCT=\""Genuino MKR1000\"" -D_RUNONTARGETHARDWARE_BUILD_ -D_ROTH_MKR1000_ -DMODEL=motoSys2_balance -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -DON_TARGET_WAIT_FOR_START=1 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DTID01EQ=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=1 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -D__MW_TARGET_USE_HARDWARE_RESOURCES_H__ -DRT -DMW_TIMERID=9 -DMW_PRESCALAR=256 -DMW_TIMERCOUNT=1875 -DMW_SCHEDULERCOUNTER=1 -D_RTT_BAUDRATE_SERIAL0_=9600 -D_RTT_BAUDRATE_SERIAL1_=9600 -D_RTT_ANALOG_REF_=0 -DCLASSIC_INTERFACE=0 -DALLOCATIONFCN=0 -DEXT_MODE=1 -DONESTEPFCN=1 -DTERMFCN=1 -DMULTI_INSTANCE_CODE=0 -DINTEGER_CODE=0 -DMT=1 -DTID01EQ=0 -DON_TARGET_WAIT_FOR_START=1 -DEXIT_FAILURE=1 -DEXTMODE_DISABLEPRINTF -DEXTMODE_DISABLETESTING -DEXTMODE_DISABLE_ARGS_PROCESSING=1 -DSTACK_SIZE=64 -DRT -DMODEL=motoSys2_balance -DNUMST=2 -DNCSTATES=0 -DHAVESTDIO -DMODEL_HAS_DYNAMICALLY_LOADED_SFCNS=0 -IC:/Users/anurag/AppData/Roaming/MathWorks/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files -IC:/PROGRA~3/MATLAB/SupportPackages/R2018b/toolbox/target/shared/svd/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinobase/include -IC:/Users/anurag/AppData/Roaming/MathWorks/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files/motoSys2_balance_ert_rtw -IC:/Users/anurag/AppData/Roaming/MathWorks/MATLAB Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files/Motorcycle -IC:/PROGRA~1/MATLAB/R2018b/extern/include -IC:/PROGRA~1/MATLAB/R2018b/simulink/include -IC:/PROGRA~1/MATLAB/R2018b/rtw/c/src -IC:/PROGRA~1/MATLAB/R2018b/rtw/c/src/ext_mode/common -IC:/PROGRA~1/MATLAB/R2018b/rtw/c/ert -IC:/PROGRA~1/MATLAB/R2018b/toolbox/coder/rtiostream/src/utils -IC:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS/4.5.0/CMSIS/Include -IC:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/tools/CMSIS-Atmel/1.1.0/CMSIS/Device/ATMEL -IC:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/cores/arduino -IC:/ProgramData/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/variants/mkr1000 -IC:/PROGRA~3/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinotarget/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinotarget/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/armcortexmbase/scheduler/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2018b/toolbox/target/shared/externalmode_daemon/include -IC:/PROGRA~3/MATLAB/SupportPackages/R2018b/3P.instrset/arduinoide.instrset/idepkgs/packages/arduino/hardware/samd/1.6.18/libraries/Wire -o MW_arduinoI2C.o C:/ProgramData/MATLAB/SupportPackages/R2018b/toolbox/target/supportpackages/arduinobase/src/MW_arduinoI2C.cpp
arm-none-eabi-g++: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files: No such file or directory
arm-none-eabi-g++: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files/motoSys2_balance_ert_rtw: No such file or directory
arm-none-eabi-g++: error: Add-Ons/Toolboxes/Arduino_Engineering_Kit_Project_Files/Motorcycle: No such file or directory
gmake: *** [MW_arduinoI2C.o] Error 1
The make command returned an error of 2
'An_error_occurred_during_the_call_to_make' is not recognized as an internal or external command,
operable program or batch file.
### Build procedure for model: 'motoSys2_balance' aborted due to an error.
Error(s) encountered while building "motoSys2_balance":
### Failed to generate all binary outputs.

In the latest version 1.1.1, this bug is fixed. The Simulink Support for Arduino MKR Motor Carrier library will show up on the library browser and the Simulink Support for Arduino Sensors is now under Sensors sub folder in the Simulink Support package for Arduino.

HTH,
Madhu

I am having the same problem as Multiplexer and Sebastian. I don't have both "Simulink Support for Arduino MKR Motor Carrier" as well as "Simulink Support for Arduino Sensors" in my Simulink's Library. It is required for the Engineering kit chapter- 2.3.2.1 Arduino Device Driver Blocks

I have the same problem like Multiplexer. The Library does not show in Simulink Library browser.

Multiplexer

Library does not show in Simulink Library browser. Upon library refresh an error shows up in Matlab command window:
"Warning: An error occurred while parsing
"C:\Users\<username>\Documents\MATLAB\Add-Ons\Toolboxes\Arduino_Engineering_Kit_Hardware_Support_18b\simulink\blocks\slblocks.m".
Error Message: Invalid arguments in the message cell. They should be of type 'character vector',
'float' or 'integer'. "

I followed steps from the ....ReadMe.txt file and reinstalled the add-on (throught the Matlab Add-on explorer). Nothing works.

Updates

1.2

Updating MATLAB Release Compatibility and the description to provide additional links

1.1.1

Fixing a bug identified by user - Library not visible in Library browser.

1.1

Fixing path related issues

1.0.1

Updating release compatibiltity

MATLAB Release Compatibility
Created with R2018b
Compatible with R2018b
Platform Compatibility
Windows macOS Linux
Communities

matlab/MATLABAddon/+arduinoioaddons/+arduino

simulink/+motorcarrier/+blocks

simulink/+motorcarrier/+internal

simulink/blocks