match hardware update frequency in simulation

4 visualizzazioni (ultimi 30 giorni)
Nathaniel Goldfarb
Nathaniel Goldfarb il 22 Feb 2022
Risposto: Chetan il 27 Set 2023
Hello,
I am trying to tune my Simulink controller for a system I built. My communication speed is about 350Hz using Serial communication to my off board controller. What I want to do is design a simulation that replicated my hardware, I have design all the dynmic models but I am having trouble replicating my communication speed. How can I make sure that my controller updates at 350Hz? I cannot find a good Simulink block that does this. I can add delays but that seems incorrect.

Risposte (1)

Chetan
Chetan il 27 Set 2023
I understand that you are trying to tune a controller and trying to replicate the communication speed.
To ensure that your Simulink controller updates at a specific frequency, such as 350Hz, you can follow these steps:
  1. Configure the solver settings in Simulink to use a fixed-step solver with a step size of 1/350 seconds (approximately 2.86 ms). This ensures that the simulation runs at a consistent rate.
  2. Use the Rate Transition block in Simulink to control the rate at which signals are passed between different parts of your model. Set the sample time of the Rate Transition block to match the desired update frequency of 350Hz: https://www.mathworks.com/help/simulink/slref/ratetransition.html
By combining these techniques, you can control the timing and synchronization of your Simulink controller to match the desired update frequency of 350Hz.
I hope these suggestions help you resolve the issue you are facing.

Prodotti


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by