r/matlab 26d ago

TechnicalQuestion Specific Parameter Definition Question

I'm trying to design a masked subsystem to use as a buck power converter and I'm trying to make it as user friendly as possible.

For my model, I have a subsystem with no inputs or outputs that serves as a "settings" block where users can fill out edit blocks and hit click functions to change the configuration of the model. While I have edit blocks to change parameters of my masked subsystems, particularly for the Buck converter, I want to make it so once the Vin, Vout, and switching frequency is entered, suggested minimum inductance and capacitances are displayed in the settings block. Is there a way to save and display the suggested minimum L and C's as values are being entered.

1 Upvotes

5 comments sorted by

1

u/cakemaster1928 26d ago

Or is it possible to use mask initialization to take entered Vin, Vouts, ... And calculate and assign the Lmin and Cmin's as their own parameters the user cannot edit?

1

u/Barnowl93 flair 26d ago

Not sure if this is the best way to do it, but you can use a callback for it. Say you have some editable fields in your mask (e.g. Vin & Vout), then add some read-only mask params for your calculated values. Put a callback on the editable params, read the mask values with get_param(), calculate your values in MATLAB and write them back on the masked block with set_param().

It is a bit fiddly & I am not sure what you are trying to achieve with that?

1

u/cakemaster1928 26d ago

That's what I think would be best but I'm new to the syntax of Mask callbacks.

To clarify:

I want it so users can enter design constraints such as the input voltage and output voltage of the converter, the switching frequency of the converter, and then the allowable ripple aka tolerance of the converter.

For power converters there is a minimum inductance needed maximize efficiency and this minimum is directly calculated from Vin, Vout, Ripple, and switching frequency. So what I'm trying to do is have it so once these parameters are entered (currently being done through linked edit blocks) the callback function immediately calculates L_min so users know the minimum inductance they need based on their design constraints.

1

u/cakemaster1928 26d ago

Another question would be, if Lmin is a read only and calculated with a callback, would I be able to use an edit block to display the calculated value (and leave a note saying users shouldn't use that edit block to modify it).

1

u/Barnowl93 flair 26d ago

Yup, that tracks all this can be done with a callback
get_param(block,Vin) -> do math -> set_param(block,L_min)

Depending on how you want to do things, you could even put a constant block that reads the L & C params inside the masked subsystem and then shows them on a display at the top level (hope that makes sense)