Hey @Jan Houska, please excuse me pinging you, but I just remembered that you might have an idea on how to solve this problem, since you are versatile in terms of SLDRT. :)
Serial input from COM device via "Stream Input"-block in Simulink Desktop Real-Time External (SLDRT)
조회 수: 15 (최근 30일)
이전 댓글 표시
Hi,
in short, I would like to imitate the functionality of the "Serial Receive" block (https://de.mathworks.com/help/instrument/serialreceive.html) with the "Stream Input" block (https://de.mathworks.com/help/sldrt/ref/streaminput.html) and don't know how to do it.
Explanation: As part of my project I am forced to run my code in the Simulink Desktop Real-Time External environment. But since the serial blocks are only available in normal mode but not external mode, I require to have some work around this, where the only alternative seems to be the Stream Input block.
Example:
In normal mode I am using the Serial Configuration and Serial Receive blocks as follows:
So one message contains of a starting byte "A" and an end byte "\n". In between there currently is one single value containing of 4 bytes. With this I can display the following function:
When I now try to imitate that behavior with the stream blocks in external mode I am trying to do this:
with the board settings:
With the same data stream as in the above example, the sinus now looks like this:
Does anyone have an idea of what I am doing wrong? One problem is, that Stream Input does not use a starting byte, but just end bytes (never the less I tried to enter 'A' also into the message terminator array).
Furthermore I would like to receive a message containing 3 values and I do not know how to do that either.
Thank you in advance for every hint.
Best regards,
Max
채택된 답변
Jan Houska
2021년 8월 20일
Hi Max,
the Stream Input block is designed for receiving textual (ASCII) data of potentially variable length. Since your data is binary and of fixed length, Packet Input block is the right block for you. The reason why you are getting garbage instead of the correct numeric value is that the Stream Input block is trying to interpret the four binary bytes as ASCII text, which it isn't. Therefore this cannot work.
Good Luck, Jan
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Target Computer Setup에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!