Go Down

Topic: [IMPORTANT] How to connect Arduino and Matlab?  (Read 1 time) previous topic - next topic

jisparrow

I'm trying to connect Maltab and Arduino by this code:

Code: [Select]
arduino=serial('COM7','BaudRate',9600);
fopen(arduino);

But I get this message:

Quote
Open failed: Port: COM7 is not available. No ports are available. Use INSTRFIND to determine if other instrument objects are connected to the requested device.
What might be a proper reason?
I have another question which is; How can I save a text file (.txt) from Matlab to Arduino SD card .. ? Wether opening a .txt file in arduino or saving it from Matlab directly to Arduino SD card.


Robin2

What is especially IMPORTANT about your problem?

This seems to me to be a Matlab problem and if it was my problem I would be consulting a Matlab forum.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

jisparrow

What is especially IMPORTANT about your problem?

This seems to me to be a Matlab problem and if it was my problem I would be consulting a Matlab forum.

...R
Haven't I mentioned that I need help in importing text from a .txt file and opening it in Arduino?
Isn't that quite related to Arduino? or if you have a bit of knowledge would you like to share it with me?
Is there any possible way that I can read a text from a txt file or at least add the txt file from my computer to Arduino SD card?

Thanks in advance.
And it is IMPORTANT for sure since I have a presentation in a university in 3 days.

Robin2

The error you posted in your Original Post is not an Arduino error
Quote
Open failed: Port: COM7 is not available
It is a PC/Matlab error.

Quote
And it is IMPORTANT for sure since I have a presentation in a university in 3 days.
Perhaps you meant to say "Urgent" - if you are at university I would expect you to know the difference

But it is not our problem that you left it so late to figure out a solution. And your question is no more (or less) important than any other question here.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

jisparrow

The error you posted in your Original Post is not an Arduino errorIt is a PC/Matlab error.
Perhaps you meant to say "Urgent" - if you are at university I would expect you to know the difference

But it is not our problem that you left it so late to figure out a solution. And your question is no more (or less) important than any other question here.

...R
Aren't you intending to help or perhaps you know nothing about this?

I'm not in university I'm a highschool student who had to make a project and learn "uni subjects" by my own in order to present it in the university.

And in fact, I haven't left anything so late since I was busy writing an algorithm in matlab and eventually had to connect matlab to my application via arduino.

Urgent or important it is still a question that needs to be answered.

Robin2

perhaps you know nothing about this?
You are quite right. I don't know Matlab, or Windows for that matter.

I have been trying (with complete lack of success) to suggest that you ask your question where you are more likely to meet someone that knows Matlab.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

jisparrow

You are quite right. I don't know Matlab, or Windows for that matter.

I have been trying (with complete lack of success) to suggest that you ask your question where you are more likely to meet someone that knows Matlab.

...R
Mate, if my problem wasn't also related to arduino I wouldn't even think about posting it here..
But you see, I know that Arduino has a function called SD.open().. in order to open a text file from the SD card I have to put the file inside it first, and this text file has the results that are coming out from Matlab, so I was trying to reach the Arduino SD card directly from Matlab itself... or at least, save the result in a text file and then save the text file inside the SD card, I swear to god google is sick of me because of how much I've looked for an answer... It is a real urgent case I need an immediate help.. otherwise my future will be over... :/

ieee488

Is there some particular reason that Matlab has to write to a SD card on an Arduino shield?

Isn't writing to an SD card on the PC running the Matlab enough?


jisparrow

#8
Feb 18, 2016, 09:50 pm Last Edit: Feb 18, 2016, 09:55 pm by jisparrow
Is there some particular reason that Matlab has to write to a SD card on an Arduino shield?

Isn't writing to an SD card on the PC running the Matlab enough?


No it is not, you see, I used Arduino SD card in order to connect arduino to my application via Bluetooth...
This is the idea in general, I take the results from Matlab in a text file, then put the text file in Arduino SD card, then open the text file using SD.open(), read the results and send them to the application via Bluetooth HC-06. I already solved the bluetooth connection, but all I need is to know how to get the results and read them.. I'd be glad if anyone helped me, It'd save my life really...

spycatcher2k

If you want the code to do this, then feel free to ask for someone to write this for you (Though you may find that you will be parting with some cash) - If you need help, post the code you have attempted so far, and you may find that we are more likely to help polite people.

We help because we want to, not because you demand it.
Mrs Drew
-=-
http://www.uk-pcb.co.uk - UK PCB Fab Company
I will design & code for you, but I will also charge you (PM me)
If you don't like my answers, realize : I'm not being cheeky, I'm Just trying to prompt you to use your own brain/google etc.

jisparrow

If you want the code to do this, then feel free to ask for someone to write this for you (Though you may find that you will be parting with some cash) - If you need help, post the code you have attempted so far, and you may find that we are more likely to help polite people.

We help because we want to, not because you demand it.
For the love of god batman! I'm not asking for a damned code, I know how to code ..
I only needed to figure out if it is a possible way to whether read a text file in arduino that has been moved to arduino SD card OR a way that Matlab can directly write the file using fwrite!

I've been seraching everywhere! If you don't have an answer then simply don't comment...
Besides, this is a quite weird response from  Batman since he's my superhero ;-;

ieee488

#11
Feb 18, 2016, 11:24 pm Last Edit: Feb 18, 2016, 11:31 pm by ieee488
No it is not, you see, I used Arduino SD card in order to connect arduino to my application via Bluetooth...
This is the idea in general, I take the results from Matlab in a text file, then put the text file in Arduino SD card, then open the text file using SD.open(), read the results and send them to the application via Bluetooth HC-06. I already solved the bluetooth connection, but all I need is to know how to get the results and read them.. I'd be glad if anyone helped me, It'd save my life really...
That explanation still leaves me baffled.
I take the results from Matlab in a text file. HUH? How? With what?
put the text file in Arduino SD card  Arduino does this?
open the text file using SD.open(), read the results and send them to the application via Bluetooth HC-06 Arduino does this?  what application are you talking about?

.
.


EDIT:
Do you have the Matlab support package installed?
http://www.mathworks.com/hardware-support/arduino-matlab.html

.


Robin2

so I was trying to reach the Arduino SD card directly from Matlab itself.
You can't reach an SD Card on an Arduino directly from Matlab. You need to get Matlab to send data to an Arduino program and then the Arduino program will write the data on the SD Card.

I had assumed from my very first reply that you understood that.

And I come back, yet again, to the error message in your Original Reply in which it appears that Matlab could not find the COM port that your Arduino is connected to. At no stage since then have you said that that problem was solved or that it was no longer relevant.

If Matlab has a problem finding the COM port that your Arduino is connected to that seems to me to be a Matlab problem. I assume you have no difficulty connecting to the Arduino using the Arduino IDE.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up