Quantcast
Channel: MATLAB Central Newsreader Recent Posts
Viewing all articles
Browse latest Browse all 19628

Re: UDP block via Simulink

$
0
0
So, you have two separate computers, both running Simulink? And you connect them to each other via an ethernet cable?

Each computer (or actually, each network card in each computer) has its own IP. When you are connecting two network cards (of different computers) to each other, you can decide yourself which IP you want each network card to have. For example, you could decide to use 193.63.131.170 for your 'host', and 193.63.131.210 for your 'client' (it is more natural to either talk about host/target, or about server/client, btw). Take two pieces of paper, write down the IP addresses and tape them onto the computers.

Now set the IP's of the computers (or actually, the network cards in the computers) to your chosen value. Set the subnet mask for both to 255.255.255.0. Setting IP/Subnet mask is something you do in Windows (not in Matlab/Simulink). If you don't succeed, find someone in your neighbourhood to show how to do it.

Hopefully it now becomes clear that you messed up the IP addresses a little: The 'host' should send to your client (therefore, it shoud send to 193.63.131.210), and it should also receive from your client (therefore, it should also receive from 193.63.131.210). Your client should receive and send from/to 193.63.131.170.

You did the ports right. The 'host' sends its data to a certain port (in your case 4001), and the client should read that specific port (4001). Similar for the return line. So:

ON HOST COMPUTER (193.63.131.170):
UDP Send to 193.63.131.210, port 4001,
UDP Receive from 193.63.131.210, port 4002.

ON TARGET COMPUTER (193.63.131.210):
UDP Receive from 193.63.131.170, port 4001,
UDP Send to 193.63.131.170, port 4002.

If you don't want to connect the Simulink computers, but want to connect two real-time target systems (i.e., you design something in Simulink, compile it for a real-time platform and make Matlab download the code to that platform), you still need the IP addresses structure above (each real-time computer has one IP and the send/receive blocks contain the 'other' IP). You then need the IP addresses that you also use for downloading the models to the real-time computers.

Good luck!

Viewing all articles
Browse latest Browse all 19628

Trending Articles