View License

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

» Watch video

Highlights from
Motor Shields

4.66667
4.7 | 3 ratings Rate this file 81 Downloads (last 30 days) File Size: 503 KB File ID: #46133 Version: 1.0.0.1
image thumbnail

Motor Shields

by

Giampiero Campa (view profile)

 

08 Apr 2014 (Updated )

Motor Shield Driver Blocks

| Watch this File

File Information
Description

This package contains motor driver blocks for 3 Arduino Motor Shields:
1) Adafruit Motor Shield V1.x (DC and Stepper motor drivers)
2) Adafruit Motor Shield V2 (DC and Stepper motor drivers)
3) Arduino Motor Shield R3 (DC motor drivers for ports A and B)
Refer to the readme.txt file for more details and make sure you read AFMotorV2.pdf before using the Adafruit Motor Shield V2.

Acknowledgements

Device Drivers inspired this file.

Required Products Simulink
MATLAB
MATLAB release MATLAB 8.1 (R2013a)
Other requirements Simulink Support Package for Arduino
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (3)
15 Feb 2017 Franky de Bruyne

Thank you for this very nice package.

For use under Matlab 2016b, you will have to follow the following step:

1. Open afmotor_v2.mdl.
2. Go to Configuration Parameters --> Hardware Implementation.
3. Select any hardware board other than the board you are trying to Program
For Example, select Arduino Mega ADK.
Then reselect the board you are trying to program.
For example, select "Arduino Uno" board.
4. Click "Apply".
5. Execute the below commands in MATLAB command line:

modelName = 'afmotor_v2';
set_param(modelName, 'CustomInclude', '<Folder path where Motorshield_2016 is present>\Motorshield_2016\Motorshield_2016;<Folder path where Motorshield_2016 is present>\Motorshield_2016\Motorshield_2016\utility')
set_param(modelName, 'CustomSource', 'Wire.cpp twi.c Adafruit_PWMServoDriver.cpp Adafruit_MotorShield.cpp');

Please make sure you replace text "<Folder path where Motorshield_2016 is present>" with your absolute folder path in the above commands.

Thank you to Pradeep Karikere Siddagangaiah from Matlab in India for his help in this matter.

I have bundled this in some Matlab code that you can put in a script. Just change the name of the directory for your application.

% 1. Open afmotor_v2.mdl.
% 2. Go to Configuration Parameters --> Hardware Implementation.
% 3. Select any hardware board other than the board you are trying to Program
% For Example, select Arduino Mega ADK.
% Then reselect the board you are trying to program.
% For example, select "Arduino Uno" board.
% 4. Click "Apply".
% 5. Execute the below commands in MATLAB command line:

modelName = 'afmotor_v2';
Directory = 'C:\Users\dbr.ECAM\Documents\Ecam\Matlab\Arduino_Matlab\Matlab_2016\Motorshield';
Dir1 = [Directory '\Motorshield_2016\Motorshield_2016'];
Dir2 = [Directory '\Motorshield_2016\Motorshield_2016\utility'];
Dir12 = [Dir1 ';' Dir2];

set_param(modelName, 'CustomInclude', Dir12)
set_param(modelName, 'CustomSource', 'Wire.cpp twi.c Adafruit_PWMServoDriver.cpp Adafruit_MotorShield.cpp');

I hope this is helpful.

Franky De Bruyne

25 Nov 2016 masoud jafari

13 Nov 2014 Carlos Moran

Updates
01 Sep 2016 1.0.0.1

Updated license

Contact us