simulink unable to pace at specified rate

23 views (last 30 days)
Fatih Kaya
Fatih Kaya on 23 Mar 2023
Edited: Nakul Khadilkar on 6 Apr 2023
I am attempting to operate a control circuit that inflates and deflates a balloon at a specific frequency of 7Hz. I am utilizing an I2C pressure sensor that is connected to an Arduino. The simulation is being conducted on Matlab 2022b in connected I/O mode, with a baud rate of 921600 set as the default.
However, my simulation is not running in real-time. It is running much slower, with one sample time taking up to 15 seconds. I have enabled pace mode and set it to 1 second, but the simulation is still running very slowly. At the bottom of the window, the message "pacing activ: unable to pace at specific rate" appears.
I am reading two registers of my I2C sensor. To obtain a high enough resolution, ideally, I require a sample time of 0.001. However, the lower the sample rate goes, the slower the simulation becomes. Even at a sample rate of 0.1, the simulation is off by approximately 0.2 seconds compared to real-time.
Is there a way to increase the sample time for my I2C sensor while still forcing the model to run in real-time?

Answers (1)

Mark McBroom
Mark McBroom on 25 Mar 2023
Accelerator and rapid accelerator modes can be used to increase the simulation speed, but these options are not likely to get you a 15x speed up. You can use the profiler to locate the spots in the model consuming the most time. Also, is your arduino running real-time at 0.001? Could your bottleneck be the arduino and not Simuilnk?
Nakul Khadilkar
Nakul Khadilkar on 6 Apr 2023
Edited: Nakul Khadilkar on 6 Apr 2023
Hi Fatih,
Is there a particular reason you are using connected IO for such fast sample times?
The different modes of operation in Simulink serve different intentions. For example, connected IO is for rapid prototyping purposes wherein the user checks if the model is working as expected and iterates over and over to get it right. It is not necessarily real-time. On the other hand, Monitor and Tune (external mode) is real time. It is the suggested mode to be used once the algorithm/model is finalized and the acquired data has to be processed/retrieved for further analysis or other applications. Please refer to the link below for explanation of the modes.

Sign in to comment.




Community Treasure Hunt

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

Start Hunting!