Arduino serial transmit block limited step time

3 vues (au cours des 30 derniers jours)
Roland
Roland le 3 Août 2014
Commenté : Ajay Joseph le 2 Fév 2018
Hallo everybody!
I´m sending data from my Arduino Mega 2560 to my computer using matlab 2013a and the simulink support package. As a guide I used this: http://www.mathworks.de/de/help/simulink/ug/configure-serial-communications.html#bthsi0o
The setup is very simple with a poti at an analog input as source. The analog input block detects the values and a header and a terminator are added. Then the serial transmit block is used to send the data. This model is built and laoded on to the arduino:
To read the data I´m using another simulink model which is running on my computer. It inlcudes a serial recieve and a serial configuration block.
As long as i set the step-size of both models to a value higher than 20 milliseconds everything is working fine and I recieve data in "real time" so there shouldn´t be a problem with the port or something like that.
But if I reduce the step-size to 10 milliseconds it seems like something is too slow. I still recieve data but it is dalyed and the delay gets bigger until the model hangs.
I tried to run the model for 20 seconds with different step-size and baud rate:
So there is no dependence on the baud rate but if the step-size is decreased there is not enough data transmitted.
Does anyone know about a limitation for the step-size when using the serial transmit block or what else could be the problem? If you need more information about something please ask. Thanks!
  1 commentaire
Roland
Roland le 4 Août 2014
Modifié(e) : Roland le 4 Août 2014
Ok I tried now to recieve the data with a serial monitor (HTerm) an in this case everything seems fine. All the values for the ADC are recieved.
I think that there is a problem with the model I´m running on my computer. Here are the settings of the 2 relevant blocks if the model is running with 10ms step-size:

Connectez-vous pour commenter.

Réponses (2)

Ajay Joseph
Ajay Joseph le 30 Jan 2018
Where do you find those green blocks? Is it only for Arduino Mega 2560 package? I have been searching for the Header and Terminator for a long time. Also, the one in the middle is missing from my library. What am I missing? Any help will be much appreciated.
  2 commentaires
Madhu Govindarajan
Madhu Govindarajan le 30 Jan 2018
The header and terminator in this case are mere constant blocks in which the person has uint8("A") and uint8(0) respectively. Once you have added the header and the terminator to your data, then you can input that in the serial receive block as shown in the figure.
Ajay Joseph
Ajay Joseph le 2 Fév 2018
Thank you very much

Connectez-vous pour commenter.


Sudeshna Bhattacharya
Sudeshna Bhattacharya le 2 Fév 2018
The issue happened in MATLAB R2013a. The Arduino Serial blocks have been enhanced to support array, multiple datatypes, etc. in R2016b and R2017a. Try checking in the latest release. If the issue still persists in newer release then provide the model.
  2 commentaires
Sudeshna Bhattacharya
Sudeshna Bhattacharya le 2 Fév 2018
You can check the example https://www.mathworks.com/matlabcentral/fileexchange/61420-dc-dc-buck-converter-example. In this example, the target model running in C2000 inserts header and terminator for every 12000th sample and reads an array in the host model instead of single byte. You can utilize similar technique. There is a video also in the example which talks about the buffering mechanism from time around 10:00 - 14:00.
Ajay Joseph
Ajay Joseph le 2 Fév 2018
Thanks

Connectez-vous pour commenter.

Catégories

En savoir plus sur Arduino Hardware 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!

Translated by