From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multisim and Ultiboard

cancel
Showing results for 
Search instead for 
Did you mean: 

Adding parameters to a model

How can one add parameters to a user model?

 

I have a simple op amp model

 

 

.subckt OpAmp n p o
E^@RefDes o 0 VALUE { max(0, min(5, 1000000*(V(p) - V(n)))) }
.ends

 

I would like not to fix the high and low voltage but be able to set them through the properties similar to the components that come with multisim(double clicking on the component brings the "value"'s up). I've searched and searched and can't find out how to do this.

0 Kudos
Message 1 of 9
(4,161 Views)

Hi,

Remove the  "^@" characters on the second line and you model will work.

Tien P.

National Instruments
0 Kudos
Message 2 of 9
(4,152 Views)

Huh? That has nothing to do with it and the model does work(I have not had issues with it at least).

 

The question is about adding parameters which your example does not address at all

 

ERefDes  o 0 VALUE { max(0, min(5, 1000000*(V(p) - V(n)))) }

 

Should be

 

ERefDes  o 0 VALUE { max(lowVoltage, min(highVoltage, 1000000*(V(p) - V(n)))) }

 

Where I can specify lowVoltagea nd highVoltage outside the model(so it can be changed easily). If it is fixed then it is much harder to use. I would like to actually use Vcc and Gnd for high and low voltages by default but be able to change them.

 

For example, when you double click on a resistor you can change it's resistance. I would like to be able to double click on my opamp model to be able to change it's rail voltages. My model works fine except it is inconvienent to edit the model just to change rail voltages.

 

 

 

0 Kudos
Message 3 of 9
(4,149 Views)

Hi,

 

I apologize for misreading your question. Any component that you double click and the dialog allows you to enter a value is a custom dialog, they are hard coded. Any component you make will use a standard dialog and the only way to change the model is to click the "Edit Model" button. IF you don't want to change the SPICE code, your second option is to create a 5 pin opamp model and you can connect a DC source to it to change the rail voltages.

Tien P.

National Instruments
0 Kudos
Message 4 of 9
(4,137 Views)

Ok, that sucks but I guess I'll have to manually change it.

0 Kudos
Message 5 of 9
(4,132 Views)

Aliassss,

 

You can use the "PARAMS:" statement directly after the subckt header to identify parameters for use in a model.   See below for an example on 2 different ESR capacitor models that allow you to set parameters up.    The parameters can be used with { param1 } to identify them within the subcircuit - the expressions using the parameters are evaluated right before the simulation occurs.

 

Once set, you only need to adjust the parameters once (you'll still need to press the 'Edit Model') but you won't need to do any special calculations internal to the model.

 

This is what a model looks like with an included 'PARAMS' statement when you click on the edit button...

 

params.JPG

 

Attached are some ESR capacitors that have been created that use the PARAMS: declaration...

 

Regards,

Pat

0 Kudos
Message 6 of 9
(4,123 Views)

Thanks, I guess that is one step closer. Would seem that multisim could make a special page that lets you quickly change those params similar to doing it with built in components(would be quite simple).

0 Kudos
Message 7 of 9
(4,117 Views)

Aliassss,

 

I believe we have this as a feature request.   I will let our Multisim R&D team know about your interest.  

 

If you have any additional thoughts on how you'd like parameters shown or displayed, let us know (I am assuming similar to the Virtual components, but what if you had more than 10-20? how would these get displayed (in a table)?).  

 

Also would you recommend including units, and if so is there any specific way you would display unit information - or would you recommend having free form text and the formatting would have to conform to the standard SPICE parser formats?

 

We welcome your input,

 

Pat Noonan

National Instruments

 

 

0 Kudos
Message 8 of 9
(4,107 Views)

I wouldn't mind just a list of the params components that would show up under the values section(or a different tab) when the component is doubled clicked on. Similar to what happens when you double click on a built in component such as an AC Voltage source.

 

As far as the number of components goes I don't see why not just have a horizontal scroll bar.

 

Since spice doesn't seem to be able to handle units properly and units are not really that big a deal(since there isn't any dimensional analysis possible anyways) one could either ignore them(just display the param name's and param value's) or have a separate config file with the model that can specify the param value units. If the file doesn't exist or is not complete the unit simply would not be shown.

 

Another way would possibly use metadata in the spice model. You could imbed the units in a comment in the spice model. This will not effect the compatibility of the model. You could go further and include some type of syntax to include better support for units(min/max values, eps, default step size, etc...).

 

I'd be content with just a dialog box with a list of the param names and values.

0 Kudos
Message 9 of 9
(4,099 Views)