Connecting to arduino - timeout

9 views (last 30 days)
ulrich
ulrich on 8 Mar 2012
Commented: Brais Gonzalez on 22 Nov 2017
Hallo!
I tried to connect matlab to my arduino uno getting the following reply:
>> a= arduino('COM6')
Attempting connection ........
Warning: A timeout occurred before the Terminator was reached.
??? Error using ==> arduino>arduino.arduino at 102
Connection unsuccessful, please make sure that the Arduino is powered on, running either srv.pde, adiosrv.pde or mororsrv.pde, and
that the board is connected to the indicated serial port. You might also try to unplug and re-plug the USB cable before attempting a
reconnection.
What I did before is:
downloaded the matlab arduino softwar in the folder ...toolbox\matlab
opened matlab as administrator
set a path to the folder ...toolbox\matlab\arduino
pluged in the arduino
and typed the command (see above).
And than there comes the error message. :-(
With the arduino 1.0 software the arduino works fine. I uploaded several files to blink the diode and it worked fine.
What I did not understand is that in the error message of matlab it saies "...running either srv.pde...". How can I start the srv.pde software?
Thanks for your help!
Ulrich

Accepted Answer

Grufff
Grufff on 8 Mar 2012
The srv.pde "software" is actually a server script which you need to upload and run on the Arduino. It is this script which enables Matlab to communicate with and control the Arduino.
The srv.pde sketch is supplied in the Matlab Arduino support package here:
You upload it to the board just like you would any other standard sketch. Full instructions are contained in the readme file that comes with the support package... quoted snippet here:
"UPLOAD SRV.PDE (OR ADIOSRV.PDE) TO THE ARDUINO BOARD (to be done only once):
The srv.pde (or adiosrv.pde) is the "server" program that will continuously run on the microcontroller. It listens for MATLAB commands arriving from the serial port, executes the commands, and, if needed, returns a result.
The following instructions are needed to upload the srv.pde file into the controller's flash memory. Note that if you don't have the motor shield and don't plan to use it, then you can UPLOAD THE ADIOSRV.PDE file instead the instructions are the same, except for the folder location).
As long as no other file is uploaded later, this step does not need to be repeated anymore, and the package can be used as soon as the board is connected to the computer..... "
Follow the instructions in the readme, these will walk you through uploading srv.pde to your Arduino and should solve your problem.
  2 Comments
ulrich
ulrich on 8 Mar 2012
Thanks Grufff!
with the adiosrv.pde it works well (uploading the srv.pde resulted in a lot of error messages). anyway, it works! great!
I read out the acceleration data of a sensor but could only get about 120 results per second which is not enough for my purposes. Do you maybe know it that's the best i can get or is there a way to make the analogRead faster? Maybe there's a way to write the data into some memory on the arduino first before reading it form matlab after the measurement is done?
Cheers,
Ulrich
Brais Gonzalez
Brais Gonzalez on 22 Nov 2017
The PWM outputs provide 50,000 values per second. You could make a program that sends the data obtained, to pins 2-13 and obtain the information in the form of PWM.

Sign in to comment.

More Answers (1)

kartik p
kartik p on 28 Jun 2014
i tried using the motor pde..but while compiling..it shows me an error dat AFMOTOR.h file is missing...u mean to say for matlab to control the servos via arduino i need to have adafruit motorshield??nd if no..den wich pde must be loaded into arduino for controlling servos?coz i tried with adiosrv.pde but matlab says no pde related to servos found so no action taken....

Categories

Find more on MATLAB Support Package for Arduino Hardware in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!