Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

To resolve issues starting MATLAB on Mac OS X 10.10 (Yosemite) visit: http://www.mathworks.com/matlabcentral/answers/159016

Arduino mega 2560

Asked by Mohammed on 15 Jun 2012
Latest activity Commented on by addie irawan on 24 Jan 2014

i have a problem to deal with arduino mega with simulink the problem is the digital block for (read or write) containing numbers from 2 : 19

and the arduino mega have 69 digital I/O

knowing that i modified the serv.pde file as mentioned in the read me file with the package

Can Any one help me ??

thanks for all

1 Comment

addie irawan on 24 Jan 2014

I have a problem on selecting pins for PWM that supported by ArduinoMega such as pin 2,4 etc. The warning prompt appeared when I selected it. Its mean the block is not supported for ArduinoMega which contras with the instruction available in model mask.

Please help.

Addie

Mohammed

Products

No products are associated with this question.

5 Answers

Answer by Rolfe Dlugy-Hegwer on 15 Jun 2012
Accepted answer

The Mega 2560 has 54 digital I/O pins, from 0 to 53, as specified here: http://arduino.cc/it/Main/ArduinoBoardMega2560 The board groups and labels these pins as "PWM", "Communication", and "Digital" pins. Can you clarify your question or explain what you are doing?

1 Comment

Mohammed on 15 Jun 2012

i'm using the arduino board with simulink by using arduino library for simulink when i select any block
it allow to me to choose pine no. from 2: 19 not from 0:54
http://www.mathworks.com/matlabcentral/fileexchange/32374

Rolfe Dlugy-Hegwer
Answer by Rolfe Dlugy-Hegwer on 15 Jun 2012

Hi Mohammed.I understand now. In your model, select Tools > Run on Target Hardware > Options. This action opens Configuration Parameters dialog. Wait a moment for the Run on Target Hardware pane to appear. Change Target hardware setting from Arduino Uno to Arduino Mega 2560. Save and close Configuration Parameters. Now you can enter higher values for the pin numbers. HTH, Rolfe

1 Comment

Mohammed on 16 Jun 2012

i'm using matlab 2011a
and i can arrive to the destination that you determined please tell me how to install the package to matlab simulink step bye step

Rolfe Dlugy-Hegwer
Answer by Rolfe Dlugy-Hegwer on 20 Jun 2012

I don't have any information on how to do this R2011a. The feature I described became available in Simulink R2012a. If you get access to R2012a, enter targetinstaller in the MATLAB Command Window. This action opens the Target Installer and provides instructions for installing support for Arduino.

3 Comments

Mohammed on 22 Jun 2012

Hi Rolfe
thank you very much for your help ..
i'm tried to use the support package with matlab 2012a when i choose the the folder that contain the package in target installer dialog an error message appear tell me that the extension i chose does not contain a valid support package

thanks a again for your help

Rolfe Dlugy-Hegwer on 22 Jun 2012

I'm looking into this and will get back to you soon.

Rolfe Dlugy-Hegwer on 22 Jun 2012

Solution #1: In Target Installer, on the "Install or update target" screen, select "Internet (recommended)". Do not select "Folder".

Rolfe Dlugy-Hegwer
Answer by Rolfe Dlugy-Hegwer on 22 Jun 2012

Easy Solution #1: In Target Installer, on the Install or update target screen, select Internet (recommended). Do not select Folder.

Solution #2, (For host computers that do not permit direct downloads from the Internet):

  1. On a private machine, go to http://www.mathworks.com/matlabcentral/fileexchange/35641-simulink-support-package-for-arduino-mega-hardware, click the Download All button.
  2. Transfer the download file, rtt_arduinomega2560_r2012a_v1_0.zip, to a USB memory stick.
  3. Connect the USB stick to the host computer that is running MATLAB.
  4. Determine the drive letter of the USB stick and the folder path of the download file, rtt_arduinomega2560_r2012a_v1_0.zip.
  5. Run Target Installer.
  6. On the "Install or update target" screen, select "Folder" and enter the folder path the download file, rtt_arduinomega2560_r2012a_v1_0.zip
  7. Continue, following the instructions.

3 Comments

Mohammed on 22 Jun 2012

i did this steps but the same error occur

Rolfe Dlugy-Hegwer on 22 Jun 2012

Hi Mohammed, Did you try Solution #1 and #2? Are you doing anything to change the zip file or extracting its contents? Which operating system are you using?

Rolfe Dlugy-Hegwer on 22 Jun 2012

I'll make a short video so you can see how I do it.

Rolfe Dlugy-Hegwer
Answer by Rolfe Dlugy-Hegwer on 22 Jun 2012

Here is a short video of Solution #2: http://screencast.com/t/p8YdLGUSmv8O

3 Comments

Mohammed on 22 Jun 2012

the target installed and i checked target options [Run on Target Hardware > Options] the target was Arduino Mega 2560 and the block allow to choose pins only from (2:19) only

Rolfe Dlugy-Hegwer on 25 Jun 2012

Enter arduinolib on the MATLAB command line to open the block library for Arduino. Replace the Digital Read and Digital Write blocks, and any other similar blocks, with the ones from this library.
Can you point me to the original source for your blocks? I'd like to see the readme file instructions regarding the serv.pde file.

Mohammed on 5 Jul 2012

thank you very much for your help the problem solved

but i have another problem

when i run the simulation using external mode an error occur (matlab has encountered internal problem needs to close )

Rolfe Dlugy-Hegwer

Contact us