File Exchange

image thumbnail

Motor Shields

version 1.0.0.1 (503 KB) by

Motor Shield Driver Blocks

4.66667
3 Ratings

50 Downloads

Updated

View License

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.

Comments and Ratings (3)

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

masoud jafari

Carlos Moran

Updates

1.0.0.1

Updated license

MATLAB Release
MATLAB 8.1 (R2013a)
Acknowledgements

Inspired by: Device Drivers

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

» Watch video