Speedgoat to Speedgoat TCP Communication

I have been sending a command matrix from a MATLAB GUI to a simulink model running in standalone mode on a Speedgoat. I did this using the simulink blocks attatched:
Then in my GUI I create a TCP client with tcp = tcpclient('192.168.7.5',5027);. I can then write my data with write(tcp,data);.
For the next project however I need to communicate Speedgoat to Speedgoat via TCP. I used the simulink blocks TCP Server in one model and TCP Client in the other. This built fine but when I went to the MATLAB command window to create the TCP Server object with, t = tcpserver(IP address, port), so I can write and read data from them it says I need "Instrument Control Toolbox". It seems odd that I can create a client object fine but not a server. The blocks compiled so I'm assumming my Server and Client exist I just need to enable them. Is there a way I can do this without buying the "Instrument Control Toolbox" or must I buy it for Simulink to Simulink communication via TCP.

 Accepted Answer

The tcpserver function is only available in Instrument Control Toolbox. However, you could use the tcpclient function which is included in MATLAB:
Here is an example showing TCP host-target communication:

7 Comments

That worked fine for communicating between the Control PC and the Speedgoat, however the Speedgoat will need to read and write data to other devices on the network via TCP. So it sounds like we will have to purchase the Instrument Control Toolbox, correct?
You can add additional TCP blocks from the Simulink Real-Time library in the model to communicate with other devices.
If you don't need the host computer to participate in the TCP network, you might use the MATLAB API for Simulink Real-Time to communicate (exchange data) with the target computer(s), and have a separate TCP connection between the target computers and other devices.
The host computer will eventually run a Labview GUI which is why TCP communication was selected, so I don't think the MATLAB API is an option (unless that assumption is incorrect?). That TCP host-target communication example is how I set up the MATLAB GUI-Speedgoat communication for a proof of concept. It was limited though, all it did was write data to the speedgoat. The final product will need to write data (Command Matrix, Parameter Tuning) to the Control Speedgoat and also read data and connection status back from the Control Speedgoat. The Control Speedgoat will then have ethernet connections to other hardware with similar needs. They will all need to recieve data and parameter tuning from the Control Speedgoat, and then respond back with Data and Connection Status. I have attatched a diagram "TCP Network Diagram1" to visually show what I'm trying to accomplish. The other images are the simulink TCP Server and Client blocks I have on the speedgoats. The "TCPServerSS" is running on the Control Speedgoat and the "TCPClientSS" is running on the Client Speedgoat and they are both connected by ethernet. These models compile but like I said I can't run the code t = tcpserver(IP address, port) because I dont have Instrument Control Toolbox. It just seems odd that I have access to the TCPServer simulink block but no way to utilize it, to implement the network in "TCP Network Diagram1" must I have Instrument Control Toolbox? Why? I would also like a way to display communication updates in the GUI like "Data recieved", is there a way to programtically monitor the sockets to see if and when the data has been recieved?
In your diagram, the Speedgoat Control is the server. The host computer is the client, so you can use tcpclient function (which does not require Instrument Control Toolbox).
I'm not sure to understand why you want to run tcpserver to establish communication between two Speedgoat systems? TCP Server and Client blocks on Speedgoat do not require to run tcpclient or tcpserver functions. Those functions are only required if you want to communicate with the host computer. The TCP Server and Client blocks are sufficient to configure TCP communication.
I did not fully understand how the blocks work when I posted this, thank you. Is there a way to monitor the TCP communication so I can update the user when data is recieved?
On the Speedgoat side, we don't have a mechanism to detect new data, but you can add some logic to the data and length port.
On the host side (MATLAB), there are some callbacks that may help:
If in the host you have MATLAB+SLRT installed, I would look into the instrument object:
Ok. Thank you for your help.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!