Please take a minute to review and accept our Terms of Use.
Welcome to the PLECS User Forum, where you can ask questions and receive answers from other members of the community.

Many technical questions regarding PLECS are answered on the Technical Solutions page of our website. Tutorial videos, specific application examples, and pre-recorded webinars are available on our YouTube page. Please follow us on LinkedIn for the latest Plexim news.

How can I create global initialization variables or parameters that work anywhere in the model hierarchy?

0 votes

In the Initialization tab of the Simulation parameters, can I have variables that work anywhere in the hierarchy of the model. i.e. global? At the moment, I create different variables and then I always have to create a mask for the top level block and pass the variables down. i.e.

In Initialization tab:


Then in the top-level block, I would have to have a parameter Rds equal to Rds and then use Rds in the block at the level below, and keep doing that if I wanted to pass that variable further down the hierarchy.

I'm wondering if I can avoid having to create a mask for the blocks in the hierarchy, with parameters for each of my variables, and just have a global variable I can use anywhere in the hierarchy.

asked Aug 27, 2020 by rcolbeck (21 points)

1 Answer

0 votes
Hi Roger,

Good question. Unfortunately I do think you need to define all mask variables used inside a subsystem *if* you mask it. But if you don't create the mask, the variables can be passed down the layer without needing to initialize them.

Another option I can think of for certain blocks (gains, controllable sources, etc.) would be to define the variable (variable(s) with a vector) in a Constant block at the top-level, then use Signal To/Signal From to send the setpoint to your target block in a lower layer elsewhere in the model. This would obviously not be a solution for defining block parameters at a lower level.

Best regards,

answered Aug 28, 2020 by Kris Eberle (1,595 points)
Thank-you Kris. Ah now that explains why at first I had some variables that were working but then after I created a mask for the top-level block, I started getting error messages about undefined variables. I hadn't put two and two together.

The vector idea is interesting.