Sie sind auf Seite 1von 7

Arduino-Simulink

Course 26/8 to 6/9 9-12am, daily

University of Jordan

Course coordinator:
Mohammad AlShawabkeh/ B.Sc student Mechatronics engineering 09 Eng91moh@hotmail.com +962797150681

Prerequisites:
Created by: Mohammad AlShawabkeh Mechatronics Engineering/B.Sc. Student Faculty of Engineering & Technology The University of Jordan Madaba, Jordan www. eng91moh.blogspot.com Mobile/Cellphone: +962 797150681

Electronics 1 Digital logic design

Embedded Coder Support Package for Arduino (Arduino Target):


1.

Highlights: allows you to create Simulink applications that will run autonomously on your Arduino board. Using Simulink Coder and Embedded Coder, the Simulink model is automatically converted to readable C code, compiled, and downloaded to the Arduino.

2.

Requirements: A. MATLAB R2011a or later. B. . Arduino ID:arduino- 022 not arduino-1.0.1.

3.

Downloading: A. Arduino ID: arduino- 022: http://arduino.googlecode.com/files/arduino-0022.zip

B. Arduino Target:

A. http://www.mathworks.com.

B.

C.

D.

E.

F.

Or: http://www.mathworks.com/matlabcentral/fileexchange/30277-embedded-codersupport-package-for-arduino

4.

Dealing with Simulink: * QUICK START:

1. After downloading the Arduino ID: arduino- 022.

2. Delete any previous version of Arduino target.

3. Unzip arduino.zip to a folder without spaces in its name, e.g. c:\ArduinoTarget

4. Add the subfolders arduino, demos and blocks to your MATLABPATH, e.g. by typing the following commands in the MATLAB command window:

>> cd c:\ArduinoTarget >> addpath(fullfile(pwd,'arduino'),fullfile(pwd,'blocks'),fullfile(pwd,'demos')) >> savepath 3

If the savepath command does not work, you may need to invoke MATLAB in administrator mode. For more information, see http://www.mathworks.com/support/solutions/en/data/1-9574H9/

5. Type the following command to refresh Simulink customizations:

>> sl_refresh_customizations

6. Connect your Arduino board to the USB port

7. Set up preferences. These are persistent across MATLAB sessions, so you don't have to specify them each time you start MATLAB.

a) Specify location of the Arduino IDE

>> arduino.Prefs.setArduinoPath('c:\Program Files\arduino\arduino-0022')

b) Specify Arduino board (Duemilanove, Uno, Mega, etc.)

>> arduino.Prefs.setBoard

% see list of board options

>> arduino.Prefs.setBoard('uno') % choose a specific board

c) Find the COM port associated with Arduino

>> comPorts=arduino.Prefs.searchForComPort

If the above command doesn't show any ports, open Windows Device Manager (http://technet.microsoft.com/en-us/library/cc754081.aspx), navigate to "Ports (COM & LPT)", and look for ports labeled "USB Serial Port" or "Arduino"

d) Specify the COM port 4

>> arduino.Prefs.setComPort('COM9'); 8. Open your project's Simulink file. 9. Use Arduino Target:

10.Change the Arduino IO blocks to Arduino Target blocks:

11. Change the "Code Generation" options: A. Tools > Code Generation>>Options>>

>>OK 12. Build and deploy the executable by pressing Ctrl+B, or choosing Tools > Code Generation > Build Model.

13. If you want to use this library later, you have to write this command in the MATLAB command window: >> cd c:\ArduinoTarget

*References: 1. Books: A. Practical Electronics for Inventors, Paul Scherz, Copyright 2000 by The McGraw-Hill Companies. All rights reserved. B. Introduction to Simulink with Engineering Applications, Steven T. Karris, Copyright 2006 Orchard Publications. All rights reserved. C. Designing Embedded Systems with PIC Microcontrollers, Second Edition,Copyright 2010, Tim Wilmshurst. Published by Elsevier Ltd. All rights reserved. 2.Websites: A. B. Arduino.cc Mathworks.com

Das könnte Ihnen auch gefallen