Skip to content
MathWorks - Mobile View
  • Sign In to Your MathWorks AccountSe connecter
  • Access your MathWorks Account
    • Mon compte
    • Mon profil
    • Mes licences
    • Se déconnecter
  • Produits
  • Solutions
  • Le monde académique
  • Support
  • Communauté
  • Événements
  • Obtenir MATLAB
MathWorks
  • Produits
  • Solutions
  • Le monde académique
  • Support
  • Communauté
  • Événements
  • Obtenir MATLAB
  • Sign In to Your MathWorks AccountSe connecter
  • Access your MathWorks Account
    • Mon compte
    • Mon profil
    • Mes licences
    • Se déconnecter

Vidéos et webinars

  • MathWorks
  • Vidéos
  • Vidéos
  • Recherche
  • Vidéos
  • Recherche
  • Contacter l'équipe commerciale
  • Version d'essai
2:25 Video length is 2:25.
  • Description
  • Full Transcript
  • Related Resources

What Are Messages in Simulink?

From the series: Run-Time Software Modeling

Use messages to model and generate C++ code for software compositions with message-based communication. You can send and receive messages from the model’s root input and output ports. You can also generate C/C++ code to connect to middleware or an operating system communication API. See how to build a simple model for generating and receiving messages using blocks in the Messages & Events library and debug it using event logging, message animation, and Sequence Viewer.

Messages allow you to model and generate C++ code for software compositions with message based communication. To do this you can send and receive messages from a model's root input and output ports. You can also generate C++ code to connect to a middleware or an operating system communication API. Let's build a simple message communication model.

I will use the message blocks in the messages and events library in Simulink. I have a sine wave source block sending a sine wave in a sample based manner and an output port. I will use the message send block to convert the sine wave into a message that sends on the sample time of the source block. A message received block will convert that message back into a signal at the rate it's received.

We can use a queue block to hold messages if they're sent faster than they can be processed. The queue is set to behave like a buffer, dropping the oldest element when it's full. That can be changed. You can also set the capacity of the queue, which is how many messages it will hold, and set the type of cue that it is such as last in first out or first in first out. I can debug my model using event animation. I can choose the animation speed that shows while running the model. This shows me that my messages are being sent and when they are arriving.

I can also log the events. Choose a message line to log and use the data inspector to see when messages are sent and what their value is. Clicking on a line when the simulation is running will also show the value. The sequence viewer can also be used to show what order messages are sent in. Clicking on a line in the message viewer shows you where a message originated and what happens with that particular message over time.

There's a message merge block to send messages to the same message line as well in the library. You can connect messages to middleware or operating system communication APIs with code generation. You use ERT and C++ to get appropriate message communication on your model boundaries. This will create a service at the component boundary, a class declaration in the header file, and allow you to add code customization data into the main file to connect.

We have another video in this series to learn more about modeling message based communication between model components.

Related Products

  • Simulink
  • Embedded Coder
  • SimEvents

Learn More

What’s New in Simulink R2021a

3 Ways to Speed Up Model Predictive Controllers

Read white paper

A Practical Guide to Deep Learning: From Data to Deployment

Read ebook

Bridging Wireless Communications Design and Testing with MATLAB

Read white paper

Deep Learning and Traditional Machine Learning: Choosing the Right Approach

Read ebook

Hardware-in-the-Loop Testing for Power Electronics Control Design

Read white paper

Predictive Maintenance with MATLAB

Read ebook

Electric Vehicle Modeling and Simulation - Architecture to Deployment : Webinar Series

Register for Free

How much do you know about power conversion control?

Start quiz
Related Information
Related Information
Learn more about Run-Time Software Modeling (6 videos)

Feedback

Featured Product

Simulink

  • Request Trial
  • Get Pricing

Related Videos:

1:56
Messages in State Machines
5:17
Understanding Bode Plots, Part 2: What Are They?
3:13
Understanding State Machines, Part 1: What Are They?

View more related videos

MathWorks - Domain Selector

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

  • Switzerland (English)
  • Switzerland (Deutsch)
  • Switzerland (Français)
  • 中国 (简体中文)
  • 中国 (English)

You can also select a web site from the following list:

How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

Americas

  • América Latina (Español)
  • Canada (English)
  • United States (English)

Europe

  • Belgium (English)
  • Denmark (English)
  • Deutschland (Deutsch)
  • España (Español)
  • Finland (English)
  • France (Français)
  • Ireland (English)
  • Italia (Italiano)
  • Luxembourg (English)
  • Netherlands (English)
  • Norway (English)
  • Österreich (Deutsch)
  • Portugal (English)
  • Sweden (English)
  • Switzerland
    • Deutsch
    • English
    • Français
  • United Kingdom (English)

Asia Pacific

  • Australia (English)
  • India (English)
  • New Zealand (English)
  • 中国
    • 简体中文Chinese
    • English
  • 日本Japanese (日本語)
  • 한국Korean (한국어)

Contact your local office

  • Contacter l'équipe commerciale
  • Version d'essai

MathWorks

Accelerating the pace of engineering and science

MathWorks est le leader mondial des logiciels de calcul mathématique pour les ingénieurs et les scientifiques.

Découvrir…

Découvrir les produits

  • MATLAB
  • Simulink
  • Version étudiante
  • Support Hardware
  • File Exchange

Essayer ou acheter

  • Téléchargements
  • Version d'essai
  • Contacter un commercial
  • Tarifs et licences
  • Comment acheter

Se former

  • Documentation
  • Tutoriels
  • Exemples
  • Vidéos et webinars
  • Formation

Obtenir de l'aide

  • Aide à l'installation
  • MATLAB Answers
  • Services de consulting
  • Centre de gestion des licences
  • Contacter le support technique

La société

  • Offres d'emploi
  • Actualités
  • Mission sociale
  • Témoignages clients
  • La société
  • Select a Web Site United States
  • Trust Center
  • Marques déposées
  • Charte de confidentialité
  • Lutte anti-piratage
  • État des applications

© 1994-2022 The MathWorks, Inc.

  • Facebook
  • Twitter
  • Instagram
  • YouTube
  • LinkedIn
  • RSS

Rejoignez la conversation