Oscillator * You should edit this file to include values for c2 and c3. * Note that lines beginning with an asterisk are comment lines * and are ignored when running spice. * * POWER SUPPLY * vcc vcc 0 vcc .global vcc .param vcc=12 **************************** **************************** * To determine whether your circuit will oscillate, * you should break the positive feedback loop at some point * and call the node on one side of the break "drive" and the node on * the other side "meas". The "drive" node is the node that * you would drive with an input signal to find the return ratio. * The "meas" node is the node at which you would measure the * resulting output. Therefore the return ratio is the * ratio of the "meas" signal to the "drive" signal. .subckt osc out drive meas **************************** **************************** * ENTER YOUR CIRCUIT HERE * Note that the I/O node names are defined by the subckt call above * Colpitt's Oscillator vin in 0 0 l1 in l1 10m r1 l1 r1 10k xq1 r1 0 r1 t2n2222 c1 r1 c 3p xq2 c drive 0 t2n2369 r2 c3 meas 10k l2 c3 c 0.1u c2 c 0 c2 c3 c3 0 c3 c4 c3 meas 1n l3 vcc out 10m r3 out c3 220 .param c2= .param c3= **************************** **************************** .ends osc * * TWO IDENTICAL COPIES OF THE OSCILLATOR ARE USED. * ONE IS USED TO FIND RRV. THE OTHER IS USED TO FIND RRI. * * * VOLTAGE RR * xv vout vdrive vmeas osc vtest vmeas vdrive 0 ac 1 emeasbar vmeasbar 0 vmeas 0 -1 istart 0 vdrive pwl (0 0 1n 1m 2n 0) *The istart generator is intended to start the oscillations. * * CURRENT RR * itest 0 mid 0 ac 1 xi iout idrive imeas osc vmeas mid imeas 0 vdrive mid idrive 0 * * OPTIONS * .options nomod probe ingold=2 acout=0 .options post=2 .options numdgt=7 .options accurate * * TRANSIENT ANALYSIS * .op .tran 1n tstop .param tstop=200n .plot v(vout) .measure tran vopp pp v(vout) from '0.75*tstop' to tstop .measure tran voavg avg v(vout) from '0.75*tstop' to tstop .measure tran zero_cross1 when v(vout)=voavg rise=1 td='0.75*tstop' .measure tran zero_cross2 when v(vout)=voavg rise=2 td='0.75*tstop' .measure period param='zero_cross2-zero_cross1' .measure frequency param='1.0/period' .measure tran ivdd find i(vcc) at=0 .measure power_diss param='-1.*vcc*ivdd/2.' * Note that the power dissipation is divided by 2 above * to correct for the use of two identical circuits to * measure RRV and RRI simultaneously. * * AC ANALYSIS * .ac dec 100 50meg 500meg *Calculate and print the following outputs: * 1. the real part of the voltage return ratio (rrvr) * 2. the imaginary part of the voltage return ratio (rrvi) * 3. the real part of the current return ratio (rrir) * 4. the imaginary part of the current return ratio (rrii) .print ac rrvr=par('vm(vmeasbar) / vm(vdrive) \\ *cos(3.14159265*(vp(vmeasbar) - vp(vdrive))/180.)') \ rrvi=par('vm(vmeasbar) / vm(vdrive) \\ *sin(3.14159265*(vp(vmeasbar) - vp(vdrive))/180.)') \ rrir=par('(im(vmeas) / im(vdrive) * \\ cos(3.14159265*(ip(vmeas) - ip(vdrive))/180.))') \ rrii=par('(im(vmeas) / im(vdrive) * \\ sin(3.14159265*(ip(vmeas) - ip(vdrive))/180.))') .end