RS232 issue under Simulink realtime
1 view (last 30 days)
Show older comments
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
0 Comments
Answers (1)
Abhi Sundararaman
on 1 Aug 2017
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.
See Also
Categories
Find more on Development Computer Setup in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!