Delay in Packet Output under Real-Time Windows Target

조회 수: 2 (최근 30일)
Jason Chen
Jason Chen 2014년 7월 16일
편집: Vittorio Lippi 2016년 2월 25일
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?
  댓글 수: 1
Vittorio Lippi
Vittorio Lippi 2016년 2월 25일
편집: Vittorio Lippi 2016년 2월 25일
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.

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Target Computer Setup에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by