Delay in Packet Output under Real-Time Windows Target
4 views (last 30 days)
Show older comments
I tried to verify the real time capability of the Real Time Windows Target. I built a Simulink model that send out a data from a laptop to an Arduino through the USB port. The Arduino immediate sent back the data. The model was run at a real time windows target. It read a one-byte signal through Packet input and sends a one-byte signal through Packet Output to an USB com port. The Packet Input is executed ahead of Packet Output. The execution order is enforced by setting the priority property.
I recorded the outputs of Packet Input and the input of Packet Output blocks. I expect to see one-step delay between them.
The test shows that the serial communication was not executed in real time in the Windows Target. Data seems to be stuck in the buffer of the UART chip some time. Once in a while, Rx Data Ready became false when the sampling period is 0.01 s. The signal is delayed one more step every time this happens. This is not acceptable for real time control.
The problem will not occur when the sampling time is larger, e.g., 0.02 s and happen more often with small sampling period.
Is this normal and unavoidable? Is there a way to clear the transmit buffer at the laptop to eliminate the accumulative delays?
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/165738/image.jpeg)
1 Comment
Vittorio Lippi
on 25 Feb 2016
Edited: Vittorio Lippi
on 25 Feb 2016
I had the same problem, actually the reason was trivial. The baudrate set for the serial communication was 9600, too slow for the amount of data that i was producing. maybe your packet was slightly above 96 bits (it is not a lot... 3 int32 are already enough..)hence with 100Hz you were exceeding the baudrate, while with 50 Hz you were not.
Answers (0)
See Also
Categories
Find more on Target Computer Setup in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!