Effacer les filtres
Effacer les filtres

How do I vary the sample rate of a block while the simulation is running?

2 vues (au cours des 30 derniers jours)
Nancy
Nancy le 28 Août 2014
Commenté : rami ghali le 9 Mar 2018
I'm trying to vary the simulation rate of a Limited Counter in order to make it count faster or slower in real time. (I'm trying to create a plant model of a crank wheel, where the rate of count of crank teeth will be a function of RPM.) I've created a variable in the MATLAB workspace and used it in an expression for the sample time in the counter. However, changes to this variable in the workspace only take effect when I restart the model, they are not read during the simulation. Also, I need to be able to increase and decrease the rate that the counter runs--i.e., accelerate and decelerate the speed the crank teeth go by--during the simulation, to check my model under development.
Is there anyway to write values to a variable used in the sample time setting of a block directly in Simulink while the simulation is running? e.g., use a slider gain and have the gain feed into the variable in the expression used to set the sample rate of the Limited Counter block? Or some other way to vary the sample rate during the simulation?
Thanks for any ideas anyone may have.

Réponse acceptée

A Jenkins
A Jenkins le 28 Août 2014
Modifié(e) : A Jenkins le 28 Août 2014
I would start with a Programmable Pulse Generator from the File Exchange.
This will give you a programmable input for the frequency, which you can adjust with either a slider or with the set_param() command.
Then, if you need a counter instead of tooth-pulses, you can integrate the output of the Pulse Generator, perhaps with a detect-change block if you just want the edges.
  2 commentaires
Nancy
Nancy le 28 Août 2014
Thank you! I do see how I can make that work. Thanks for your help.
rami ghali
rami ghali le 9 Mar 2018
my system is running in variable mode not fixed would that still work?

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur General Applications dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by