Partially missing values while reading serial input from a microcontroller (Simulink Instrument Control Toolbox)

8 vues (au cours des 30 derniers jours)
I am trying to read serial data from an Atmel SAM E70 Xplained -board using Instrument Control Toolbox and display the data in Simulink. However there are values missing when printed in Simulink scope.
Below is the code snippet from the microcontroller (programmed using Atmel studio).
code.PNG
The numerical values of these ASCII letters are 49 57 13 10, which are expected to be received from the Serial Receive -block.
Below is the Simulink model configured to display all of the received characters:
simulink_model.PNG
Output of the model:
simulink_receives.png
As you can see, some of the values are overlapping / appear to be missing. How can I fix this?
There is no problem while using Ardino terminal (below) or PuTTy, so I doubt there is anything wrong with the sender.
arduino_works.png
I have tried changing the block sample time and data size of the input with no success.
  1 commentaire
Santeri
Santeri le 27 Juin 2019
I am not marking this as solved yet, as there are still unclear aspects (see my comment on Jonas' answer).

Connectez-vous pour commenter.

Réponses (1)

Jonas
Jonas le 18 Juin 2019
Your Simulink model is reading at 10kHz, while your Atmel controller is only sending each one second. This means that you are reading multiple times when the data has not changed (overlap).
  1 commentaire
Santeri
Santeri le 18 Juin 2019
Thank you for the response. I increased the sampling time and the values look better, although I still don't understand how the values can be read several times in serial communication. From the Serial Receive documentation: "In a nonblocking mode, the Status port indicates if the block has received new data." It seems that the status port triggers every time a value is read? (Pictured blue in the scope image).

Connectez-vous pour commenter.

Produits


Version

R2018a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by