Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

UDP block via Simulink

847 views
Skip to first unread message

Nurul Mohd

unread,
Oct 11, 2012, 12:38:08 PM10/11/12
to
Hi everyone,

I would like to ask help from anyone who can help me out of this problem. I want to measure the delay in feedback loop between two IP address before I connect them to the hardware.

What I've done is I create two Simulink file;

1st file,
Host: Sine wave is applied as input and connect to UDP Sender (send to 193.63.131.170, port number: 4001) and UDP Receiver (receive from 193.63.131.210, port number:4002)
2nd file,
Client: UDP Receiver (receive from 193.63.131.170, port number: 4001) and UDP Sender (send to 193.63.131.210, port number: 4002)

So then, I can compare either output UDP receiver from this IP 193.63.131.210 is delayed from 193.63.131.170 or not.

In configuration parameter in Real-time window target part for both file, there is Destination IP address. I do not know which address should I put either 193.63.131.170 or 193.63.131.210 for both files. So, I just try and error.

But I'm not sure whether I did a right way of doing that because my output receiver for both are now zero. Seems like the sine wave input is not transmitted to those IP address.

Can anyone help me with this matter. I really don't know how to use this block.

Many thanks in advanced.
Nurul

Gijs van Oort

unread,
Oct 15, 2012, 11:17:08 AM10/15/12
to
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!

Nurul Mohd

unread,
Nov 3, 2012, 1:19:14 PM11/3/12
to
Hi Gjis van Oort,

Thanks a lot for your useful advice. It was very clear and easy for me to understand and followed.

However, I still have a little problem with this setting.

For your information, I've successfully connect this two IP through Simulink via UDP block between two real-time target system (one is HOST and another one is CLIENT)

I did it like this,
ON HOST windows (193.63.131.210):
> UDP Send to 193.63.131.220, port 4004,
> UDP Receive from 193.63.131.220, port 4003.
>
> ON CLIENT windows (193.63.131.220):
> UDP Receive from 193.63.131.210, port 4004,
> UDP Send to 193.63.131.210, port 4003.

everything is working fine.
So, then I add one more CLIENT called as CLIENT2 with IP 193.63.131.170 and send the same data to this client as per CLIENT.

ON CLIENT2 windows (193.63.131.170)
UDP Receive from 193.63.131.210, port 4002
UDP Send to 193.63.131.210, port 4001

So, I've to modify on the HOST windows to be
ON HOST windows (193.63.131.210):
> UDP Send to 193.63.131.220, port 4004,
> UDP Receive from 193.63.131.220, port 4003.
> UDP Send to 193.63.131.170, port 4002,
> UDP Receive from 193.63.131.170, port 4001.

So, now I've 3 windows to be executed.

And then, I give a sine input from HOST windows to see whether the IPs receive or not the signal given.

The result is..only CLIENT receive the signal from the HOST and send it back to the HOST

Receiver from HOST in CLIENT2 is ZERO. It didn't receive any signal from HOST but, the weird thing is Receiver in HOST window receive a signal (but not from CLIENT2)

So basically my question is: How to send data from HOST to more than one CLIENT.

My research is to connect THREE real-time target system (with 3 different IPs) and execute it via real-time platform in MATLAB.

Really need your help and I really get stuck in here.

Gijs van Oort

unread,
Nov 5, 2012, 4:40:08 AM11/5/12
to
Your strategy sounds right; I guess there is something wrong with the packets that you send (if you send a packet with a different size than you expect to receive, you will receive nothing).

I suggest you to use a network sniffer (an application which shows you all packets that are sent/received through the network card) to find out what is going wrong. It allows you to see if packets are sent or not (so that you know where the error lies). I suggest to use Wireshark. There is also a portable version of Wireshark.

Good luck!

Gijs

Nurul Mohd

unread,
Nov 5, 2012, 5:23:08 AM11/5/12
to
Ouh really?Also I think it may be Matlab/Simulink didn't support multicast function.

I'll try to find and download Wireshark software after this.

Thanks a lot for your help and info. Really appreciate it!

Nurul..=P
0 new messages