simulink unable to pace at specified rate
23 views (last 30 days)
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?
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. https://www.mathworks.com/help/simulink/slref/introduction-to-profiling-models.html Also, is your arduino running real-time at 0.001? Could your bottleneck be the arduino and not Simuilnk?