How to set the sample time of a subsystem?

I have a model for xPC in which I have different masked subsystems. As they do different tasks, they need to run with different timesteps (some do fast acquisition, others need longer time to run and do communication or other slow tasks). Subsystems trigger each other (start each other - obviously the faster one is in control).
How can I define the sampling time of a subsystem (and all components inside)?
I'm using fixed step solver. What timestep do I need to set for it? - the shortest one that I use in any subsystem?
Thank you for any suggestion.
-any single core solution out there?

 Risposta accettata

Azzi Abdelmalek
Azzi Abdelmalek il 11 Feb 2014
Modificato: Stefanie Schwarz il 14 Ott 2023
Try a zoh block just before your subsystem and set sample time of your subsystem blocks to inherited
Add
If your subsystem doesn't contain a continuous block, right click on your subsystem, click on block parameter(subsystem) then check treat as atomic unit, and set your sample time

4 Commenti

Istvan
Istvan il 11 Feb 2014
Modificato: Stefanie Schwarz il 14 Ott 2023
Thanks for the answer. Sorry but I don't see how a Zero-Order Hold would help (as far as I understood that only delays the outputs, right?).
What I mean is more like: how to have the sample time textbox on the interface of a masked subsystem and force the entire subsystem to execute at that rate?
"Do not use the Zero-Order Hold block to create a fast-to-slow transition between blocks operating at different sample rates. Instead, use the Rate Transition block."
But I am struggling with that one: I want to impose the sample time on the entire subsystem... (like the sample time of an source or similar).
The zoh is used before a continuous blocks. Its input is maintained the same until the next sample. The zoh doesn't delay anything.
If your subsystem doesn't contain a continuous block, right click on your subsystem, click on block parameter(subsystem) then check treat as atomic unit, and set your sample time
Istvan
Istvan il 12 Feb 2014
Modificato: Stefanie Schwarz il 14 Ott 2023
Great! I think this is it (treat as atomic units) :) I have discrete states so it's exactly what I needed. After setting the treat as atomic unit box, with the Mask editor I could put the sample time property on the block interface. Thank you very much again!

Accedi per commentare.

Più risposte (0)

Categorie

Community Treasure Hunt

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

Start Hunting!

Translated by