match hardware update frequency in simulation

1 次查看(过去 30 天)
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.

回答(1 个)

Chetan
Chetan 2023-9-27
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.

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by