How to use Stream Input block for serial communication using Simulink Desktop Real-Time
조회 수: 8 (최근 30일)
이전 댓글 표시
MathWorks Support Team
2019년 7월 8일
편집: MathWorks Support Team
2019년 7월 9일
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?
채택된 답변
MathWorks Support Team
2019년 7월 9일
편집: MathWorks Support Team
2019년 7월 9일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Development Computer Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!