FPGA and ethernet communication

18 views (last 30 days)
amey patil
amey patil on 25 Nov 2011
Edited: Star Strider on 27 Jul 2014
I want to use TCPIP protocol on port 80 to connect fpga kit named ML505 with matlab.
Can i do it???
If yes den how??
I know there are some commands like
echotcpip = start or stop TCP/IP echo server
resolvehost = Network name or network address
tcpip = Create TCPIP object
What is the use of this commands i didnot get the meaning of creating TCPIP object when my object is xilixs FPGA ML505 kit???

Accepted Answer

Amy
Amy on 12 Jul 2014
Edited: Star Strider on 27 Jul 2014
You can download a HTTP web server IP core from http://www.webphyfpga.com that transfers data between MATLAB and FPGA using the HTTP protocol and the MATLAB 'urlread' command. Physical Ethernet connection to the FPGA is made via standard LVDS IO and a RJ-45 jack (see photo below).
There's also an online demo that allows you to experiment transferring data over the internet with an actual FPGA running the IP core using the MATLAB code below. To try it, navigate to http://webphyfpga.ddns.net in your browser and log onto the FPGA. In the MATLAB code, set 'fpga_ip' = the resolved IP address (e.g. http://173.76.169.42:8080/) from your browser's URL box. Use the embedded webcam to view the board live as you move the servo motor and illuminate LEDs.
% IP address of FPGA
fpga_ip = "http://173.76.169.42:8080/";
% Write 8 bytes to BRAM address 0x1002 and read them back.
s = urlread (strcat(fpga_ip,'wr_0x1002_0x0123456789ABCDEF'),'post',{'',''});
s = urlread (strcat(fpga_ip,'rd_0x1002_0x8'),'post',{'',''});
fprintf('read 0x%s from FPGA\n',s);
% Move servo motor and write to 7 segment display.
s = urlread (strcat(fpga_ip,'wr_0x0_0x1234'),'post',{'',''});

More Answers (2)

Walter Roberson
Walter Roberson on 25 Nov 2011
"object" in this context means a MATLAB Object Oriented Programming (OOP) variable of a specific data Class. "object" does not refer to physical objects in this context.
For now, you should just interpret "object" in this context as being a complicated kind of variable that MATLAB knows is associated with a particular TCP/IP connection.
  4 Comments
amey patil
amey patil on 12 Dec 2011
But if matlab guys are giving us tools for doing physical communication then it is pausible with matlab to make it really happen.I m trying with latest version of MATLAB that is R2011B .Hope that it will allow me to make actual connection with Hardware of my expectation.
Walter Roberson
Walter Roberson on 12 Dec 2011
No. The physical connections would already have to be made before MATLAB could be used to transfer data over the connections.
You need
http://www.mathworks.com/help/toolbox/instrument/tcpip.html
Connection = tcpip('192.168.0.2', 80);
fopen(Connection)
After that you would use fwrite(Connection, ...) and fread(Connection, ...)
There is another possibility in your situation: depending on exactly what the server interface is defined as on the FPGA, it could be that you would not use tcpip() and fopen() directly at all, and that you would instead use urlread() or urlwrite() to send commands to the FPGA and get back the response.

Sign in to comment.


Daniel Shub
Daniel Shub on 26 Nov 2011
Prior to r2011a (???) MATLAB could only act as a TCPIP client. Now MATLAB can act as both a client and a server. I believe this requires the instrument control toolbox. Are you trying to connect to or from MATLAB? The documentation is pretty good. You should start with:
doc tcpip
  1 Comment
Walter Roberson
Walter Roberson on 26 Nov 2011
The MATLAB File Exchange contribution "tcpudpip" is able to act as both a client and a server with earlier versions of MATLAB.
Port 80 is HTTP, so likely the FPGA would act as the server, likely making the point moot.

Sign in to comment.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!