Could anyone help me on how to read serial data and show/print it on the screen, from a Arduino Mega 2560 model onto a computer connected by a USB, using Matlab? I have tried may attempts on changing the code in Matlab but dont know where to correct it. Till now I am getting numbers but does not correspond to any meaning. Would be of great help if you can guide me on this.
Could anyone help me on how to read serial data and show/print it on the screen, from a Arduino Mega 2560 model onto a computer connected by a USB, using Matlab?
You have 4 hardware serial ports, but only one USB-to-serial converter, connected to RX0/TX0 (Serial). You won't be able to talk to the Serial Monitor AND Matlab at the same time.
I have tried may attempts on changing the code in Matlab but dont know where to correct it. Till now I am getting numbers but does not correspond to any meaning. Would be of great help if you can guide me on this.
Show some code, then we can help.
The Arduino software itself can talk to the device and show data. I'm trying to do the same procedure with Matlab with the same hardware configuration setup???
Here is the code below:
s = serial('COM8');
set (s, 'baudrate', 57600);
fopen(s)
while 1:10
disp(fread(s));
end
out = fscanf(s)
fclose(s)
The Arduino software itself can talk to the device and show data.
So, we need to see that code. Something about "the device" and how it is connected to the Arduino would be useful, too.
If the connection between the Arduino and "the device" is through Serial, the Arduino can't talk to the device and Matlab at the same time.
I don't want it to work simultaneously with the Arduino code. I just want it to be able to work with Matlab without the Arduino software running. Read data and print the data like the Arduino software.
The way I connected is on the previous post (picture 19). Its only connected by a USB to the computer.
I'm going to guess that English is not your native language, so I'm cutting you some slack.
I don't want it to work simultaneously with the Arduino code.
What is the "it" that you are referring to? There MUST be some Arduino code involved. Not working with the Serial Monitor or the IDE is different.
I just want it to be able to work with Matlab without the Arduino software running.
If you are referring to the Arduino IDE or Serial Monitor, that's fine. They don't need to be, and shouldn't, in the case of the Serial Monitor, be running. If you are referring to the software running on the Arduino, that MUST be running.
Read data and print the data like the Arduino software.
Which Arduino software are you talking about?
The way I connected is on the previous post (picture 19).
Which is a pretty lousy picture. All it shows is a side view of a shield on an Arduino. Can't even see what kind of shield it is.
You still haven't told us that.
I have given the Matlab code I used. Forget about using the Arduino Code with Matlab because its serial and cannot be used at the same time. Can you help on writing a Matlab code for reading and showing data or not? Another pic is below.
Another pic is below.
Is it really asking too much for you to just tell us what that device is?
Forget about using the Arduino Code with Matlab because its serial and cannot be used at the same time. Can you help on writing a Matlab code for reading and showing data or not?
Matlab communicates with the Arduino via the serial port. If you won't show what code is on the Arduino, or think that it is completely irrelevant, then, no, I can't help you.
You seem to have some idea that Matlab can communicate with the hardware, whatever it is, without the Arduino's involvement. That simply is not so.
techjack:
I have given the Matlab code I used. Forget about using the Arduino Code with Matlab because its serial and cannot be used at the same time. Can you help on writing a Matlab code for reading and showing data or not? Another pic is below.
Sorry, but this isn't a Matlab-focused forum.
Also, I attached an irrelevant pic too.
Yes you finally got my point. I’m trying to connect the Aduino Mega 2560 model to the computer using MATLAB to read and print data from it.
Why can’t MATLAB be able to read data from the Arduino Board, I’ve even heard LAB VIEW has the ability to read data from it.
techjack:
Yes you finally got my point. I’m trying to connect the Aduino Mega 2560 model to the computer using MATLAB to read and print data from it.
Why can’t MATLAB be able to read data from the Arduino Board, I’ve even heard LAB VIEW has the ability to read data from it.
That's because whoever wrote the labview extension for arduino also wrote a program that you upload to the arduino before using it. Probably.
I’m trying to connect the Aduino Mega 2560 model to the computer using MATLAB to read and print data from it.
Why can’t MATLAB be able to read data from the Arduino Board
Because Matlab only reads data sent to the Serial port by the Arduino. If you don't have code on the Arduino to read what Matlab sends, and return appropriate responses, you will not be able to read from the Arduino.
You might as well wish for the sun to rise in the west at night.