Bandwidth
Description Calculate the Bandwidth for waveforms (in magnitude)
  Assumes the current plot is a plot of magnitude in db vs. frequency. The bandwidth is then measured with respect to the maximum, but down 3db on each side.
Hot Key  none
Script HomeCursors
Vsignal = current
theMax = max(Vsignal)
MoveCursorRight(0,Vsignal,theMax)
Fmax = GetCursorX(0)
SetCursor(1,Fmax)
MoveCursorRight(1,Vsignal,theMax-3)
MoveCursorLeft(0,Vsignal,theMax-3)
test = GetCursorX(1) - GetCursorX(0)
print test
Example Open <ICAPSdir>\CIRCUITS\buttfil\butfil1.dwg. Run the simulation, open Scope5 and plot db of vout by selecting dB and vout from the Add Waveforms dialog, then select Bandwidth from the Calculator/Control Systems menu.

 Bode Plot.
Description Create a Bode diagram for vin and vout
  You must have identified vectors Vin and Vout; either in the simulation or afterward in Scope5. The output vectors are gain (in db) and phase (in degrees). Scaling is set to 60dB per div and 20 deg. per division.
Hot Key  none
Script phase = phaseextend(phase(vout)-phase(vin))
plot phase
setylimits -300 300
gain = db(vout) - db(vin)
plot gain
setylimits -100 100
Example Open <ICAPSdir>\CIRCUITS\servo\servo.dwg. Run the simulation, open Scope5 and select Calculator/Control Systems\Bode Plot menu item.

 Bode Scale 20-60
Description Scale 20db/div 60deg/div center at 0.
  You must have identified gain and phase vectors. This script rescales them.
Hot Key  none
Script plot phase
setylimits -300 300
plot gain
setylimits -100 100
Example run the bode plot example, change scaling using Auto Scale in the scaling dialog, then run this script.

 Bode Scale 6-30
Description Scale 6db/div 30deg/div center at 0.
  You must have identified gain and phase vectors. This script rescales them.
Hot Key  none
Script plot phase
setylimits -150 150
plot gain
setylimits -30 30
Example run the bode plot example, then run this script.

 Bode with margins
Description Create a Bode diagram for vin and vout and show the gain and phase margin
  You must have identified vectors Vin and Vout; either in the simulation or afterward in Scope5.
Hot Key  b
Script phase = phaseextend(phase(vout)-phase(vin))
plot phase
setylimits -150 150
gain = db(vout) - db(vin)
plot gain
setylimits -30 30
HomeCursors
SetCursor(1,0)
MoveCursorRight(1, phase,0)
MoveCursorRight(0, gain,0)
gainMargin = -GetCursorY(gain,1)
phaseMargin = GetCursorY(phase,0)
print gainMargin
print phaseMargin
Example Open <ICAPSdir>\CIRCUITS\servo\servo.dwg. Run the simulation, open Scope5 and press b. This is a powerful single keystroke method. You may want to adapt it to your specific problem by changing scaling, vector names, etc. You should place the new script in your User folder so that future releases will not overwrite your work.

 Gain and Phase Margin
Description Prints gain and phase margin.
  Requires plots called gain and phase.
Hot Key  none
Script HomeCursors
SetCursor(1,0)
MoveCursorRight(1, phase,0)
MoveCursorRight(0, gain,0)
gainMargin = -GetCursorY(gain,1)
phaseMargin = GetCursorY(phase,0)
print gainMargin
print phaseMargin
Example Run the Bode Plot example, then this script.

 Group Delay
Description Measures the group delay in the pass band of an AC plot named vout
  Assume an AC simulation with a vector called Vout.
Hot Key  none
Script gain = db(vout)
phase = PhaseExtend(ph(vout))
theDelay = -differentiate(phase)/360
setunits theDelay sec
plot gain
HomeCursors
theMax = max(gain)
MoveCursorRight(0,gain,theMax)
Fmax = GetCursorX(0)
SetCursor(1,Fmax)
MoveCursorRight(1,gain,theMax-3)
MoveCursorLeft(0,gain,theMax-3)
plot theDelay
groupDelay = mean(theDelay)
print groupDelay
Example Open <ICAPSdir>\CIRCUITS\buttfil\butfil1.dwg. Run the simulation, open Scope5 and run this script.

 Nyquist
Description Nyquist for a new graph.
  Assume an AC simulation with vectors called Vout and Vin.
Hot Key  n
Script phase = phaseextend(phase(vout)-phase(vin))
gain = db(vout) - db(vin)
mag = 10^(gain/20)
real = -mag*cos(phase)
imag = -mag*sin(phase)
setunits real
setunits imag
newplot nyquist real
nyquist.imag = imag
setplot nyquist
plot imag
setxlimits -10 10
setylimits -10 10
Example Open <ICAPSdir>\CIRCUITS\servo\servo.dwg. Run the simulation, open Scope5 and press n. Then press b and select the link checkbox in the scaling dialog. As you move cursor 1 to the left, notice that the trace label moves along the nyquist showing the real, imaginary and frequency components.