simulink unable to pace at specified rate

31 visualizzazioni (ultimi 30 giorni)
Fatih Kaya
Fatih Kaya il 23 Mar 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?

Risposte (1)

Mark McBroom
Mark McBroom il 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?
THanks.
Mark.
  2 Commenti
Fatih Kaya
Fatih Kaya il 28 Mar 2023
Thanks for your answer. I used both an Uno and an Nano 33IoT which are capable of 16 and 64 MHz so i think the devices are fast enough. I suppose its the communication between the arduino and simulink. Even a simple output of e.g. the A0 pin slows down to 0.8 seconds a sample.
Nakul Khadilkar
Nakul Khadilkar il 6 Apr 2023
Modificato: Nakul Khadilkar il 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.
https://www.mathworks.com/help/supportpkg/arduino/ug/connected-io.html#mw_433e82f7-9aff-4659-8409-1b4cff38c0ff

Accedi per commentare.

Categorie

Scopri di più su MATLAB Support Package for Arduino Hardware in Help Center e File Exchange

Prodotti


Release

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by