![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175241/image.png)
FPGA and ethernet communication
조회 수: 10 (최근 30일)
이전 댓글 표시
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???
댓글 수: 0
채택된 답변
Amy
2014년 7월 12일
편집: Star Strider
2014년 7월 27일
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',{'',''});
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175241/image.png)
댓글 수: 0
추가 답변 (2개)
Walter Roberson
2011년 11월 25일
"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
Walter Roberson
2011년 12월 12일
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.
Daniel Shub
2011년 11월 26일
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
Walter Roberson
2011년 11월 26일
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.
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!