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 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Maximilian Becker
el 19 de Ag. de 2021
Comentada: Maximilian Becker
el 23 de Ag. de 2021
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
2 comentarios
Respuesta aceptada
Jan Houska
el 20 de Ag. de 2021
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
Más respuestas (1)
Ver también
Categorías
Más información sobre Target Computer Setup en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!