efficiency
Description Compares the power out versus the power in and prints the efficiency of the device.
Hot Key e
Script

*&e Print efficiency, give Vindc, In, Vout, Iout
efficiency = 100 * average(Vout*Iout/(Vindc*Iin))
set colwidth=1
printtext -n "efficiency = "
printval efficiency
printtext " Percent"


emi
Description Takes selected emi waveform and applies a hanning (han100) window and fft. Enables comparison to see if an electric device meets emi requirements of referenced MIL STANDARDS (MIL-STD-461D, or any other).
Hot Key --
Script

EMI Analysis
nameplot emi
* Init radix 16
fftinit(16)
* Build and apply han100 to current waveform.
if length(default) > 1
set units = rad
homecursors
pi = 4*atan(1)
alias previous = current
han100 = 1 - cos(2*pi*default/(getcursorx(1) - getcursorx(0)))
set units = deg
vo_ = (current[0] + current[length(current)-1])/2
result =vo_ + han100*(current - vo_)
plotf result han100(%s) previous
else
print "This plot contains no scale"
end
* FFT magnitude
timetofreq(current)
* plot the result in dbuv
measured = db(current) + 120
plot measured
setunits measured dbuv
* make fft log scaleable
rotate current -1
rotate default -1
last = length(default)-1
current[last] = current[last-1]
default[last] = default[last-1]+default[0]
* make log x and lin y axis
setscaletype log lin
* plot the specification
setplot emi_f
compose frequency values 10k+j(0) 500k+j(0) 5meg+j(0) 5.01meg+j(0) 10meg+j(0)
setunits frequency hertz
compose level values 90 54 54 60 60
setunits level dbuv
setautoscale all
plotref level frequency
setylimits -100 100
setvec measured
setylimits -100 100


 expandx
Description Place the cursors somewhere on the waveform and press x. The plot's x-axis is zoomed into the region between the cursors.
 

This is an example of a script you can create and place in "!Yourname" folder. Follow the format below and place the .scp file in the ...in\scripts subfolder. The scripts subfolders are the same as the hierarchy shown in the Calculator menu. The first line is a comment line that will be displayed in the HELP status at the bottom of the main window. If you create a bitmap (15 high by 16 wide), naming it with the saem name as you script, but with a .bmp extension, you can make it a toolbar button using the Options menu, Customize Toolbar dialog. You can also add a .htm file to provide further information about your script.

Hot Key  The character following the optional "&" symbol is the hotkey. In this case, we have chosen "x"
Script

*&x expands xscale to the cursors
setxlimits getcursorx(0) get cursorx(1)


 expandxallplots
Description Changes the x-axis of all plots to show their first and last point.
Hot Key  --
Script

* C:\spice8\In\Scripts\!User\expandxAllPlots.scp
nameplot ref
constants.xmin = getcursorx(0)
constants.xmax = getcursorx(1)
pl = nextplot(null)
constants.iter = 0
while pl <> null
if sameplot(xmin) = 0
setxlimits xmin xmax
end
pl = nextplot(pl)
end
setplot ref


expandy
Description  Similar to expandx except that it makes the y-axis scaling for the selected waveform full scale.
  see expandx for details
Hot Key  Y
Script

*&Y expands yscale to maximum for current waveform
setylimits min(current) max(current)


family

Description
 
Splits a waveform into the number of "pieces" or steps you specify.
Hot Key  --
Script * family subdivides a plot into a family
*function dmod2(x,n,xm) ( 1e-9 * xm * ( ( 1e9 / xm * x) % ( 1e9 / n) ) )
if isdef(current)
nameplot plotwas
constants.numsteps = 0
askvalues numsteps "The number of steps"
if numsteps > 0
thelength = length(default)
xmax = default[thelength-1]
timex = ( 1e-9 * xmax * ( ( 1e9 / xmax * default ) % ( 1e9 / numsteps ) ) )
newplot family
plot current plotwas.timex
destroy plotwas
else
print "Unacceptable input"
end
else
print "You must plot something"
end
 

familyP

Description
 
Allows you to compare two plots -- one plot showing a full waveform and a second showing the number of waveforms you specify. Used for parametric cursor evaluation.
Hot Key  --
Script * family subdivides a plot into a family
*function dmod(x,n,xmax) ( 1e-9 * xmax * ( ( 1e9 / xmax * x ) % ( 1e9 / numsteps ) ) )
if isdef(current)
nameplot plotwas
askvalues numsteps "The number of steps"
thelength = length(default)
xmax = default[thelength-1]
timex = ( 1e-9 * xmax * ( ( 1e9 / xmax * default ) % ( 1e9 / numsteps ) ) )
newplot family
plot current plotwas.timex
* destroy plotwas
else
print "You must plot something"
end

FFTscale

Description
 
Makes an fft log scalable by eliminating a zero starting point.
Hot Key  --
Script * make fft log scaleable
rotate current -1
rotate default -1
last = length(default)-1
current[last] = current[last-1]
default[last] = default[last-1]+default[0]
 

Frequency
Description  Works like a frequency counter to measure the period of the 10 cycles after the position of cursor 0. The w hotkey was used because f is already assigned to the fft.
Hot Key  w
Script

*&w frequency over next 10 intervals from cursor 0
trigval = mean(current)
trigchange = pk_pk(current)/10
setnthtrigger 0 current postrig trigval trigchange 1
setcursor 1 getcursorx(0)
setnthtrigger 1 current postrig trigval trigchange 10
frequency = 10 / (getcursorx(1) - getcursorx(0) )
setunits frequency Hz
print frequency


Max
Description  Allows you to move cursor 1 to max of current
Hot Key  --
Script

Movecursorleft 1 current max(current)


Superfamily
Description Allows you to use Sweep or Alter Dialogs to create multiple waveform vectors. Combines multiple vectors into one vector for analysis.
Hot Key s
Script

*superfamily
nameplot plotwas
nnv = nextvector(null)
len = length(default)
sumvec = 0
timevec = 0
while nnv <> null
if nnv <> default
if nnv <> sumvec
if length(nnv) = len
append sumvec nnv
append timevec default
end
end
end
nnv = nextvector(nnv)
end
newplot family
plot sumvec timevec
destroy plotwas


Power
Description If you provide in a graph waveform 1 as your current vector, and waveform 2 as your voltage vector. The power script will plot the power curve, and print to the output record window it's max and average value. It will also plot below the VI curve.

For further analysis you can enable parametric cursors by selecting the plot with the power curve and checking the link check box in the scaling window dialog. This makes the plot with the power curve the master trace plot and the VI curve plot the slave plot. You can now move cursor 1 along the power curve and see its corresponding voltage and current at that time.

Hot Key --
Script

* plot pwr and i-v if w1 = i and w2 = v
*plot id
*plot vd
pwr = w1 * w2
plot pwr
newplot
plot w1 w2
setplot plot1
setvec w3
print max(w3)
print average(w3)

movecursorleft 1 w3 max(w3)