RS232 issue under Simulink realtime

1 次查看(过去 30 天)
Hello,
I had some confusion about using the Base Board Serial blocks under Simulink real-time.
I have a sensor that sends a packet stream of a fixed length (12 bytes) at a rate of 20 Hz. I need a function to be executed once these 12 bytes are received. The function sampling time is set to -1. The baud rate used is 115200, which means that the 12 bytes take about 1.2 ms. I also have another control loop that works fine at 40 Hz, with analogue in and out.
I configure the serial board for a receiver HW FIFO size of 16 bytes, with almost full interrupt level. The software buffer is set to Receive minimum read: of 12 and Receive maximum read: of 100. I made that to generate an interrupt when a gap of at least 4 characters occur.
My problem is that this function is executed at a rate of 40 Hz instead of 20 Hz (as i expect), and synchronized to the Simulink time.
thanks in advance

回答(1 个)

Abhi Sundararaman
Since the function has an inherited sampling time (-1), the rate at which it is executed is dependent on the block that feeds into it. In the end, setting the sample time of the model to 0.05 seconds (20 Hz) should force the function to execute at that sampling rate, or an integer multiple of the sample time (a divisor of 20Hz). Since the data only comes in at 20Hz, I believe that setting the sample time of the whole model to this value would force your function to execute at that same rate.
  1 个评论
Mohamed Abdelaal
Mohamed Abdelaal 2017-8-2
Thank you very your answer. But what if i set all the block to a sampling interval of -1, should that execute all the block asynchronously?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Development Computer Setup 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by