Communicate with Data Distribution Service (DDS) Middleware
This example shows how to operate communications using Data Distribution Service (DDS) middleware on the target computer. The Simulink® Real-Time™ DDS Send block and DDS Receive block pass messages using the dds middleware on the real-time application.
To establish communication by using data distribution service:
Open a Simulink model.
In the Simulink editor, on the Apps tab, select Apps > Simulink Real-Time.
Add SLRT DDS blocks to the model.
Configure the SLRT DDS blocks by either adding a new data dictionary or associating an existing dictionary. For more information about the data dictionary, see DDS Dictionary (DDS Blockset).
Build the model and generate the real-time application.
Connect to the DDS application and run the real-time application on the target computer.
Note: If the RegisteredType
name des not match the TopicType
name, the real-time application cannot communicate with the DDS application.
Using this example build the slrt_ex_pendulum_100Hz_dds
model, and deploy the application on a target computer. Start running the application, and observe the data from DDS Send block is received by the DDS Receive block by using the Simulink Data Inspector.
Create Target Object and Connect
Create a Target object for the default target computer and connect to the target computer. In the Command Window, type:
tg = slrealtime; connect(tg);
Open Example Model
Open the model. In the Command Window, type
model = 'slrt_ex_pendulum_100Hz_dds';
open_system(model);
Configure Model for Target Computer
modelSTF = getSTFName(tg);
set_param(model,"SystemTargetFile",modelSTF);
Configure Physical Layer for DDS Communication
The DDS Send and DDS Receive blocks can communicate through an ethernet interface between the target and development computer, target and target computer, target computer and other machine that are connected to the same network. You can also specify network restrictions through Quality of Services settings by using the DDS Dictionary app. To configure an ethernet connection, use the Speedgoat Ethernet Configuration Tool. For more information about this utility, see the Speedgoat documentation.
Build Model and Download to Target Computer
To build the model and download the real-time application, type:
evalc('slbuild(model)');
load(tg,model);
start(tg);
View Signals From DDS Send and DDS Receive Blocks
To view the signals, open the Simulation Data Inspector. In the Command Window, type:
Simulink.sdi.view();
Close the App and Models
Close the Simulation Data Inspector. In the Command Window, type:
Simulink.sdi.close;
Close the Open Model
In the Command Window, type:
bdclose (model);
See Also
DDS Dictionary (DDS Blockset)
Related Topics
- Import or Create DDS Definitions (DDS Blockset)
- Edit Domains, Topics, and Registered Types (DDS Blockset)