TCP communication in real time simulink

I am trying to send TCP messages from a simulink model that is running realtime on a target computer. Matlab says that TCP is supported in realtime simulink but I only see a TCP block in Instrument control box. Also when I try to use those blocks and build the model on the target computer, it gives the following error:
Error evaluating registered method 'Start' of MATLAB S-Function 'stcpipsb' in 'testing_TCP/TCP//IP Send'.
Caused by:
The block TCP/IP Send could not connect to the specified port. Please specify a different port or wait for the current port to become available.
I have configured the IP address of the TCP block to be that of the target computer and used different port numbers like 22222 (which is what I have configured in the simulink realtime explorer), 30000, 30, 10 all to no avail. Where is it going wrong and what is causing the error?

 Respuesta aceptada

Prashant Arora
Prashant Arora el 18 de Oct. de 2017
Editada: Stefanie Schwarz el 21 de Jul. de 2023

1 voto

HI Rajashree,
There is a TCP Send block in the Simulink Real-Time library, which you should use for sending data from a Target computer to another remote device.
You can check out the following example, which shows communication between two targets using TCP/IP.
Check the TCP configuration blocks in the example to understand the IP address and port specification for communication.

5 comentarios

Rajashree Ravi
Rajashree Ravi el 19 de Oct. de 2017
Editada: Rajashree Ravi el 19 de Oct. de 2017
I am not able to find TCP send block in the Simulink Real-Time library. I am only able to see the option TCP under Instrument toolbox library and the Simulink Realtime library options don't seem to have it as shown in the image. Is there an update for this library in 2016b version? Please explain how I can get this block. Thanks
Prashant Arora
Prashant Arora el 19 de Oct. de 2017
Hi Rajashree,
I think support for TCP in Simulink Real-Time from Target to other devices was added in R2017a. This is why you are unable to see the library block. In R2016b, you can consider UDP transmission using UDP Send and Receive blocks.
Paul Stansell
Paul Stansell el 2 de Nov. de 2020
The links in this answer are dead

Iniciar sesión para comentar.

Más respuestas (1)

THOMAS JOHN
THOMAS JOHN el 24 de Sept. de 2019

0 votos

Hello Prashant
I am a researcher currently doing a project related to signal transmission & reception using TCP & UDP. At the moment, I am able to achieve signal transmission and reception using TCP in normal non-real time MATLAB/Simulink but I am unable to achieve signal reception when I do real-time operation using TCP in MATLAB/Simulink.
Do I need to use real-time TCP/UDP models or is there any other option? The problem is that my remote receiver do not have a real-time simulink library & real-time TCP/UDP blocks. Please kindly suggest an alternative solution if possible. Many Thanks.
Best Regards
Dr Thomas John

1 comentario

Andrea Assorati
Andrea Assorati el 2 de Nov. de 2019
For real-time applications, in MATLAB command line i used 'flushinput' command to clean the input buffer and just delete the data in eccess. I am unable to make this operation in Simulink too.

Iniciar sesión para comentar.

Categorías

Preguntada:

el 12 de Oct. de 2017

Comentada:

el 21 de Jul. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by