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.
Open Example Model
Open the model. In the Command Window, type
open_system('slrt_ex_pendulum_100Hz_dds');
Build Model and Download to Target Computer
To build the model and download the real-time application, type:
tg=slrealtime('TargetPC1'); evalc('slbuild(''slrt_ex_pendulum_100Hz_dds'')'); load(tg,'slrt_ex_pendulum_100Hz_dds'); 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 models. In the Command Window, type:
bdclose ('all');
See Also
DDS Dictionary (DDS Blockset)
Related Topics
- Import or Create DDS Definitions (DDS Blockset)
- Edit Domains, Topics, and Registered Types (DDS Blockset)