next up previous contents
Next: Appendix D - Internal Up: Appendix C - Reverse Previous: Stack Operations   Contents

Examples

.PAR x1 { 1. 2. / }

As the expression between '{' and '}' is parsed from left to right, the following values are stored on the stack:



Step x y z
1. 1.0 0.0 0.0
2. 2.0 1.0 0.0
/ 0.5 0.0 0.0



The operator '/' takes the then current values of x and y (2.0 and 1.0) and divides them, resulting in the final value for the parameter x1 of 0.5.

.CALC V_dB { eout LN 10. LN / 10. X 2. X }

This example expresses the variable 'eout' in dB. The step by step stack values are (assuming that eout has the value 2.0 with no imaginary part):



Step x y z
eout 2.0 0.0 0.0
LN 0.693... 0.0 0.0
10. 10.0 0.693... 0.0
LN 2.302... 0.693... 0.0
/ 0.301... 0.0 0.0
10. 10.0 0.301... 0.0
X 3.01... 0.0 0.0
2. 2.0 3.01... 0.0
X 6.02... 0.0 0.0



The equivalent algebraic expression is:

$V_{dB}=\frac{ln(eout)}{ln(10.0)}*10.0*2.0$

or

$V_{dB}=20.0*log(eout)$

where $log$ is to the base 10.

.CALC pwr { eout CC iout X }

This example calulates the complex power associated with the voltage eout and the current iout. The equivalent algebraic expression is:

$pwr=conj(eout)*iout$

where $conj(eout)$ denotes the complex conjugate of eout.

.CKT

...

* define a 10.00 MHz crystal

* crystal Q:

.PAR q 75.e3

* crystal resonant frequency:

.PAR fo 10.e6

* calculate wo (rps):

.PAR wo { fo 2 X PI X }

* crystal motional resistance:

R R1 1 2 50.

* calculate motional inductance:

L L1 2 3 { R1 q X wo / }

* calculate motional capacitance:

C C1 3 4 { 1 L1 / wo / wo / }

* holder capacitance

C Co 1 4 5.pfd

...

.END

This example defines two crystal parameters, the q and resonant frequency fo. The values of wo, the motional inductance and the motional capacitance are then calculated based on the established parameters.


next up previous contents
Next: Appendix D - Internal Up: Appendix C - Reverse Previous: Stack Operations   Contents
Bob Smither 2008-11-19