delays when sending binary data to micro-controller from simulink

1 次查看(过去 30 天)
Hello everyone,
i have a problem with sending binary data in Simulink. There is a micro-controller connected via USB at COM-Port. For testing i send a multiplexed sine signal with 'serial send' -block from Simulink to this controller(Px4 flight controller). When i look at the logged data from the micro-controller i can see the sine but with delays in it:
This is not acceptable as i need the data to get to the controller in real time.
In the lower graph(of the above log) you can see the time difference between two consecutive samples, where are significant peaks, when the delays occur.
and that is what the sine signal looks like before it enters the 'serial send' in simulink(hence what it ideally should look like when entering the micro-controller):
i also tried the 'To Instrument'-Block with same behaviour as result. Furthermore i tried to send it using the standard serialobject within a MATLAB Function Block with the same result.
Sending the same sine signal via 'serialobject' from a matlab-script works fine; no delays.
Has anyone a suggestion how i could solve this problem?
Thanks for your help
Simon
  1 个评论
Simon Heer
Simon Heer 2020-12-22
I now reduced my model to just a simple matlab function-block which measures the time of every simulation step(using tic toc). As a result there are also delays with the same frequenzy as described above, even there is just this simple matlab function-block. So is this behaviour normal because it does not matter when simulating not in real time ? Is there a known workaround?
Output of the matlab function-block measuring step times:

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Sources 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by