cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you know you can set a signature that will be added to all your posts? Set it here! X

How do I show the value of a variable in a text block?

CH_10337917
2-Guest

How do I show the value of a variable in a text block?

I'm wanting to generate spice models in MathCad Prime worksheets. The problem I'm having is I can't seem to find a way to substitute the value of a variable into a text block.

I calculate some variables such as:

 

Model_Name:="HDS10M"

Nf=2.4

Isf=1.86e-7

 

Then I want to create a text block that contains something like this.

 

.model Model_Name diode(N=value(Nf) Is=value(Isf)... )

 

but I want this to be displayed in the worksheet so I can just copy and paste it into a text file to have a model..

 

.model HDS10M diode(N=2.4 Is=1.86e-7)

 

This would be very useful when there are a bunch of parameters like in a FET model or in a subcircuit to eliminate opportunity for human error. Is there any way to do this?

 

Best Regards,

Chris

1 ACCEPTED SOLUTION

Accepted Solutions
LucMeekes
23-Emerald III
(To:CH_10337917)

Prime will not let you do that in a  text block, but don't despair.

A text block is a nasty thing to copy text from, especially if it contains live math.

What Prime does offer is manipulation of strings. So you can build your SPICE line in an expression.

It might look like this:

LucMeekes_0-1658609916540.png

The interesting part is that you can have Prime write such text strings to a file, so you could build your entire SPICE deck from within Prime.

Assuming that you may be using multiple diode models, you can use a function to build the SPICE line:

LucMeekes_1-1658610254685.png

And you can take it a step higher by defining a more general function Model, from which you can create DiodeModel and other models:

LucMeekes_2-1658611433916.png

 

Success!
Luc

 

View solution in original post

4 REPLIES 4

Hi,

Like this:-

Capture8.JPG

Cheers

Terry

Hi Terry,

  Great answer, I can make that work in combination with Luc's answer below. 

Have a great week!

Best Regards,

Chris

LucMeekes
23-Emerald III
(To:CH_10337917)

Prime will not let you do that in a  text block, but don't despair.

A text block is a nasty thing to copy text from, especially if it contains live math.

What Prime does offer is manipulation of strings. So you can build your SPICE line in an expression.

It might look like this:

LucMeekes_0-1658609916540.png

The interesting part is that you can have Prime write such text strings to a file, so you could build your entire SPICE deck from within Prime.

Assuming that you may be using multiple diode models, you can use a function to build the SPICE line:

LucMeekes_1-1658610254685.png

And you can take it a step higher by defining a more general function Model, from which you can create DiodeModel and other models:

LucMeekes_2-1658611433916.png

 

Success!
Luc

 

Thanks Luc,

   That will work, Thanks allot for posting this solution. Have a great week!

Best Regards,

Chris

Top Tags