Simulink Switch doesn't propagate rate transition

How can I make a Simulink Switch to propagate rate transition?
Right now I have two signal paths, of variable rates, with the rate determined by some condition:
However, the rest of the chain doesn't work, because the switch doesn't maintain the rate (or so SL thinks)
Also, there isn't a way to have a rate block with an input pin that defines the rate, so I can't adjust the rate via a dynamic input instead.
What's the right way to switch rates while the sim is running?

Respuestas (1)

Fangjun Jiang
Fangjun Jiang el 12 de Mayo de 2023
Not sure what you exactly mean, but a Signal Specification block can specify any rate you want.

7 comentarios

John
John el 12 de Mayo de 2023
@Fangjun Jiang, thanks. But can a Signal Specification block take on the properties of the rate transition block dynamically? I thought it had to be set. My goal is (per above) to dynamically change rates during a sim.
I didn't verify but I think the rate of the Outport 2 is determined by the Switch block, or the system that Outport 2 is in.
The Switch blocks does the "if-else" condition at a certain rate. The two sources provide the value, but not the rate. Imagine both sources are at a very high rate, a slow "if-else" calculation will not be able to pass that high rate. This is not a physical switch.
A Variant Source block might help but it can only change the source per simulation, not during the simulation.
You may try Physical Modeling using SimScape.
Paul
Paul el 14 de Mayo de 2023
As best I can tell, the sample time of the output of the Switch block will be Fixed-in-Minor-Step. Whether or not that's what's desired is a different question.
Sample Time, as a block parameter, "To change a sample time after simulation begins, you must stop the simulation, reset the SampleTime parameter, and then restart execution."
Is the goal to switch between two signals with different sample times? Or is the goal to effectively change the sample time of one signal while the simulation is running? If the latter, and if that signal starts as a continuous sample time signal, one could pass it through a triggered subsystem and control the sampling via the triggering logic.
John
John el 15 de Mayo de 2023
Thanks @Paul. " If the latter, and if that signal starts as a continuous sample time signal, one could pass it through a triggered subsystem and control the sampling via the triggering logic"
Yes, the goal to effectively change the sample time of one propagated signal (the one coming out of the switch) while the simulation is running, so that the rest of the sim that connects to the propagated signal has a different rate.
"control the sampling via the triggering logic"
Interesting idea. Regarding the triggered subsystem, how would I do this? Wouldn't that be the same issue, ie I'd need a variable-rate trigger? The only way I know how to switch between two rates is a switch, but that doesn't end up with a dicrete rate that propagates to its output.
Or, would the triggered subsystem still work?
If it does, would the behavior be the same as a discrete system?
Paul
Paul el 15 de Mayo de 2023
To make sure I'm clear .... because I don't think I am ...
We have two signals, the first with sample time T1 and the second with sampe time T2.
Question: Do these signals derive from the same source signal? If so, what is the sample time of that source signal?
Both signals are input to a switch, as shown in the picture in the question.
Question: What determines the middle input to the switch, i.e., the selection of the top or bottom signal?
John
John el 30 de Mayo de 2023
@Paul "Question: Do these signals derive from the same source signal? If so, what is the sample time of that source signal?"
Yes. That source is continuous-time. The rate transitions are shown in the OP.
"Question: What determines the middle input to the switch, i.e., the selection of the top or bottom signal?"
A separate logic block that computes certain statistics further down the chain (branching off of the output port), and switches based on a threshold.
Paul
Paul el 1 de Jun. de 2023
What is the concern at the output of the switch? That signal as has an FiM sample time, but will still obey the sample time of the selected signal at the times when the output signal from the switch is used, won't it?

Iniciar sesión para comentar.

Productos

Versión

R2022b

Preguntada:

el 11 de Mayo de 2023

Comentada:

el 1 de Jun. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by