How to use Stream Input block for serial communication using Simulink Desktop Real-Time
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
MathWorks Support Team
le 8 Juil 2019
Modifié(e) : MathWorks Support Team
le 9 Juil 2019
I am trying to use Stream Input block to read data from a Serial Port in my Simulink Desktop Real-Time Application. Can you give me some hints on how I have to choose the parameters to make it work?
Réponse acceptée
MathWorks Support Team
le 9 Juil 2019
Modifié(e) : MathWorks Support Team
le 9 Juil 2019
Since serial communications does not come in packets, greater care must be taken to correctly specify the terminating sequence so that the parser is able to determine the end of the sequence and start of another one. Typically for serial communications, sequences end in a Carriage Return (CR, or \r), or a Carriage Return in combination with Line Feed (LF, or \n).
If you are unsure what the sequences look like, you may try out tools like RealTerm:
By selecting "Display as ASCII", you will be able to inspect the sequences. For example, it could look like this:
In this case, the sequence seems to be a 5-digit integer number with a CR ending sequence. One possible way to set the Stream Input block parameters would be:
Block output data types: uint16
Format string: %d
Message Termination: \r
0 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Development Computer Setup dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!