Taking some data from Arduino AnalogRead but sending to serial port with two decimal after scaling from 1023 end-scale to 5V real-end-scale
so, the sketch in Arduino is:
int sensorA;
float sensorA1;
void setup()
{
Serial.begin(9600); // sets the serial port to 9600
}
void loop()
{
sensorA = analogRead(0);
sensorA1=(float)sensorA/1023*5;
Serial.println(sensorA1);
delay(20); // wait 20ms for next reading
}
the objective is getting data from Arduino for being displayed on Matlab.
For openning the Serial Port from Matlab...
s = serial('COM6');
set(s,'BaudRate',9600);
fopen(s);
out = fscanf(s);
fclose(s)
delete(s)
clear s
the problems:
1) if MATLAB is run before Arduino connection, then Arduino found COM6 busy and it is not able to be connected
2) if Arduino get the COM6, the MATLAB find it busy and it is not able to connect and getting data from COM6
??? Error using ==> fopen
Port: COM6 is not available. Available ports: COM7.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
>>
seems the project is blocked at this time.
MATLAB runs an old version 6.5.0, but I think no later version is required for this single application
Next solution steps to be checked:
http://www.mathworks.co.uk/matlabcentral/fileexchange/32374-matlab-support-package-for-arduino-aka-arduinoio-package
getting data from Excel
http://www.mrexcel.com/forum/excel-questions/488335-receive-data-com-port.html
from Excel 2007
http://strokescribe.com/en/read-serial-port-excel-2007.html
http://robottini.altervista.org/arduino-and-real-time-charts-in-excel
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario