% Serial object
s = serial('COM12','BaudRate',9600,'DataBits',8);
% Close any open objects so they don't interfere
newobjs = instrfind;
fclose(newobjs);
% Open our serial object
fopen(s);
i need to detect some object from camera with MATLAB and then to operate servo motors..so that's why i need to send data from matlab to fpga. Do you think that there is another way to do it?Why do you want to send data from Matlab to fpga?
In any case your best best is probably UART. Get a 3dollar usb->UART converter like this one and implement a UART module on the FPGA (or download one, there are loads of free available implementations) so that the FPGA can talk to the converter.
In Matlab: You open a serial object and you write to it in individual bytes.
You can write:C:% Serial object s = serial('COM12','BaudRate',9600,'DataBits',8); % Close any open objects so they don't interfere newobjs = instrfind; fclose(newobjs); % Open our serial object fopen(s);
get(s)
To display all the parameters of the s object that you might want to configure and you do that by writing:
set(s, '<parametername>', <parametervalue> );
I have experience with reading from the port using 'fread()' but don't haven't tried writing to it. Shouldn't be too hard.
I don't know if you will need a special toolbox for the serial stuff to work on Matlab. If you run into toolbox issues then try Octave, maybe they have a serial implementation aswell.
by Jake Hertz
by Aaron Carman
by Jake Hertz