Delay in Packet Output under Real-Time Windows Target

1 visualización (últimos 30 días)
Jason Chen
Jason Chen el 16 de Jul. de 2014
Editada: Vittorio Lippi el 25 de Feb. de 2016
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 comentario
Vittorio Lippi
Vittorio Lippi el 25 de Feb. de 2016
Editada: Vittorio Lippi el 25 de Feb. de 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.

Iniciar sesión para comentar.

Respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by