delays when sending binary data to micro-controller from simulink

1 view (last 30 days)
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 Comment
Simon Heer
Simon Heer on 22 Dec 2020
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:

Sign in to comment.

Answers (0)

Community Treasure Hunt

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

Start Hunting!