Arduino serial transmit block limited step time
이전 댓글 표시
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!
답변 (2개)
Ajay Joseph
2018년 1월 30일
0 개 추천
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
Madhu Govindarajan
2018년 1월 30일
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
2018년 2월 2일
Thank you very much
Sudeshna Bhattacharya
2018년 2월 2일
0 개 추천
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
Sudeshna Bhattacharya
2018년 2월 2일
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
2018년 2월 2일
Thanks
카테고리
도움말 센터 및 File Exchange에서 Arduino Hardware에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


