Skip to main content

How to specify global parameters?

This tutorial requires:

DesignSpark Circuit Simulator

DesignSpark Circuit Simulator allows you to specify global parameters (variables) that can be used as component property values. This tutorial illustrates why this is useful and how to do it.

Parameter Arithmetic Functions and Operators

DesignSpark Circuit Simulator supports numerous arithmetic functions and operations to calculate complex component parameter values. These can be used when defining global parameters in the schematic, or internally with SPICE models.

Built-in Functions

SQRT (val)square root of val
LOG(val)neperian logarithm of val
LOG10(val)decimal logarithm of val
DB(val)value in DBs of val (20xLog10(val))
EXP(val)exponent of val
COS(val)cosine of val, where val is defined in radians
SIN(val)sine of val, where val is defined in radians
TAN(val)tangent of val, where val is defined in radians
ACOS(val)arc cosine of val, where val is defined in radians
ASIN(val)arc sine of val, where val is defined in radians
ATAN(val)arc tangent of val, where val is defined in radians
COSH(val)hyperbolic cosine of val
SINH(val)hyperbolic sine of val
TANH(val)hyperbolic tangent of val
SGN(val)returns +1 if val>0, 0 if val=0, -1 if val<0
SIGN(val)returns +1 if val is positive or null, -1 otherwise
SIGN(val1, val2)returns the ABS(val1)*SGN(val2)
PWR(val1, val2)returns the absolute value of val1, raised to the value of val2, with the sign of val1
POW(val1, val2)returns the value of val1 to the power of the integer part of val2
ABS(val)absolute value of val
INT(val)integer value of val (equivalent of TRUNC)
TRUNC(val)truncated value of val (integer part of real value)
ROUND(val)rounded, to the nearest integer, value of val

MIN(val1, ... valn)

DMIN(val1,...valn)

returns the minimum of val1 to valn. There is no limit to the number of values that can be specified

MAX(val1, ...valn)

DMAX(val1,...valn)

returns the maximum of val1 to valn. There is no limit to the number of values that can be specified

DERIV(val)

returns the derivative of val

REAL()

returns the real part of a complex number

IMAG()

returns the imaginary part of a complex number

MAGNITUDE()

returns the magnitude of a complex number

CONJ()

returns the conjugate of a complex number

COMPLEX(a, b)

returns a complex number using 'a' as the real part and 'b' as the imaginary part

DDT(val)

returns the derivative of val

IDT(val)

returns the integral of val

LIMIT(a,b,c)

returns b if a<b, returns c if a>c, returns a otherwise

BITOF(a,b)

returns "1" if bit b of the integer value of parameter is a "1". Returns "0" if bit b of the integer value of parameter a is a "0"

PWL(xvalue, interp, x1, y1, ...xn, yn)

returns the equivalent output value at the input value xvalue, interp=0|1 specifies whether the y value is interpolated linearly (1) or not (0). xn and yn are used to calculate the equivalent output value

Arithmetic Operators

^ (or**)raise to power
*multiply
/divide
+add
-subtract

Boolean Operators

OperatorMeaning
!=not equal to
==equal to
<less than
<=less than or equal to
>greater than
>=greater than or equal to
||OR operator
&&AND operator

Bitwise Operators

OperatorMeaning
&bitwise AND operator
|bitwise OR operator
<<bitwise shift left operator
>>bitwise shift right operator

Conditional Evaluation of Expressions

FunctionMeaning
VALIF(condition, expression 1, expression2)if condition is TRUE, return expression1 else return expression2
EVAL(condition?expression1:expression2)if condition is TRUE, return expression1 else return expression2

How to set global parameters

Set global parameters as follows:

  1. Click on the Design Settings icon in the schematic toolbar.
  2. Click on Global Parameters.
  3. Type a parameter Name and Value into the respective fields in the table dialog.

global parameters

The parameter Name cannot contain the string "Error".

 

Global Parameter Values and Expressions

As shown, global parameters can be simple numbers or mathematical expressions. Global parameter names can also be referenced in other global parameter expressions.

When the Global Parameter dialog is closed, a check will run to see if all of the expressions are valid. Error messages will appear if any problems are encountered.

If You Run Into Any Problems

If you run into any issues with the Global Parameter dialog, you can manually add the data as follows:

  1. Close the Global Parameter dialog if it is open.
  2. Click on Simulation Settings>Advanced Options
  3. Type your global parameters directly into the Manual Options text box.

The format is as follows:

.param name1 = value1 ! optional comment1

.param name2 = value2 ! optional comment2

For example:

.param res1 = pow(a, 3) ! Raise a to the third power

RS DesignSpark is the go-to platform for students, makers, hobbyists and professional design engineers, providing design resources such as the award winning DesignSpark PCB and DesignSpark Mechanical CAD software. Join the community today at https://www.rs-online.com/designspark/register

Comments