I hope some of you guys have some Matlab experience or maybe can still help me.
I want to write an Interface for Matlab that works just like the Serial Monitor in Arduino.
But unfortunately, I do not have much experience with electronics, so I hope my questions do not sound too stupid. ^^'
So it is an Arduino Diecimila Board board I am using and there are six pins on it which I should make visible in Matlab. They are the Analog Input pins.http://arduino.cc/en/uploads/Main/ArduinoDiecimilaComponents.jpg
So I have a little function, with which I can get some output for one port.
But as I said, I understand some programming but little electronics and not much about ports. So I don't really know, how to open the additional ports and what port corresponds to what pin on the board (which is my biggest question, e.g. to which pin does "COM3" correspond?).
Does anybody know, what I have to enter, in order to get numbers like in the Serial Monitor for those six analog inputs?
The Matlab code looks like this:
s = serial('COM3'); %assigns the object s to serial port
set(s, 'InputBufferSize', 256); %number of bytes in inout buffer
set(s, 'FlowControl', 'hardware');
set(s, 'BaudRate', 9600);
set(s, 'Parity', 'none');
set(s, 'DataBits', 8);
set(s, 'StopBit', 1);
disp(['Port Setup Done!!',num2str(prop)]);
fopen(s); %opens the serial port
while(t <= 200) %Runs for 200 cycles - if you cant see the symbol, it is "less than" sign. so while (t less than 200)
a =fread(s); %reads the data from the serial port and stores it to the matrix a
a=max(a); % in this particular example, I'm plotting the maximum value of the 256B input buffer
x =[x a]; % Merging the value to an array, this is not very computationaly effective, as the array size is dynamic.
%Consider pre allocation the size of the array to avoid this. But beware, You might loose some important
%data at the end!
disp([num2str(t),'th iteration max= ',num2str(a)]);
a=0; %Clear the buffer
fclose(s); %close the serial port