Numerit[WIN32][1700][1703]CD~11e:\programs\numerit\pll files qffffff)@j@fffffvq@?@ffffff9@?@ffffff9@ffffff)@ffffff)@         Times New RomanArialSymbol Courier New X ffffff)@@ refNoiseAmplG uVnc@&1V@oscNoiset>@>@>@>@>@>@>@ >@ >@ >@>@>@>@>@>@ >@  >==>>??%Oscillator fractional frequency errorTime (s) 1.008e-07 1.017e-071e-100.010.01 020002000.010.01E c@fffffv3@>yosc(t)=dt+tnosc(t')dt'0!z(zzz}yzy}}x}}zxz}}x0zz(zzzyzyy}zzyy(>>d>> >>>>> E H@ @cnosc!z(zzzd E *@@Kd!zd X ffffff)@@oscDriftE @@] s-1!z(xy  d       E 9@ @cyosc!z(zzzd X ffffff)@@ oscNoiseAmplE ffffff?@Ks!zd X 0@@ RMStimeErrG &1c@GzN[@refNoiset ReferencetimeErrt PLL output>@>@>@>@>@>@>@ >@ >@ >@>@>@>@>@>@ >@  >==>>??Time error (s)Time (s) -3.5e-083.75e-085e-090.010.01 0.010.01E c@wwwwwg2@&y(t)=f(t)-f0f0!zyzy}x}$zyzyxz(yz(y&&d&&&&&&& E c@wwwwwg2@&x(t)=x(0)+ty(t')dt0'!zyzy}x}zyyy}x}0zzyzyyzzyy&&d&& &&&&& E DDDDD @@KN!zd E ffffff @ @_ xi!z(z  d       E c@23@uksyt=12t2(N-2m)N-2mxi+2m-2xi+m+xii=12!({(z"{x'$yy{(yyzxyzy1zxyz"z(zxyzxyz(zxzxz(zzxy(ykkdkk3 kkkkk E @@Kt!{d E ffffff @@Km!zd E @@Kt!{d E c@(@et=mt0!{xz{(yd G |?5fc@ rY@adevReftau Reference adevSteeredtau PLL outputadevOsctau Oscillator>@>@>@>@>@>@>@ >@ >@ >@>@>@>@>@>@ >@  >==>>??Overlapping Allan Deviation Time Interval-11-61 0.010.01031 0.010.01vvvpvvvpvvvpvvvpvvvpvvvpvvv Phase Lock Loop Simulationvvv vvv Oscillator Noisevvv vvv Oscillator fractional frequency error, ) , at time, t, is modeled as a sum of random walk frequency noise and a constant frequency drift. vvv ! # vvv & = ' ( Avvv $ is a Guassian random variable with standard deviation =* vvv vvv " vvv vvv vvv Reference Noisevvvp:vvv Reference noise is modelled as Gaussian White Phase Noise vvv with standard deviation =! vvv vvv  vvv Resultsvvv vvv The RMS time error =- , vvv vvv . vvv vvv vvv vvv vvv vvv Allan Deviation vvv The time dependent fractional frequency error, y, depends, on the instantaneous frequency, f, and nominal frequency, f0. The time is t. " 2 @vvv The time error, x, is the integrated fractional frequency error.vvv # 4 vvv The Allan Deviation is based on the first difference of the fractional frequency errors (second difference of the phase error). Unlike the standard deviation, it does not depend on the average value of the data. This makes it a better statistic for describing non-stationary data with drift, flicker or random walk noise. The overlapping version of the Allan deviation is calculated below. Note that the Allan Variance is the square of the Allan Deviation.Rvvv The Allan Deviation calculated from the 5 time errors, 6 , is given by,$ 7 ovvv where the time intervals, "8 , is an integer multiple, 9 , of the sample time ": 0.% ;  vvv __<  q8ffffff)@j@fffffvq@?@ffffff9@?@ffffff9@ffffff)@ffffff)@         Times New RomanArialSymbol Courier New `pll.num2`This program simulates a simple phase-locked loop;`with models for reference noise and oscillator instability`version 1.1, July 25, 2005`Created by Doug Arnold/`This program is freeware. Use at your own riskclear`input parameters0numData = 1000 `number of data points=iStart = numData/2+1 `start computing the RMS time errorSrefNoiseAmpl = 5.0e-8 `reference noise amplitude, units the same as sample timeSoscNoiseAmpl = 1.0e-10 `oscillator random walk noise, fractional frequency errorUoscDrift = 1.0e-9 `oscillator fractional frequency drift/sample time intervalNfreqErrInit = 1e-7 `initial fractional frequency errorclockRes = 5.0e-9/dt = 1.0 `sample time intervalt[numData]:0.0 `timefor i = 1 to numDatat[i] = (i-1)*dt.`oscillator noise (fractional frequency error)!noiseVector[numData]:oscNoiseAmpl!oscNoise = randGuass(noiseVector)VcumSum = freqErrInit `random walk frequency noise + constant oscillator driftfor i = 1 to numDatacumSum += oscNoise[i]!oscNoise[i] += cumSum + oscDriftoscPhaseErr[numData]:0.0for i = 2 to numDataNoscPhaseErr[i] = oscPhaseErr[i-1] + 0.5 * dt * (oscNoise[i] + oscNoise[i-1])`reference noise (phase error)AnoiseVector[numData]:refNoiseAmpl `Guassian white phase noise randomize!refNoise = randGuass(noiseVector)`PLLtimeErr[numData] = 0.0freqErr[numData] = 0.0freqCorrect[numData] = 0.0sumTimeErr = 0.0.pllFilter(0,true) `initialize pll filterfor i = 2 to numData/timeErr[i] = timeErr[i-1] - freqErr[i-1] * dt)measTimeErr[i] = timeErr[i] + refNoise[i]2freqCorrect[i] += pllFilter(measTimeErr[i], false))freqErr[i] = oscNoise[i] + freqCorrect[i]if i >= iStart(sumTimeErr += timeErr[i]^2 `skip`Compute output quantities0RMStimeErr = sqrt(sumTimeErr/(numData-iStart+1))NnumTau = trunc(log(numData)/log(2)) ` compute Overlapping Allan Deviationstau[numTau]:0.0adevRef[numTau]:0.0adevOsc[numTau]:0.0adevSteered[numTau]:0.0Hfor j = 1 to numTau ` generate octave progression of sample timestau[j] = 2^(j-1) * dtadevRef = adev(refNoise,tau,dt)"adevOsc = adev(oscPhaseErr,tau,dt)"adevSteered = adev(timeErr,tau,dt)Q`````````````````````````````````````````````````````````````````````````````````Q` F U N C T I O N S `Q` `Q````````````````````````````````````````````````````````````````````````````````` ` pllFilter7` argument 1 is a measured time error (bias) in secondsV` argument 2 is a boolean: a value of zero runs the next data point through the filterA` : any other value initializes the filter/` returned is a fractional frequency correctionfunc pllFilter(timeErr, init) if initphaseGain = 0.01freqGain = 0.1prevTimeErr = 0.0correction = 0.0elseHcorrection += phaseGain * timeErr + freqGain * (timeErr - prevTimeErr)prevTimeErr = timeErrreturn correctionQ````````````````````````````````````````````````````````````````````````````````` `randGuass,`argument is a vector of standard deviationsR`returns a coerresponding vector of zero-mean guassian distributed random numbers,9`each one adjusted for the input standard deviation valuefunc randGuass(deviation)imax = length(deviation)guassian[imax] : .0#if odd(length(deviation)) imax -= 1Wfor i = 1 to imax by 2 `generate two at a time for efficiencyranSquare = 2.0+while (ranSquare >= 1.0 or ranSquare = 0.0)interval[2] : 2.0ranNum = rand(interval) - 1.0&ranSquare = ranNum[1]^2 + ranNum[2]^2Nfactor = sqrt(-2.0*log(ranSquare)/ranSquare) `Box-Mueller transformation/guassian[i] = ranNum[1] * factor * deviation[i]4guassian[i+1] = ranNum[2] * factor * deviation[i+1]Uif odd(length(deviation)) `Do the last one if necessaryranSquare = 2.0+while (ranSquare >= 1.0 or ranSquare = 0.0)interval = 2.0..2.0 len 2ranNum = rand(interval) - 1.0&ranSquare = ranNum[1]^2 + ranNum[2]^2,factor = sqrt(-2.0*log(ranSquare)/ranSquare):guassian[imax+1] = ranNum[1] * factor * deviation[imax+1]return guassianS````````````````````````````````````````````````````````````````````````````````````adev(`returns the Overlapping Allan Deviation&`argument 1 is an array of time errors)`argument 2 is an array of time intervalsfunc adev(x,tau,dt)numX = length(x)numTau = length(tau)sigma[numTau]:0.09for j = 1 to numTau ` Allan deviation calculationadevSum = 0.0m = round(tau[j]/dt)for k = 1 to numX - 2*m+adevSum += (x[k] - 2*x[k+m] + x[k+2*m])^22sigma[j]= sqrt(adevSum/(2*(numX-2*m)*(tau[j])^2)) return sigma@c:\documents and settings\darnold\my documents\programs\numerit\ numDataiStart refNoiseAmpl  oscNoiseAmpl  oscDrift  freqErrInitdtt i noiseVector oscNoise cumSum oscPhaseErr refNoise timeErr freqErr freqCorrect sumTimeErr measTimeErr RMStimeErr numTautau adevRef adevOsc  adevSteered j 6  C @      4 ,   X8 4  A B N6 4 ,  <      X8 4 N  4 @S  N6 4 ,    X8! 4  A4 B 4  A4 @B@  N6$ 4 , %& < ) 4 * 4 + 4 , - <?/   X8 0 4  A4  A4 BA1 4 4 4 @2 4 4<S3 4 4 4@4  Z7 5 4 EN N6 9  A @C; C< 4 ,= 4 ,> 4 ,? 4 ,A   X8B 4   AE B N6 D  <E  <F   <#14CTW_{~ # randGuass randGuass deviationimax guassiani ranSquare intervalranNumfactor gh i 4 ,j 7 Ol   X8m n  Z  \b7o 4 ,p  Aq 4 E 4 E@6r G B Cs 4 4 B 4Bt  @4 4 B  @4B N6v 7w x  Z  \b7y   fz  A{ 4 E 4 E@6| G B C}  @4 4 B  @4B => hk?t pllFilter pllFiltertimeErrinit phaseGain freqGain prevTimeErr correction %ST 7U V W X 6[  B   AB@N\ ^ =_> adev adevxtaudtnumXnumTausigmajadevSummk d   4 ,   X8  4 C     BAX8 4  @4BA  B@4@ EN N 6 4     BAB 4 EBC N6 =>\_$DG 1000@@2@1?5.0e-8Hj>1.0e-10|=1.0e-9& .>1e-7Hz>1.0?0.00.5?00.01{Gz?0.1?.02.0@