'10-17-06 version110 released. 'This version is updated from version 108. For both MSA and VNA. nomainwin 'all of the following are "default" values and are dependent on the construction of your Spectrum Analyzer masterclock = 64 'enter the exact frequency of the Master Clock (in MHz). Example: 64.000056 or 63.999937 'if exact frequency is unknown, enter the nominal value of Master Clock. Example: 64. You can chage it when calibrating. centfreq = 200 'enter the default center frequency, in MHz. For initial set-up use "0" sweepwidth = 400 'enter the default sweep width, in MHz. For initial set-up use 10 times the BW of Final Xtal Filter wate = 0 'value to "slow" the sweep speed for more accurate data. Use "0" as default. steps = 400 'whole number of steps per sweep. 1 thru 720 is acceptable. 400 is a good number. marker1 = 100 'marker 1 step placement, default. A marker will be placed on the graph, at this step number marker2 = 200 'marker 2 step placement, default. If no markers are wanted, enter the value, 750, in each marker default marker3 = 300 'marker 3 step placement, default. If the value is greater than "steps", no marker will display finalfreq1 = 10.7 'freq of Final Xtal Filter # 1, in MHz finalbw1 = 2.0 'BW (in KHz)of Final Xtal Filter # 1 sagain1 = 0 'total gain of SA with Final Filter #1 installed finalfreq2 = 10.7 'freq of Final Xtal Filter # 2, in MHz. If only Final Xtal Filter # 1 is used, enter duplicate values. finalbw2 = 15 'BW (in KHz)of Final Xtal Filter # 2 sagain2 = 0 'total gain of SA with Final Filter #2 installed finalfreq3 = 10.7 'freq of Final Xtal Filter # 3, in MHz finalbw3 = 30 'BW (in KHz)of Final Xtal Filter # 3 sagain3 = 0 'total gain of SA with Final Filter #3 installed finalfreq4 = 10.7 'freq of Final Xtal Filter # 4, in MHz finalbw4 = 300 'BW (in KHz)of Final Xtal Filter # 4 sagain4 = 0 'total gain of SA with Final Filter #4 installed appxDDS = 10.7 'this is the nominal DDS output frequency (in MHz) that steers PLL 1, must be the center freq. of DDS xtal filter ddsfilbw = .015 'this is the DDS xtal filter bandwidth (3 dB points) PLL1 = 2326 'enter PLL #: 2325, 2326, 2350, 2353, 4112 PLL1phasefreq = .974 'approximate Phase Detector Frequency (MHz) you want for PLL 1. Use .974 when DDS filter is 15 KHz wide 'PLL1phasefreq must be less than the following formula: PLL1phasefreq < (VCO 1 minimum frequency) x ddsfilbw/appxDDS PLL1mode = 0 '0 = Integer Mode, 1 = Fractional Mode for PLL 1. I don't recommend Fractional Mode for PLL 1, although it will work (noiser) PLL1phasepolarity = 0 'for non-inverting loop filter, enter 1; for inverting op amp, enter 0 PLL2 = 2326 'enter PLL #: 2325, 2326, 2350, 2353, 4112, or 0 for SRD multiplier appxLO2 = 1024 '2nd LO frequency (MHz). 1024 is nominal, Must be a whole number multiple of "PLL2phasefreq" PLL2phasefreq = 4 'PLL2 phase frequency (MHz). This must be a numerical sub-multiple of "appxLO2". 4 is nominal PLL2phasepolarity = 1 'for non-inverting loop filter, enter 1; for inverting op amp, enter 0 PLL3 = 2326 'enter PLL #: 2325, 2326, 2350, 2353, 4112. Enter "0" (zero) for no Tracking Generator. 2350 and 2353 can be used as fractional-N PLL3phasepolarity = 0 'enter 1 for non-inverting loop filter; for inverting op amp, enter 0 PLL3off = 970 'Output freq of PLL3/VCO3 when Trk Gen "off", in MHz PLL3top = 1 'PLL3 Topology. Enter "0" for original Trk Gen. Enter "1" for New TG (DDS3/PLL3 combination) PLL3mode = 0 '1 = Fractional Mode, 0 = Integer Mode. If fractional mode is used, the step size is "PLL3phasefreq"/16 'if Original TG is used, PLL3mode can be "0" or "1". Enter "0" for new DDS/PLL combo. It must Integer-N PLL3phasefreq = .974 'TrkGen PLL3 phase frequency (MHz). If TG is DDS3/PLL3 combo, use same technique as PLL1phasefreq 'if Original TG (PLL3top=0) then this must be a sub-multiple of both Master Clock and Final Xtal Filter Frequency appxDDS3 = 10.7 'Nominal DDS3 output frequency (in MHz) that steers PLL 3 (center freq of DDS 3 filter) 'Enter "0" if using original Tracking Generator design dds3filbw = .015 'this is the DDS3 xtal filter bandwidth (3 dB points), in MHz PLL3offset = 0 'Enter "0" (Mhz). This is offset frequency for PLL 3, Tracking Generator, but not tested yet glitchtime = 5000 'this is whole numer value that is added to the [Settle Down] when the DDS or PLL changes drastically topref = 0 'default, top reference line on scale, magnitude, in dBm input to MSA. For initial set-up, use "0" botref = -100 'default bottom reference line on scale, magnitude, in dBm input to MSA. For initial set-up, use "-100" '[CalibrationFile] 'change following variables for your Log Det/AtoD combination adconv = 12 '"8" for original 8 bit,"12" for optional 12 bit ladder,or "16" for serial AtoD maxpdmout = 4094 'maximum bit count for the Phase AtoD converter. Determined during VNA calibration. Default is 4095 invdeg = 180 'actual phase change when PDM is inverted. Default is 180. Enter actual value after calibration. maxpower = 0 'maximum power level input to the Log Det, in dBm 'the maximum input must be below Log Det compression. Nominally 0(0dBm) for LM3356, to as much as 10(+10 dBm)for AD8306/7 maxbits = 4094 'bit value when maxpower is applied to Log Det minus10bits = 3868 'bit value when 10 dB less than maxpower is applied to the Log Det minus20bits = 3417 'bit value when 20 dB less than maxpower is applied to the Log Det minus30bits = 2980 'bit value when 30 dB less than maxpower is applied to the Log Det minus40bits = 2532 'bit value when 40 dB less than maxpower is applied to the Log Det minus50bits = 2021 'bit value when 50 dB less than maxpower is applied to the Log Det minus60bits = 1569 'bit value when 60 dB less than maxpower is applied to the Log Det minus70bits = 1058 'bit value when 70 dB less than maxpower is applied to the Log Det minus80bits = 642 'bit value when 80 dB less than maxpower is applied to the Log Det minus90bits = 418 'bit value when 90 dB less than maxpower is applied to the Log Det minus100bits = 385 'bit value when 100 dB less than maxpower is applied to the Log Det minus110bits = 382 'bit value when 110 dB less than maxpower is applied to the Log Det minus120bits = 381 'bit value when 120 dB less than maxpower is applied to the Log Det minus130bits = 380 'bit value when 130 dB less than maxpower is applied to the Log Det 'The following are nominal values you can start with, before calibration 'nominal value: 8 Bit 12 Bit 16 Bit 'maxbits = 255 4095 65535 'minus10bits = 241 3741 59850 'minus20bits = 213 3384 54140 'minus30bits = 186 3024 48380 'minus40bits = 158 2673 42770 'minus50bits = 126 2323 37170 'minus60bits = 97 1981 31700 'minus70bits = 65 1631 26100 'minus80bits = 39 1299 20780 'minus90bits = 28 971 15540 'minus100bits = 23 697 11150 'minus110bits = 23 577 9230 'minus120bits = 23 556 8900 'minus130bits = 23 553 8850 '--------Normally, nothing below this line will ever need changing---------- x = 720 'graph horizontal is 720 pixels in width(x), for 800x600 pixel monitor y = 300 'graph vertical is 300 pixels in amplitude(y) windowwide = 800 'Working and Graph Windows are 800 pixels wide maxscale = 255 'height of Log Scale, in pixels, must be less than y windowhigh = 185 'Working Window is 180 pixels in height graphhigh = 415 'Graph Window is 415 pixels in height finalfreq = finalfreq1 'default freq for the last filter center freq using finalfreq1 finalbw = finalbw1 'default bw for the last filter center freq using finalbw1 gain = sagain1 'default gain for SA using sagain1 'the following lines of code are operations and will not be changed by the user unless 'a different type of Control Board is used. port = hexdec("&H378") 'printer port data address for specific computer status = hexdec("&H379") 'printer port status address for specific computer control = hexdec("&H37A") 'printer port control address for specific computer contclear = 11 'global to take all LPT control lines low fqud = 10 'global to take LPT-pin 1 high. (Strobe line,FQUD) wclk = 9 'global to take LPT-pin 14 high. (Auto Feed line,WCLK) enat = 15 'global to take LPT-pin 16 high. (Init Printer line,ENAT) enap = 3 'global to take LPT-pin 17 high. (Select In line,ENAP) wclkfqud = 8 'global to take both LPT-pins 1 & 14 high. (FQUD,WCLK) dim datatable(800,3) 'data from most current sweep, 0thisstep(#),1thisfreq(MHz),2thispointpower(dBm),3phaseofpdm(deg) dim magarray(800,2) 'magni pixels for each step#: 0pointx, 1oldmagpixel,2newmagpixel dim phaarray(800,2) 'phase pixels for each step#: 0notused,1oldphapixel,2newphapixel dim calarray(800,2) 'calibration data for each step#: 0notused,1absolutemagnitude(dBm),2absolutephase(deg) 'Initialize circuits in MSA out port, 0 'begin with all data lines low out control, contclear 'begin with all command lines low '[InitializeDDS]'reset DDS. It can power up in a bogus condition. gosub [ResetParallelDDS]'needs:control,wclkfqud,contclear ; resets DDS on J5, parallel if PLL3top = 1 then Jcontrol = enat:swclk = 32:sfqud = 2:gosub [ResetSerialDDS] '[ResetSerialDDS]needs:port,control,Jcontrol,swclk,fqud,contclear ; resets DDS, serially '[InitializeTrkGen]'set PLL3 to proper Rcount, initialize and command Rcounter if PLL3top = 0 then gosub [CreateRcounterPLL3old]'needs:masterclock,PLL3phasefreq ; creates:rcounter3,pdf3 if PLL3top = 1 then gosub [CreateRcounterPLL3new]'needs:appxDDS3,dds3filbw,PLL3phasefreq ; creates:rcounter3 gosub [CommandPLL3R]'needs:rcounter3,PLL3mode,PLL3phasepolarity,enat,PLL3 ; Initializes and commands PLL3 Rcounter '[CommandFreqToTrkGen]'set PLL3 to proper Ncount, and change frequency of PLL3 LO3 = PLL3off if PLL3top = 0 then gosub [ChangeFreqofPLL3old]'needs:LO3,rcounter3,masterclock,enat ; commands PLL3 Ncounters ; creates:ncounter3,fcounter3,Bcounter3,Acounter3,LO3 if PLL3top = 1 then gosub [ChangeFreqofPLL3new]'needs:LO3,rcounter3,appxDDS3,enat ; commands PLL3 Ncounters ; creates:ncounter3,fcounter3(0),Bcounter3,Acounter3,dds3output,pdf3 '[InitializePLL2]'set PLL2 to proper Rcount, initialize and command to LO2 frequency rcounter2 = int(masterclock/PLL2phasefreq) if (masterclock/PLL2phasefreq) - rcounter2 >= .5 then rcounter2 = rcounter2 + 1 'rounds off rcounter2 gosub [CommandPLL2R]'needs:rcounter2,PLL2phasepolarity,enap,PLL2 pdf2 = masterclock/rcounter2 'actual phase detector frequency of PLL 2 appxVCO = appxLO2 : reference = masterclock gosub [CreateIntegerNcounter]'needs:appxVCO,reference,rcounter ; creates:ncounter,fcounter(0) ncounter2 = ncounter:fcounter2 = fcounter gosub [CommandPLL2N]'needs:ncounter,fcounter,enap,PLL2 Bcounter2=Bcounter: Acounter2=Acounter '[InitializePLL1]'set PLL1 to proper Rcount and initialize 'need appxDDS,PLL1phasefreq,ddsfilbw rcounter1 = int((appxDDS + (.5*ddsfilbw))/PLL1phasefreq) 'This determines the whole number Reference divide ratio for PLL 1 if ((appxDDS + (.5*ddsfilbw))/PLL1phasefreq) - rcounter1 >= .5 then rcounter1 = rcounter1 +1 gosub [CommandPLL1R]'needs:rcounter1,PLL1mode,PLL1phasepolarity,enap,PLL1 '[SetUpWorkingWindow] Create the Working Window, using global variables gosub [createWorkingWindow] 'create Working Window for MSA using global default values [GrabWorkingWindowData] 'get info from Working window to create Graph Window gosub [calcWindowInfo] '[SetUpGraphWindow] 'create the Graph Window, using Working Window data if vna = 0 then gosub [CreateGraph] 'create SA Graph and then return here if vna = 1 then gosub [CreateGraphforVNA] 'create VNA Graph and then return here if harmonicwindow = 1 then print #harmonicwindow.image0button, "!setfocus" print #main.hitkeybox, "!setfocus" 'make sure the "Hit any Key" box has the focus [SweepFromStartFreq] print #handle, "discard" 'clear out pc memory of drawn segments thisstep = 0 'create step number for beginning of sweep lastpointx = 0 'create graph points for beginning of sweep lastpointy = y-1 if invdeg = 1 then gosub [CalPDMinvdeg] [CalculateNextStep]'needs:startfreq,stepfreq,thisstep,thisfreq,LO2,finalfreq ; creates:thisfreq,LO1 thisfreq = startfreq + (stepfreq * thisstep) 'calculates input freq. at this new step LO1 = thisfreq + LO2 - finalfreq 'calculates the actual LO1 frequency '[CalculateNforPLL1]'needed:LO1,appxDDS,rcounter1,spurcheck ; creates:ncounter1,fcounter1,pdf1,ddsoutput if PLL1mode = 0 then gosub [CreatePLL1asInteger]'needs:LO1,appxDDS,rcounter1 ; creates:ncounter1,fcounter1(0),pdf1,ddsoutput if PLL1mode = 1 then gosub [CreatePLL1asFractional]'needs:LO1,appxDDS,rcounter1,spurcheck ; creates:ncounter1,fcounter1,pdf1,ddsoutput '[CommandDDSforPLL1]needed:ddsoutput,masterclock,lastddsoutput,appxDDS,ddsfilbw if ddsoutput = lastddsoutput then goto [endCommandDDSforPLL1] 'skip command if not needed if ddsoutput-appxDDS>ddsfilbw/2 then beep:error$="DDSoutput too high for filter" if appxDDS-ddsoutput>ddsfilbw/2 then beep:error$="DDSoutput too low for filter" if ddsoutput < lastddsoutput then glitch = 1 'add delay to prevent PLL settling glitch ddsclock = masterclock gosub [CreateBaseForDDS]'needs:ddsoutput,ddsclock ; creates: base word0 = 0 'a "1" here will activate the x4 internal multiplier, but not recommended gosub [DDScommandParallel]'needs:base,word0,port,control,wclk,fqud,contclear ; commands DDS on J5, parallel lastddsoutput = ddsoutput [endCommandDDSforPLL1] '[CommandPLL1]'needed:ncounter1,fcounter1,PLL1mode,enap,PLL1 gosub [CommandPLL1N]'needs:ncounter1,fcounter1,PLL1mode,enap,PLL1 ; commands PLL NBuffer '[UpdateNewTrkGen]This is skipped if TG is original topology or turned "OFF" if PLL3top = 1 and trkgen = 1 then LO3=LO2 + thisfreq + PLL3offset:gosub [ChangeFreqofPLL3new]:glitch = 1 'when new TG changes freq, it takes time to settle, during which, the Phase Det Module is invalid, therefore, add glitch time '[ResetPhaseDetModule]Set the PDM phase for last known mode, since it is likely a PLL3 command will reset the PDM to Norm. Put it here, before [SettleDownTime]. if vna = 1 then out port, pdm*128: out control, enap: out control, contclear: out port, 0 'pdm is determined in [InvertPDmodule] '[SettleDownTime]'needed:wate,glitch,glitchtime ; this slows the program for waittime=0 to (wate * 100)+(glitch*glitchtime) 'allows time for ckts to settle before data sampling next waittime glitch = 0 'reset glitch variable back to 0 '[ReadMagnitude]'needed: port,status ; creates: magdata (and phadata for 16 bit) if adconv = 8 then gosub [logData8Bitmag] 'and return here with magdata if adconv = 12 then gosub [logData12Bitmag] 'and return here with magdata if adconv = 16 then gosub [logData16Bit] 'and return here with magdata and phadata '[ReadPhase]'Read the voltage from the Phase Detector Module with the proper AtoD if vna = 0 then goto [ConvertAtoDbits] 'skip getting phase data if adconv = 8 then gosub [logData8Bitpha] 'and return here with phadata if adconv = 12 then gosub [logData12Bitpha] 'and return here with phadata if phadata/maxpdmout < .2 or phadata/maxpdmout > .8 then gosub [InvertPDmodule] 'data is near dead zone, invert the PDM phase to keep data linear 'returns here with new phadata(new magdata if 16 bit is used) and invdeg. phaseofpdm = val(using("####.##",(360*phadata/maxpdmout))) 'converts phadata bits to phase and round off to .01 degrees if pdm = 1 then phaseofpdm = phaseofpdm + invdeg 'invdeg is the actual inverted phase change if phaseofpdm > 360 then phaseofpdm = phaseofpdm - 360 if phaseofpdm > 180 then phaseofpdm = phaseofpdm - 360 'the phaseofpdm will be from -180 to +180 if calfwd = 1 then calarray(thisstep,2)= phaseofpdm 'this inserts the absolute phase into the calarray for phase reference phaseofpdm = phaseofpdm - calarray(thisstep,2) 'this gives the differential phase from calibration if phaseofpdm > 180 then phaseofpdm = phaseofpdm - 360 if phaseofpdm < -180 then phaseofpdm = phaseofpdm + 360 datatable(thisstep,3) = phaseofpdm 'put current phase measurement into the array, line value= thisstep 'convert phase to pixels thispointphase = maxscale * (phaseofpdm - botphase)/(topphase - botphase) if phaseofpdm >= topphase then thispointphase = maxscale if phaseofpdm <= botphase then thispointphase = 0 [ConvertAtoDbits] gosub [ConvertMagdataToPower]'needs: calibration table ; creates thispointpower if calfwd = 1 then calarray(thisstep,1)= thispointpower 'this inserts the power into the calarray for magnitude reference if vna = 1 then thispointpower = thispointpower - calarray(thisstep,1) 'this gives the differential power from calibration gosub [ConvertPowerToPixels]'needs:thispointpower,topref,botref ; creates thispointmag datatable(thisstep,0) = thisstep 'put current step number into the array, line value= thisstep datatable(thisstep,1) = thisfreq 'put current frequency into the array, line value= thisstep datatable(thisstep,2) = thispointpower 'put current power measurement into the array, line value= thisstep '[PlotDataOnGraph] if vna = 0 then gosub [PlotDataSA]'needs:thisstep,x,steps,rewrite,thispointx,y,thispointmag,lastpointx,lastpointy ; creates:lastpointx,lastpointy and plots magdata if vna = 1 then gosub [PlotDataVNA]'needed:thisstep,x,steps,rewrite,y,thispointmag,thispointphase ; plots magdata,phadata '[DetermineNextOperation] if varwindow = 1 then gosub [updatevar] print #main.hitkeybox, "!contents? stop$" 'look at "Hit any key" box, stop sweep if anything there if len(stop$)>0 then gosub [Halted] [IncrementOneStep] thisstep = thisstep + 1 'add 1 to step and continue sweeping if calfwd = 1 and thisstep > steps then calfwd = 0:beep:print #main.calibfwd, "Calibrated":print #main.hitkeybox, "end":wait if thisstep > steps then goto [SweepFromStartFreq] 'end of sweep, start over goto [CalculateNextStep] '----SubRoutines------ [InvertPDmodule]'Change Phase Det Module 180 degrees and take data again. if pdm = 0 then inv = 1 if pdm = 1 then inv = 0 out port, inv*128: out control, enap: out control, contclear: out port, 0 'commands the phase det module to invert 'The PDM needs time to settle after a phase change, play with following: for waittime = 0 to (wate * 100) 'The delay required, depends on the RC time constant of the Phase Det Module output next waittime '1 for "wate" seems good for .01 ufd as C1 if adconv = 8 then gosub [logData8Bitpha] 'and return here with phadata if adconv = 12 then gosub [logData12Bitpha] 'and return here with phadata if adconv = 16 then gosub [logData16Bit] 'and return here with phadata, and new magdata if inv = 0 then pdm = 0 if inv = 1 then pdm = 1 return 'with new phadata, and new magdata if using 16 bit [CalPDMinvdeg] beep pdm = 0 out port, pdm*128: out control, enap: out control, contclear: out port, 0 for waittime = 0 to 600000 next waittime if adconv = 8 then gosub [logData8Bitpha] 'and return here with phadata if adconv = 12 then gosub [logData12Bitpha] 'and return here with phadata if adconv = 16 then gosub [logData16Bit] 'and return here with phadata, and new magdata phadata0 = phadata pdm = 1 out port, pdm*128: out control, enap: out control, contclear: out port, 0 for waittime = 0 to 600000 next waittime if adconv = 8 then gosub [logData8Bitpha] 'and return here with phadata if adconv = 12 then gosub [logData12Bitpha] 'and return here with phadata if adconv = 16 then gosub [logData16Bit] 'and return here with phadata, and new magdata invdeg = val(using("####.##",(360*(phadata0-phadata)/maxpdmout))) print #main.invdegbox,invdeg beep print #main.hitkeybox, "Cald" wait [logData8Bitmag]'needed: port,status ; creates: magdata ' if inp(status) < 128 then wait (status bit 7) line is high (D/A 127 then wait line is low (magnitude voltage 63 then ack line is high (phase voltage>ladder) 'the data will always be 1 bit less than crossover region phadata = 0 out port, phadata + 128 'set D/A MSB to "1", creates 2.5v out of D/A ladder magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 128 out port, phadata + 64 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 64 out port, phadata + 32 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 32 out port, phadata + 16 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 16 out port, phadata + 8 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 8 out port, phadata + 4 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 4 out port, phadata + 2 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 2 out port, phadata + 1 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 1 out port, 0 'return data to zero return 'return, with phadata [logData12Bitmag]'needed: port,status ; creates: magdata ' if inp(status) < 128 then wait (status bit 7) line is high (D/A 127 then wait line is low (magnitude voltage 63 then ack line is high (phase voltage>ladder) ' if inp(status) < 64 then ack line is low (phase voltage 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 2048: word = word + 8 out port,word +4 +16 +32 ' put 4 into MSB latch, D/A = 1024 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 1024: word = word + 4 out port,word +2 +16 +32 ' put 2 into MSB latch, D/A = 512 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 512: word = word + 2 out port,word +1 +16 +32 ' put 1 into MSB latch, D/A = 256 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 256: word = word + 1 out port,word +16 +32 ' put appxm. into MSB latch, D/A = appx out port,word +16 +32 +64 ' latch MSB with appx word = 0 out port,8 +16 +64 ' put 8 into middle latch, D/A = 128 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 128: word = word + 8 out port,word +4 +16 +64 ' put 4 into middle latch, D/A = 64 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 64: word = word + 4 out port,word +2 +16 +64 ' put 2 into middle latch, D/A = 32 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 32: word = word + 2 out port,word +1 +16 +64 ' put 1 into middle latch, D/A = 16 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 16: word = word + 1 out port,word +16 +64 ' put appxm. into middle latch, D/A = appx out port,word +16 +32 +64 ' latch middle with appx word = 0 out port,8 +32 +64 ' put 8 into LSB latch, D/A = 8 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 8: word = word + 8 out port,word +4 +32 +64 ' put 4 into LSB latch, D/A = 4 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 4: word = word + 4 out port,word +2 +32 +64 ' put 2 into LSB latch, D/A = 2 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 2: word = word + 2 out port,word +1 +32 +64 ' put 1 into LSB latch, D/A = 1 magpha = inp(status) if magpha > 127 then magpha = magpha - 128 if magpha > 63 then phadata = phadata + 1 out port, 0 'return data to zero return ' return with phadata [logData16Bit]'needed: port,status ; creates: magdata,phadata (if two A/D's installed) 'MAG is WAIT, PHASE is ACK, SCLK is BD6, CVNis BD7. magdata = 0 phadata = 0 out port, 128 'take CVN high out port, 64 'CVN low, SCLK=1 d15 = inp(status) 'read data if d15>127 then d15=d15-128:magdata = magdata + 32768 'WAIT is low, MAG is high if d15<64 then phadata = phadata + 32768 'ACK is low, PHASE is high out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d14 = inp(status) if d14>127 then d14=d14-128:magdata = magdata + 16384 if d14<64 then phadata = phadata + 16384 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d13 = inp(status) if d13>127 then d13=d13-128:magdata = magdata + 8192 if d13<64 then phadata = phadata + 8192 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d12 = inp(status) if d12>127 then d12=d12-128:magdata = magdata + 4096 if d12<64 then phadata = phadata + 4096 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d11 = inp(status) if d11>127 then d11=d11-128:magdata = magdata + 2048 if d11<64 then phadata = phadata + 2048 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d10 = inp(status) if d10>127 then d10=d10-128:magdata = magdata + 1024 if d10<64 then phadata = phadata + 1024 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d9 = inp(status) if d9>127 then d9=d9-128:magdata = magdata + 512 if d9<64 then phadata = phadata + 512 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d8 = inp(status) if d8>127 then d8=d8-128:magdata = magdata + 256 if d8<64 then phadata = phadata + 256 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d7 = inp(status) if d7>127 then d7=d7-128:magdata = magdata + 128 if d7<64 then phadata = phadata + 128 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d6 = inp(status) if d6>127 then d6=d6-128:magdata = magdata + 64 if d6<64 then phadata = phadata + 64 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d5 = inp(status) if d5>127 then d5=d5-128:magdata = magdata + 32 if d5<64 then phadata = phadata + 32 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d4 = inp(status) if d4>127 then d4=d4-128:magdata = magdata + 16 if d4<64 then phadata = phadata + 16 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d3 = inp(status) if d3>127 then d3=d3-128:magdata = magdata + 8 if d3<64 then phadata = phadata + 8 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d2 = inp(status) if d2>127 then d2=d2-128:magdata = magdata + 4 if d2<64 then phadata = phadata + 4 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d1 = inp(status) if d1>127 then d1=d1-128:magdata = magdata + 2 if d1<64 then phadata = phadata + 2 out port, 0 'SCLK=0, next a/d data bit will change out port, 64 'SCLK=1 d0 = inp(status) if d0>127 then d0=d0-128:magdata = magdata + 1 if d0<64 then phadata = phadata + 1 out port, 0 'SCLK=0, a/d outputs go high z on 16th SCLK trailing edge return 'return, with magdata and phadata [ConvertMagdataToPower]'needed: calibration table ; creates thispointpower 'convert magnitude data bits to power, using cal table (in dBm at input to Log Detector) if magdata < minus130bits then power = maxpower-130 if magdata >= minus130bits and magdata = minus120bits and magdata = minus110bits and magdata = minus100bits and magdata = minus90bits and magdata = minus80bits and magdata = minus70bits and magdata = minus60bits and magdata = minus50bits and magdata = minus40bits and magdata = minus30bits and magdata = minus20bits and magdata = minus10bits and magdata = maxbits then power = maxpower if adconv = 8 then thispointpower = val(using("####.#",power))-gain 'round off power to .1 dB if adconv = 12 then thispointpower = val(using("####.##",power))-gain 'round off power to .01 dB if adconv = 16 then thispointpower = val(using("####.##",power))-gain 'round off power to .01 dB return [ConvertPowerToPixels]'needed:thispointpower,topref,botref ; creates thispointmag if thispointpower > topref then thispointmag = maxscale if thispointpower <= topref and thispointpower >= botref then thispointmag = maxscale*(thispointpower-botref)/(topref-botref) if thispointpower < botref then thispointmag = 0 return [PlotDataSA]'needed:thisstep,x,steps,rewrite,y,thispointmag,lastpointx,lastpointy ; creates:lastpointx,lastpointy and plots magdata thispointx = thisstep * x/steps 'establishes data point on the x-axis of graph (0 to 720) print #handle, "color white" 'quick way to clear trace if rewrite = 0 then print #handle, "line ";thispointx;" ";y;" ";thispointx;" ";y-275 'display a white line,hiding previous data points, during normal sweep print #handle, "color black" if rewrite = 0 then print #handle, "line ";thispointx;" ";y;" ";thispointx;" ";(y-1)-thispointmag 'display a data line during normal sweep if rewrite = 1 then print #handle, "line ";thispointx;" ";(y-1)-thispointmag;" ";lastpointx;" ";lastpointy 'connect the data dots during rewrite mode, one pixel higher than normal sweep if thisstep = marker1 then gosub [insertMarker]'and return here after inserting marker if thisstep = marker2 then gosub [insertMarker]'and return here after inserting marker if thisstep = marker3 then gosub [insertMarker]'and return here after inserting marker lastpointx = thispointx 'remember previous data point for next data take lastpointy = (y-1)-thispointmag return [insertMarker] 'display marker info (vertical line and data info) print #handle, "line ";thispointx;" ";(y-15)-thispointmag;" ";thispointx;" ";(y-2)-thispointmag print #handle, "line ";thispointx;" ";y+6;" ";thispointx;" ";y+10 if vna = 0 then print #handle, "\\"; thisfreq;" MHz\";magdata; " = bits\";thispointpower;" dBm" if vna = 1 then print #handle, "\\"; thisfreq;" MHz\";thispointpower;" dB\";phaseofpdm; " deg" return 'return to [PlotData] [PlotDataVNA]'needed:thisstep,x,steps,rewrite,y,thispointmag,thispointphase ; plots magdata,phadata previousstep = thisstep - 1 if previousstep < 0 then previousstep = 0 'this should keep the first step clean (step 0) thispointx = thisstep * x/steps 'establishes pixel point on the x-axis of graph (0 to 720) 'plot Magnitude newmagpixel = y-thispointmag print #handle, "color white" if rewrite = 0 then print #handle, "line ";magarray(previousstep,0);" ";magarray(previousstep,1);" ";thispointx;" ";magarray(thisstep,2) 'display a white line,from laststep old point to thisstep old point, covering up old line print #handle, "color blue" print #handle, "line ";magarray(previousstep,0);" ";magarray(previousstep,2);" ";thispointx;" ";newmagpixel magarray(thisstep,0) = thispointx 'this is the x-axis pixel value for this step, used in the next step as the previous step's x position magarray(thisstep,1) = magarray(thisstep,2) 'this is the previous sweep's y-axis pixel value at this step #, used in next step for clearing old trace magarray(thisstep,2) = newmagpixel 'this is the newest y-axis pixel value for this step, used in next step to extend new trace 'plot Phase print #handle, "color white" if rewrite = 0 then print #handle, "line ";magarray(previousstep,0);" ";phaarray(previousstep,1);" ";thispointx;" ";phaarray(thisstep,2) 'display a white line,from laststep old point to thisstep old point, covering up old line print #handle, "color red" newphapixel = y-thispointphase print #handle, "line ";magarray(previousstep,0);" ";phaarray(previousstep,2);" ";thispointx;" ";newphapixel phaarray(thisstep,1) = phaarray(thisstep,2) 'this is the previous sweep's y-axis pixel value at this step #, used in next step for clearing old trace phaarray(thisstep,2) = newphapixel 'this is the newest y-axis pixel value for this step, used in next step to extend new trace print #handle, "color black" if thisstep = marker1 then gosub [insertMarker]'and return here after inserting marker if thisstep = marker2 then gosub [insertMarker]'and return here after inserting marker if thisstep = marker3 then gosub [insertMarker]'and return here after inserting marker return [CommandPLL1R]'needed:rcounter1,PLL1mode,PLL1phasepolarity,enap,PLL1 rcounter = rcounter1 preselector = 32 : if PLL1mode = 1 then preselector = 16 phasepolarity = PLL1phasepolarity 'inverting op amp is 0, non-inverting loop is 1 fractional = PLL1mode '0 for Integer-N; 1 for Fractional-N Jcontrol = enap 'for PLL 1, on Control Board J1, the value is "3" LEPLL = 4 'for PLL 1, on Control Board J1, the value is "4" PLL = PLL1 gosub [CommandRBuffer]'needs:rcounter,preselector,phasepolarity,fractional,Jcontrol,LEPLL,PLL if len(errora$)>0 then error$ = "PLL 1, " + errora$:errora$ = "" return [CommandPLL2R]'needed:rcounter2,PLL2phasepolarity,enap,PLL2 rcounter = rcounter2 preselector = 32 phasepolarity = PLL2phasepolarity 'inverting op amp is 0, non-inverting loop is 1 fractional = 0 '0 for Integer-N; PLL 2 should not be fractional due to increased noise Jcontrol = enap 'for PLL 2, on Control Board J2, the value is "3" LEPLL = 8 'for PLL 2, on Control Board J2, the value is "8" PLL = PLL2 gosub [CommandRBuffer]'needs:rcounter,preselector,phasepolarity,fractional,Jcontrol,LEPLL,PLL if len(errora$)>0 then error$ = "PLL 2, " + errora$:errora$ = "" return [CommandPLL3R]'needed:rcounter3,PLL3mode,PLL3phasepolarity,enat,PLL3 rcounter = rcounter3 preselector = 32 : if PLL3mode = 1 then preselector = 16 phasepolarity = PLL3phasepolarity 'inverting op amp is 0, non-inverting loop is 1 fractional = PLL3mode '0 for Integer-N; 1 for Fractional-N Jcontrol = enat 'for Tracking Gen PLL, on Control Board J3, the value is "15" LEPLL = 16 'for Tracking Gen PLL, on Control Board J3, the value is "16" PLL = PLL3 gosub [CommandRBuffer]'needs:rcounter,preselector,phasepolarity,fractional,Jcontrol,LEPLL,PLL if len(errora$)>0 then error$ = "PLL 3, " + errora$:errora$ = "" return [CommandRBuffer]'needed:rcounter,preselector,phasepolarity,fractional,Jcontrol,LEPLL,PLL if PLL = 2325 then gosub [Command2325R]'needs:rcounter,preselector,Jcontrol,port,LEPLL,contclear ; commands LMX2325 rcounter and registers if PLL = 2326 then gosub [Command2326R]'needs:rcounter,phasepolarity,Jcontrol,port,LEPLL,contclear ; commands LMX2326 rcounter and registers if PLL = 2350 then gosub [Command2350R]'needs:rcounter,phasepolarity,Jcontrol,port,LEPLL,contclear,fractional ; commands LMX2350 rcounter if PLL = 2353 then gosub [Command2353R]'needs:rcounter,phasepolarity,Jcontrol,port,LEPLL,contclear,fractional ; commands LMX2353 rcounter if PLL = 4112 then gosub [Command4112R]'needs:rcounter,preselector,phasepolarity,Jcontrol,port,LEPLL,contclear ; commands AD4112 rcounter return [CreatePLL1asInteger]'needed:LO1,appxDDS,rcounter1 ; creates:ncounter1,fcounter1(0),pdf1,ddsoutput ncount1 = LO1/(appxDDS/rcounter1) 'approximates the Ncount for PLL 1 ncounter1 = int(ncount1) 'actual value for PLL1 Ncounter if ncount1 - ncounter1 >= .5 then ncounter1 = ncounter1 + 1 fcounter1 = 0 pdf1 = LO1/ncounter1 'actual phase freq of PLL1 ddsoutput = pdf1 * rcounter1 'actual output of DDS(input Ref to PLL1) return [CreatePLL1asFractional]'needed:LO1,appxDDS,rcounter1,spurcheck ; creates:ncounter1,fcounter1,pdf1,ddsoutput 'solve for Ncounter and ddsoutput, automatically check for spurs ncount1 = LO1/(appxDDS/rcounter1) 'approximates the Ncount for PLL 1. ver108 ncounter1 = int(ncount1) 'actual value for PLL1 Ncounter. ver108 fovercount1 = ncount1 - ncounter1 'ver108 fcounter1 = 10*val(using("##.#",fovercount1*16/10)) 'rev108 if fcounter1 = 16 then ncounter1 = ncounter1 + 1:fcounter1 = 0 'rev108 pdf1 = LO1/(ncounter1 + (fcounter1/16)) 'actual phase freq for PLL1. ver108 ddsoutput = pdf1 * rcounter1 'actual output of DDS(input Ref to PLL1). ver108 spur = 0 'reset spur, and determine if there is potential for a spur firstif = LO2 - finalfreq fractionalfreq = ddsoutput/(rcounter1*16) harnonicb = int(firstif/fractionalfreq) if (firstif/fractionalfreq)-harnonicb >=.5 then harnonicb = harnonicb + 1 'rev108 harnonica = harnonicb - 1 harnonicc = harnonicb + 1 firstiflow = LO2 - (finalfreq + finalbw/1000) firstifhigh = LO2 - (finalfreq - finalbw/1000) if harnonica*fractionalfreq > firstiflow and harnonica*fractionalfreq < firstifhigh then spur = 1 if harnonicb*fractionalfreq > firstiflow and harnonicb*fractionalfreq < firstifhigh then spur = 1 if harnonicc*fractionalfreq > firstiflow and harnonicc*fractionalfreq < firstifhigh then spur = 1 if spur = 1 and (ddsoutputappxDDS) then fcounter1 = fcounter1 + 1 if fcounter1 = 16 then ncounter1 = ncounter1 + 1:fcounter1 = 0 'rev108 if fcounter1 <0 then ncounter1 = ncounter1 - 1:fcounter1 = 15 'rev108 pdf1 = LO1/(ncounter1 + (fcounter1/16)) ddsoutput = pdf1 * rcounter1 'actual output of DDS(input Ref to PLL1) if spurcheck = 1 and (ddsoutputappxDDS) then fcounter1 = fcounter1 + 1 'causes -shift in pdf1 if fcounter1 = 16 then ncounter1 = ncounter1 + 1:fcounter1 = 0 'rev108 if fcounter1 < 0 then ncounter1 = ncounter1 - 1:fcounter1 = 15 'rev108 pdf1 = LO1/(ncounter1 + (fcounter1/16)) ddsoutput = pdf1 * rcounter1 'actual output of DDS(input Ref to PLL1) return [CommandPLL1N]'needed:ncounter1,fcounter1,PLL1mode,enap,PLL1 ; commands PLL NBuffer if (ncounter1 = lastncounter1) and (fcounter1 = lastfcounter1) then return 'cmd not needed glitch=1 'add delay to prevent PLL settling glitch ncounter = ncounter1 fcounter = fcounter1 preselector = 32 : if PLL1mode = 1 then preselector = 16 Jcontrol = enap 'for PLL 1, on Control Board J1, the value is "3" LEPLL = 4 'for PLL 1, on Control Board J1, the value is "4" PLL = PLL1 gosub [CommandNBuffer]'needs:ncounter,fcounter,preselector,Jcontrol,LEPLL,PLL if len(errora$)>0 then error$ = "PLL 1, " + errora$:errora$ = "" Bcounter1=Bcounter: Acounter1=Acounter lastncounter1 = ncounter1 'established comparison in above code lastfcounter1 = fcounter1 'established comparison in above code return [CommandPLL2N]'needed:ncounter,fcounter,enap,PLL2 preselector = 32 Jcontrol = enap 'for PLL 2, on Control Board J2, the value is "3" LEPLL = 8 'for PLL 2, on Control Board J2, the value is "8" PLL = PLL2 gosub [CommandNBuffer]'needs:ncounter,fcounter,preselector,Jcontrol,LEPLL,PLL if len(errora$)>0 then error$ = "PLL 2, " + errora$:errora$ = "" LO2=((Bcounter*preselector)+Acounter+(fcounter/16))*pdf2 return [CommandPLL3N]'needed:ncounter,fcounter,PLL3mode,enat,PLL3 preselector = 32 : if PLL3mode = 1 then preselector = 16 Jcontrol = enat 'for Tracking Gen PLL, on Control Board J3, the value is "15" LEPLL = 16 'for Tracking Gen PLL, on Control Board J3, the value is "16" PLL = PLL3 gosub [CommandNBuffer]'needs:ncounter,fcounter,preselector,Jcontrol,LEPLL,PLL if len(errora$)>0 then error$ = "PLL 3, " + errora$:errora$ = "" return [CommandNBuffer]'needed:ncounter,fcounter,preselector,Jcontrol,LEPLL,PLL if PLL = 2325 then gosub [Command2325N]'needs:ncounter,preselector,Jcontrol,port,LEPLL,contclear ; commands LMX2325 ncounter ; creates Bcounter,Acounter if PLL = 2326 then gosub [Command2326N]'needs:ncounter,Jcontrol,port,LEPLL,contclear ; commands LMX2326 ncounter ; creates Bcounter,Acounter if PLL = 2350 then gosub [Command2350N]'needs:ncounter,preselector,fcounter,Jcontrol,port,contclear,LEPLL ; commands LMX2350 ncounter ; creates Bcounter,Acounter if PLL = 2353 then gosub [Command2353N]'needs:ncounter,preselector,fcounter,Jcontrol,port,contclear,LEPLL ; commands LMX2353 ncounter ; creates Bcounter,Acounter if PLL = 4112 then gosub [Command4112N]'needs:ncounter,preselector,Jcontrol,port,contclear,LEPLL ; commands AD4112 ncounter ; creates Bcounter,Acounter return 'with Bcounter,Acounter [CreateIntegerNcounter]'needed:appxVCO,reference,rcounter ; creates:ncounter,fcounter(0) ncounter = int(appxVCO/(reference/rcounter)) 'approximates the ncounter for PLL if (appxVCO/(reference/rcounter)) - ncounter >= .5 then ncounter = ncounter + 1 'rounds off ncounter fcounter = 0 return [CreateFractionalNcounter]'needed:appxVCO,reference,rcounter ; creates:ncounter,fcounter ncount = appxVCO/(reference/rcounter) 'approximates the Ncount for PLL ncounter = int(ncount) 'actual value for PLL Ncounter fovercount = ncount - ncounter fcounter = 10*val(using("##.#",fovercount*16/10)) 'rounds off fcounter if fcounter = 16 then ncounter = ncounter + 1:fcounter = 0 return [Command2325R]'needed:rcounter,preselector,Jcontrol,port,LEPLL,contclear ; commands LMX2325 rcounter and registers if rcounter <3 then beep:errora$ = "2325 Rcounter is < 3" if rcounter >16383 then beep:errora$ = "2325 Rcounter is > 16383" r0 = 1 'control bit, 1 sets the r counter latch, 0 is for n counter rc1 = int(rcounter/2):r1 = rcounter - 2*rc1 'binary conversion from decimal rc2 = int(rc1/2):r2 = rc1 - 2*rc2 rc3 = int(rc2/2):r3 = rc2 - 2*rc3 rc4 = int(rc3/2):r4 = rc3 - 2*rc4 rc5 = int(rc4/2):r5 = rc4 - 2*rc5 rc6 = int(rc5/2):r6 = rc5 - 2*rc6 rc7 = int(rc6/2):r7 = rc6 - 2*rc7 rc8 = int(rc7/2):r8 = rc7 - 2*rc8 rc9 = int(rc8/2):r9 = rc8 - 2*rc9 rc10 = int(rc9/2):r10 = rc9 - 2*rc10 rc11 = int(rc10/2):r11 = rc10 - 2*rc11 rc12 = int(rc11/2):r12 = rc11 - 2*rc12 rc13 = int(rc12/2):r13 = rc12 - 2*rc13 rc14 = int(rc13/2):r14 = rc13 - 2*rc14 r15 = 1: if preselector = 64 then r15 = 0 'sets preselector divide ratio, 1=32, 0=64 out control, Jcontrol 'enable Control Board J connector out port, r15:out port, r15 + 2 'data valid, data valid and clock high out port, r14:out port, r14 + 2 'data valid and clock low, data valid and clock high out port, r13:out port, r13 + 2 'etc out port, r12:out port, r12 + 2 'etc out port, r11:out port, r11 + 2 'etc out port, r10:out port, r10 + 2 'etc out port, r9:out port, r9 + 2 'etc out port, r8:out port, r8 + 2 'etc out port, r7:out port, r7 + 2 'etc out port, r6:out port, r6 + 2 'etc out port, r5:out port, r5 + 2 'etc out port, r4:out port, r4 + 2 'etc out port, r3:out port, r3 + 2 'etc out port, r2:out port, r2 + 2 'etc out port, r1:out port, r1 + 2 'etc out port, r0:out port, r0 + 2 'last data valid and clock low, last data valid and clock high out port, LEPLL:out port, 0 'last data low and clock low and LE high, all control lines low out control, contclear 'Disable Control Board J connector return [Command2325N]'needed:ncounter,preselector,Jcontrol,port,LEPLL,contclear ; commands LMX2325 ncounter Bcounter = int(ncounter/preselector) Acounter = ncounter- (Bcounter * preselector) if Bcounter<3 then beep:errora$ = "2325 Bcounter < 3" if Bcounter>2047 then beep:errora$ = "2325 Bcounter > 2047" if Bcounter16383 then beep:errora$="2326 R counter >16383" r1 = 0 'R address bit 0, must be 0 r2 = 0 'R address vit 1, must be 0 ra0 = int(rcounter/2):r3 = rcounter- 2*ra0 'LSB R0 ra1 = int(ra0/2):r4 = ra0- 2*ra1 ra2 = int(ra1/2):r5 = ra1- 2*ra2 ra3 = int(ra2/2):r6 = ra2- 2*ra3 ra4 = int(ra3/2):r7 = ra3- 2*ra4 ra5 = int(ra4/2):r8 = ra4- 2*ra5 ra6 = int(ra5/2):r9 = ra5- 2*ra6 ra7 = int(ra6/2):r10 = ra6- 2*ra7 ra8 = int(ra7/2):r11 = ra7- 2*ra8 ra9 = int(ra8/2):r12 = ra8- 2*ra9 ra10 = int(ra9/2):r13 = ra9- 2*ra10 ra11 = int(ra10/2):r14 = ra10- 2*ra11 ra12 = int(ra11/2):r15 = ra11- 2*ra12 ra13 = int(ra12/2):r16 = ra12- 2*ra13 'MSB r17 = 0 'Test Bit r18 = 0 'Test Bit r19 = 0 'Test Bit r20 = 0 'Test Bit r21 = 0 'Lock Detector Mode, 0=3 refcycles, 1=5 cycles '[Command2326Rbuffer]'need Jcontrol,LEPLL,contclear out control, Jcontrol 'Enable the Control Board J connector out port, r21:out port, r21 + 2:out port, r20:out port, r20 + 2 out port, r19:out port, r19 + 2:out port, r18:out port, r18 + 2 out port, r17:out port, r17 + 2:out port, r16:out port, r16 + 2 out port, r15:out port, r15 + 2:out port, r14:out port, r14 + 2 out port, r13:out port, r13 + 2:out port, r12:out port, r12 + 2 out port, r11:out port, r11 + 2:out port, r10:out port, r10 + 2 out port, r9:out port, r9 + 2:out port, r8:out port, r8 + 2 out port, r7:out port, r7 + 2:out port, r6:out port, r6 + 2 out port, r5:out port, r5 + 2:out port, r4:out port, r4 + 2 out port, r3:out port, r3 + 2:out port, r2:out port, r2 + 2 out port, r1:out port, r1 + 2:out port, LEPLL:out port, 0 'Latch buffer out control, contclear 'Disable the Control Board J connector return [Command2326N]'needed:ncounter,Jcontrol,port,LEPLL,contclear ; commands LMX2326 ncounter 'need ncounter,Jcontrol,LEPLL,contclear Bcounter = int(ncounter/32) Acounter = int(ncounter-(Bcounter*32)) if Bcounter < 3 then beep:errora$="2326 B counter <3" if Bcounter > 8191 then beep:errora$="2326 B counter >8191" if Bcounter < Acounter then beep:errora$="2326 B counter 32767 then beep:errora$="2350 Rcounter >32767" rfr0=0 '2350 RF_R register, 2 bits, must be 0 rfr1=1 '2350 RF_R register, 2 bits, must be 1 rfra2 = int(rcounter/2):rfr2 = rcounter- 2*rfra2 rfra3 = int(rfra2/2):rfr3 = rfra2- 2*rfra3 rfra4 = int(rfra3/2):rfr4 = rfra3- 2*rfra4 rfra5 = int(rfra4/2):rfr5 = rfra4- 2*rfra5 rfra6 = int(rfra5/2):rfr6 = rfra5- 2*rfra6 rfra7 = int(rfra6/2):rfr7 = rfra6- 2*rfra7 rfra8 = int(rfra7/2):rfr8 = rfra7- 2*rfra8 rfra9 = int(rfra8/2):rfr9 = rfra8- 2*rfra9 rfra10 = int(rfra9/2):rfr10 = rfra9- 2*rfra10 rfra11 = int(rfra10/2):rfr11 = rfra10- 2*rfra11 rfra12 = int(rfra11/2):rfr12 = rfra11- 2*rfra12 rfra13 = int(rfra12/2):rfr13 = rfra12- 2*rfra13 rfra14 = int(rfra13/2):rfr14 = rfra13- 2*rfra14 rfra15 = int(rfra14/2):rfr15 = rfra14- 2*rfra15 rfra16 = int(rfra15/2):rfr16 = rfra15- 2*rfra16 rfr17 = phasepolarity 'RF phase polarity, 1=positive action, 0=inverted action rfr18=1 'LSB of RF charge pump sel, 4 Bits, 16 levels, 100ua/level rfr19=1 'total current = (100ua * bit value)+100ua rfr20=1 '100ua to 1600ua: ie, 800ua = 0111, 1600ua = 1111 rfr21=1 'MSB of RF charge pump sel, 4 Bits 100ua/bit rfr22=0 'V2 enable voltage doubler =1 0=norm Vcc rfr23 = fractional 'DLL mode, delay line cal, 0=slow 1=fast,fractional mode '[CreateIFRbuffer2350]'IF section is turned off ifr23=0 'osc. 0=separate ifr22=1 'Modulo F, 1=16 0=15 ifr21=1 'ifr21-ifr19 is FO/LD, 3 Bits (0-7), MSB, 0=IF/RF alogLockDet(open drain) ifr20=1 '1=IF digLockDet, 2=RF digLockDet, 3=IF/RF digLockDet ifr19=1 '4=IF Rcntr, 5=IF Ncntr, 6=RF Rcntr, 7=RF Ncntr, LSB ifr18=0 'IF charge pump, 0=100ua 1=800ua ifr17=1 'IF polarity 1=positive phase action ifr16=0 'IFR counter IF section 15 Bits, MSB 14 ifr15=0 'IFRcounter Bit 13 ifr14=0 'IFRcounter Bit 12 ifr13=0 'IFRcounter Bit 11 ifr12=1 'IFRcounter Bit 10 ifr11=1 'IFRcounter Bit 9 ifr10=1 'IFRcounter Bit 8 ifr9=1 'IFRcounter Bit 7 ifr8=0 'IFRcounter Bit 6 ifr7=1 'IFRcounter Bit 5 ifr6=1 'IFRcounter Bit 4 ifr5=0 'IFRcounter Bit 3 ifr4=0 'IFRcounter Bit 2 ifr3=0 'IFRcounter Bit 1 ifr2=0 'IFR counter, IF section 15 Bits, LSB 0 ifr1=0 '2350 IF_R register, 2 bits, must be 0 ifr0=0 '2350 IF_R register, 2 bits, must be 0 '[CreateIFNbuffer2350]'IF section is turned off(ifn22=1) ifn23=0 'IF counter reset, 0=normal operation ifn22=1 'Power down mode for IF section, 1=powered down, 0=powered up ifn21=0 'PWN Mode, 0=async 1=syncro ifn20=0 'Fastlock, 0=CMOS outputs enabled 1= fastlock mode ifn19=0 'test bit, leave at 0 ifn18=1 'OUT 0, 1 ifn17=0 'OUT 1, 0 ifn16=0 'IF N Bcounter 12 Bits MSB bit 11 ifn15=0 'IF N Bcounter, bit 10, '512 = 0010 0000 0000 ifn14=1 'IF N Bcounter, bit 9 ifn13=0 'IF N Bcounter, bit 8 ifn12=0 'IF N Bcounter, bit 7 ifn11=0 'IF N Bcounter, bit 6 ifn10=0 'IF N Bcounter, bit 5 ifn9=0 'IF N Bcounter, bit 4 ifn8=0 'IF N Bcounter, bit 3 ifn7=0 'IF N Bcounter, bit 2 ifn6=0 'IF N Bcounter, bit 1 ifn5=0 'IF N Bcounter, 12 Bits, LSB bit 0 ifn4=0 'bit 2, IF N Acounter 3 Bits MSB ifn3=0 'bit 1, 0 = 000 thru 7 = 111 ifn2=0 'bit 0, IF N Acounter 3 Bits LSB ifn1=0 '2350 IF_N register, 2 bits, must be 0 ifn0=1 '2350 IF_N register, 2 bits, must be 1 '[CommandIFRbuffer2350] out control, Jcontrol 'enable the Control Board J connector out port, ifr23:out port, ifr23 + 2:out port, ifr22:out port, ifr22 + 2 out port, ifr21:out port, ifr21 + 2:out port, ifr20:out port, ifr20 + 2 out port, ifr19:out port, ifr19 + 2:out port, ifr18:out port, ifr18 + 2 out port, ifr17:out port, ifr17 + 2:out port, ifr16:out port, ifr16 + 2 out port, ifr15:out port, ifr15 + 2:out port, ifr14:out port, ifr14 + 2 out port, ifr13:out port, ifr13 + 2:out port, ifr12:out port, ifr12 + 2 out port, ifr11:out port, ifr11 + 2:out port, ifr10:out port, ifr10 + 2 out port, ifr9:out port, ifr9 + 2:out port, ifr8:out port, ifr8 + 2 out port, ifr7:out port, ifr7 + 2:out port, ifr6:out port, ifr6 + 2 out port, ifr5:out port, ifr5 + 2:out port, ifr4:out port, ifr4 + 2 out port, ifr3:out port, ifr3 + 2:out port, ifr2:out port, ifr2 + 2 out port, ifr1:out port, ifr1 + 2:out port, ifr0:out port, ifr0 + 2 out port, LEPLL:out port, 0 'this is the latch bit(LE up, then down) '[CommandIFNbuffer2350]'note, the Jcontrol is still set high out port, ifn23:out port, ifn23 + 2:out port, ifn22:out port, ifn22 + 2 out port, ifn21:out port, ifn21 + 2:out port, ifn20:out port, ifn20 + 2 out port, ifn19:out port, ifn19 + 2:out port, ifn18:out port, ifn18 + 2 out port, ifn17:out port, ifn17 + 2:out port, ifn16:out port, ifn16 + 2 out port, ifn15:out port, ifn15 + 2:out port, ifn14:out port, ifn14 + 2 out port, ifn13:out port, ifn13 + 2:out port, ifn12:out port, ifn12 + 2 out port, ifn11:out port, ifn11 + 2:out port, ifn10:out port, ifn10 + 2 out port, ifn9:out port, ifn9 + 2:out port, ifn8:out port, ifn8 + 2 out port, ifn7:out port, ifn7 + 2:out port, ifn6:out port, ifn6 + 2 out port, ifn5:out port, ifn5 + 2:out port, ifn4:out port, ifn4 + 2 out port, ifn3:out port, ifn3 + 2:out port, ifn2:out port, ifn2 + 2 out port, ifn1:out port, ifn1 + 2:out port, ifn0:out port, ifn0 + 2 out port, LEPLL:out port, 0 'this is the latch bit(LE up, then down) '[CommandRFRbuffer2350]'note, the Jcontrol is still set high out port, rfr23:out port, rfr23 + 2:out port, rfr22:out port, rfr22 + 2 out port, rfr21:out port, rfr21 + 2:out port, rfr20:out port, rfr20 + 2 out port, rfr19:out port, rfr19 + 2:out port, rfr18:out port, rfr18 + 2 out port, rfr17:out port, rfr17 + 2:out port, rfr16:out port, rfr16 + 2 out port, rfr15:out port, rfr15 + 2:out port, rfr14:out port, rfr14 + 2 out port, rfr13:out port, rfr13 + 2:out port, rfr12:out port, rfr12 + 2 out port, rfr11:out port, rfr11 + 2:out port, rfr10:out port, rfr10 + 2 out port, rfr9:out port, rfr9 + 2:out port, rfr8:out port, rfr8 + 2 out port, rfr7:out port, rfr7 + 2:out port, rfr6:out port, rfr6 + 2 out port, rfr5:out port, rfr5 + 2:out port, rfr4:out port, rfr4 + 2 out port, rfr3:out port, rfr3 + 2:out port, rfr2:out port, rfr2 + 2 out port, rfr1:out port, rfr1 + 2:out port, rfr0:out port, rfr0 + 2 out port, LEPLL:out port, 0 'this is the latch bit(LE up, then down) out control, contclear 'Disable the Control Board J connector return [Command2350N]'needed: ncounter,preselector,fcounter,Jcontrol,port,contclear,LEPLL ; commands LMX2350 ncounter '[CreateRFNbuffer2350] Bcounter = int(ncounter/preselector) Acounter = int(ncounter-(Bcounter*preselector)) if Bcounter < 3 then beep:errora$="2350 Bcounter <3" if Bcounter > 1023 then beep:errora$="2350 Bcounter >1023" if Bcounter < Acounter + 2 then beep:errora$="2350 Bcounter32767 then beep:errora$ = "2353 Rcounter is > 32767" rbit0 = 0 'R address bit 0 rbit1 = 1 'R address bit 1 ra0 = int(rcounter/2):rbit2 = rcounter- 2*ra0 'LSB R buffer ra1 = int(ra0/2):rbit3 = ra0- 2*ra1:ra2 = int(ra1/2):rbit4 = ra1- 2*ra2 ra3 = int(ra2/2):rbit5 = ra2- 2*ra3:ra4 = int(ra3/2):rbit6 = ra3- 2*ra4 ra5 = int(ra4/2):rbit7 = ra4- 2*ra5:ra6 = int(ra5/2):rbit8 = ra5- 2*ra6 ra7 = int(ra6/2):rbit9 = ra6- 2*ra7:ra8 = int(ra7/2):rbit10 = ra7- 2*ra8 ra9 = int(ra8/2):rbit11 = ra8- 2*ra9:ra10 = int(ra9/2):rbit12 = ra9- 2*ra10 ra11 = int(ra10/2):rbit13 = ra10- 2*ra11:ra12 = int(ra11/2):rbit14 = ra11- 2*ra12 ra13 = int(ra12/2):rbit15 = ra12- 2*ra13:ra14 = int(ra13/2):rbit16 = ra13- 2*ra14 'MSB R buffer rbit17 = phasepolarity 'phase detector polarity 1=normal,0=reverse for opamp rbit18 = 1 'LSB of Charge pump control, 100ua x1 +100ua rbit19 = 1 'Charge pump control, 100ua x2 +100ua rbit20 = 1 'Charge pump control, 100ua x4 +100ua rbit21 = 1 'MSB of Charge pump control, 100ua x8 +100ua rbit22 = 0 'Charge Pump Voltage Doubler Enabled when 1 rbit23 = fractional 'Delay Line Loop Cal mode, set to 1 for fractional N '[Create2353F1Buffer]'globals reqd, none f1bit23=0 f1bit22=1 'divider, 1=16 0=15 f1bit21=0 'FO/LD output selection, 3 Bits 0-7 MSB f1bit20=0 '0=alog lock det, 2=dig lock det f1bit19=0 '6=Ndivider output, 7=Rdivider output f1bit18=0:f1bit17=0:f1bit16=0:f1bit15=0:f1bit14=0 f1bit13=0:f1bit12=0:f1bit11=0:f1bit10=0:f1bit9=0 f1bit8=0:f1bit7=0:f1bit6=0:f1bit5=0:f1bit4=0 f1bit3=0:f1bit2=0 f1bit1=0 'F1 address bit 1 f1bit0=0 'F1 address bit 0 '[Create2353F2Buffer]'globals reqd: none f2bit23=0:f2bit22=0 f2bit21=0 'Power Down Mode, 0=async 1=syncro f2bit20=0 'Fastlock, 0=CMOS outputs enabled 1= fastlock mode f2bit19=0 'test bit, leave at 0 f2bit18=0 'OUT 1, 0 f2bit17=0 'OUT 0, 0 f2bit16=0:f2bit15=0:f2bit14=0:f2bit13=0 f2bit12=0:f2bit11=0:f2bit10=0:f2bit9=0 f2bit8=0:f2bit7=0:f2bit6=0:f2bit5=0 f2bit4=0:f2bit3=0:f2bit2=0 f2bit1=0 'F2 address bit 1 f2bit0=1 'F2 address bit 0 '[CommandF1Buffer] out control, Jcontrol 'enable the clk,data,and LE buffer out port, f1bit23:out port, f1bit23 + 2:out port, f1bit22:out port, f1bit22 + 2 out port, f1bit21:out port, f1bit21 + 2:out port, f1bit20:out port, f1bit20 + 2 out port, f1bit19:out port, f1bit19 + 2:out port, f1bit18:out port, f1bit18 + 2 out port, f1bit17:out port, f1bit17 + 2:out port, f1bit16:out port, f1bit16 + 2 out port, f1bit15:out port, f1bit15 + 2:out port, f1bit14:out port, f1bit14 + 2 out port, f1bit13:out port, f1bit13 + 2:out port, f1bit12:out port, f1bit12 + 2 out port, f1bit11:out port, f1bit11 + 2:out port, f1bit10:out port, f1bit10 + 2 out port, f1bit9:out port, f1bit9 + 2:out port, f1bit8:out port, f1bit8 + 2 out port, f1bit7:out port, f1bit7 + 2:out port, f1bit6:out port, f1bit6 + 2 out port, f1bit5:out port, f1bit5 + 2:out port, f1bit4:out port, f1bit4 + 2 out port, f1bit3:out port, f1bit3 + 2:out port, f1bit2:out port, f1bit2 + 2 out port, f1bit1:out port, f1bit1 + 2:out port, f1bit0:out port, f1bit0 + 2 out port, LEPLL:out port, 0 'Latch buffer '[CommandF2Buffer] 'note,Jcontrol is still high out port, f2bit23:out port, f2bit23 + 2:out port, f2bit22:out port, f2bit22 + 2 out port, f2bit21:out port, f2bit21 + 2:out port, f2bit20:out port, f2bit20 + 2 out port, f2bit19:out port, f2bit19 + 2:out port, f2bit18:out port, f2bit18 + 2 out port, f2bit17:out port, f2bit17 + 2:out port, f2bit16:out port, f2bit16 + 2 out port, f2bit15:out port, f2bit15 + 2:out port, f2bit14:out port, f2bit14 + 2 out port, f2bit13:out port, f2bit13 + 2:out port, f2bit12:out port, f2bit12 + 2 out port, f2bit11:out port, f2bit11 + 2:out port, f2bit10:out port, f2bit10 + 2 out port, f2bit9:out port, f2bit9 + 2:out port, f2bit8:out port, f2bit8 + 2 out port, f2bit7:out port, f2bit7 + 2:out port, f2bit6:out port, f2bit6 + 2 out port, f2bit5:out port, f2bit5 + 2:out port, f2bit4:out port, f2bit4 + 2 out port, f2bit3:out port, f2bit3 + 2:out port, f2bit2:out port, f2bit2 + 2 out port, f2bit1:out port, f2bit1 + 2:out port, f2bit0:out port, f2bit0 + 2 out port, LEPLL:out port, 0 'Latch buffer '[CmdRbuffer] 'note,Jcontrol is still high out port, rbit23:out port, rbit23 + 2:out port, rbit22:out port, rbit22 + 2 out port, rbit21:out port, rbit21 + 2:out port, rbit20:out port, rbit20 + 2 out port, rbit19:out port, rbit19 + 2:out port, rbit18:out port, rbit18 + 2 out port, rbit17:out port, rbit17 + 2:out port, rbit16:out port, rbit16 + 2 out port, rbit15:out port, rbit15 + 2:out port, rbit14:out port, rbit14 + 2 out port, rbit13:out port, rbit13 + 2:out port, rbit12:out port, rbit12 + 2 out port, rbit11:out port, rbit11 + 2:out port, rbit10:out port, rbit10 + 2 out port, rbit9:out port, rbit9 + 2:out port, rbit8:out port, rbit8 + 2 out port, rbit7:out port, rbit7 + 2:out port, rbit6:out port, rbit6 + 2 out port, rbit5:out port, rbit5 + 2:out port, rbit4:out port, rbit4 + 2 out port, rbit3:out port, rbit3 + 2:out port, rbit2:out port, rbit2 + 2 out port, rbit1:out port, rbit1 + 2:out port, rbit0:out port, rbit0 + 2 out port, LEPLL:out port, 0 'Latch buffer out control, contclear 'Disable the Control Board J connector return [Command2353N]'needed: ncounter,preselector,fcounter,Jcontrol,port,contclear,LEPLL ; commands LMX2353 ncounter '[Create2353Nbuffer] Bcounter = int(ncounter/preselector) Acounter = int(ncounter-(Bcounter*preselector)) if Bcounter < 3 then beep:errora$ = "2353 Bcounter is < 3" if Bcounter > 1023 then beep:errora$ = "2353 Bcounter is > 1023" if Bcounter < Acounter + 2 then beep:errora$ = "2353 Bcounter < Acounter+2" 'ver108 nbit0 = 1 'n address bit 0 nbit1 = 1 'n address bit 1 f0 = int(fcounter/2):nbit2 = fcounter - 2*f0 'fcounter bit 0 f1 = int(f0/2):nbit3 = f0 - 2*f1 'fcounter bit 1 f2 = int(f1/2):nbit4 = f1 - 2*f2 'fcounter bit 2 f3 = int(f2/2):nbit5 = f2 - 2*f3 'fcounter bit 3 (0 to 15) na0 = int(Acounter/2):nbit6 = Acounter- 2*na0 'Acounter bit 0 LSB na1 = int(na0/2):nbit7 = na0 - 2*na1 na2 = int(na1/2):nbit8 = na1 - 2*na2 na3 = int(na2/2):nbit9 = na2 - 2*na3 na4 = int(na3/2):nbit10 = na3 - 2*na4 'Acounter bit 4 MSB nb0 = int(Bcounter/2):nbit11 = Bcounter- 2*nb0 'Bcounter bit 0 LSB nb1 = int(nb0/2):nbit12 = nb0 - 2*nb1 nb2 = int(nb1/2):nbit13 = nb1 - 2*nb2 nb3 = int(nb2/2):nbit14 = nb2 - 2*nb3 nb4 = int(nb3/2):nbit15 = nb3 - 2*nb4 nb5 = int(nb4/2):nbit16 = nb4 - 2*nb5 nb6 = int(nb5/2):nbit17 = nb5 - 2*nb6 nb7 = int(nb6/2):nbit18 = nb6 - 2*nb7 nb8 = int(nb7/2):nbit19 = nb7 - 2*nb8 nb9 = int(nb8/2):nbit20 = nb8 - 2*nb9 'Bcounter bit 9 MSB nbit21 = 0 :if preselector = 32 then nbit21 = 1 '0=16/17 1=32/33 nbit22 = 0 'power down if 1 nbit23 = 0 'counter reset if 1 '[Command2353NBuffer] out control, Jcontrol 'enable Control Board J connector out port, nbit23:out port, nbit23 + 2:out port, nbit22:out port, nbit22 + 2 out port, nbit21:out port, nbit21 + 2:out port, nbit20:out port, nbit20 + 2 out port, nbit19:out port, nbit19 + 2:out port, nbit18:out port, nbit18 + 2 out port, nbit17:out port, nbit17 + 2:out port, nbit16:out port, nbit16 + 2 out port, nbit15:out port, nbit15 + 2:out port, nbit14:out port, nbit14 + 2 out port, nbit13:out port, nbit13 + 2:out port, nbit12:out port, nbit12 + 2 out port, nbit11:out port, nbit11 + 2:out port, nbit10:out port, nbit10 + 2 out port, nbit9:out port, nbit9 + 2:out port, nbit8:out port, nbit8 + 2 out port, nbit7:out port, nbit7 + 2:out port, nbit6:out port, nbit6 + 2 out port, nbit5:out port, nbit5 + 2:out port, nbit4:out port, nbit4 + 2 out port, nbit3:out port, nbit3 + 2:out port, nbit2:out port, nbit2 + 2 out port, nbit1:out port, nbit1 + 2:out port, nbit0:out port, nbit0 + 2 out port, LEPLL:out port, 0 'Latch buffer out control, contclear 'disable Control Board J connector return [Command4112R]'needed: rcounter,preselector,phasepolarity,Jcontrol,port,LEPLL,contclear ; commands AD4112 rcounter '[Create4112InitBuffer] I24=1 'I24,23 prescaler: 0=8, 1=16, 2=32, 3=64 I23=0 'preselector defaulted to 32 if preselector =8 then I24=0:I23=0 if preselector =16 then I24=0:I23=1 if preselector =64 then I24=1:I23=1 I22=0 'Power Down Mode, 0=async, 1=sync use 0 I21=1 'I22,21,20 Phase Current for Set 2 I20=1 'current= min current + min current*bit value I19=1 'use bit value of 7 and 4.7 Kohm for 5.0 ma I18=1 'I18,17,16 Phase Current for Set 1 I17=1 'current= min current + min current*bit value I16=1 'use bit value of 7 and 4.7 Kohm for 5.0 ma I15=0 'I15,14,13,12 Fastlock Timer cycles I14=0 '4 Bits, Cycles= 3 cycles + 4*bit value I13=0 'Fastlock Time out value, use 0 I12=0 'use 4 bit value = 0 I11=0 '0=Fastlock Mode 1 (command), 1=Mode 2 (automatic) I10=0 '1=Fastlock enabled, 0 =Fastlock Disabled I9=0 '1=Tristate the phase det output, use 0 I8 = phasepolarity 'Phase det polarity, 1=pos 0=neg I7=0 'FoLD control(pin14 output), 0= tristate, 1= Digital Lock Detect I6=0 '2= N Divider out, 3= High output, 4= R Divider output I5=0 '5= Open drain lock detect, 6= Serial Data output, 7= Low output I4=0 'PD1, Power Down, 0=normal operation, 1=select power down mode I3=0 '1= Counter Reset Enable, allows reset of R,N counters,use 0 I2=1 'F1 address bit 1, must be 1 I1=1 'F1 address bit 0, must be 1 '[Command4112InitBuffer] out control, Jcontrol 'Enable the Control Board clk,data,and LE buffer out port, I24:out port, I24 + 2 out port, I23:out port, I23 + 2:out port, I22:out port, I22 + 2 out port, I21:out port, I21 + 2:out port, I20:out port, I20 + 2 out port, I19:out port, I19 + 2:out port, I18:out port, I18 + 2 out port, I17:out port, I17 + 2:out port, I16:out port, I16 + 2 out port, I15:out port, I15 + 2:out port, I14:out port, I14 + 2 out port, I13:out port, I13 + 2:out port, I12:out port, I12 + 2 out port, I11:out port, I11 + 2:out port, I10:out port, I10 + 2 out port, I9:out port, I9 + 2:out port, I8:out port, I8 + 2 out port, I7:out port, I7 + 2:out port, I6:out port, I6 + 2 out port, I5:out port, I5 + 2:out port, I4:out port, I4 + 2 out port, I3:out port, I3 + 2:out port, I2:out port, I2 + 2 out port, I1:out port, I1 + 2:out port, LEPLL:out port, 0 'Latch buffer out control, contclear 'Disable the Control Board clk,data,and LE buffer '[Create4112Rbuffer] if rcounter >16383 then beep:errora$="4112 R counter >16383" r1 = 0 'R address bit 0, must be 0 r2 = 0 'R address vit 1, must be 0 ra0 = int(rcounter/2):r3 = rcounter- 2*ra0 'LSB R0 ra1 = int(ra0/2):r4 = ra0- 2*ra1 ra2 = int(ra1/2):r5 = ra1- 2*ra2 ra3 = int(ra2/2):r6 = ra2- 2*ra3 ra4 = int(ra3/2):r7 = ra3- 2*ra4 ra5 = int(ra4/2):r8 = ra4- 2*ra5 ra6 = int(ra5/2):r9 = ra5- 2*ra6 ra7 = int(ra6/2):r10 = ra6- 2*ra7 ra8 = int(ra7/2):r11 = ra7- 2*ra8 ra9 = int(ra8/2):r12 = ra8- 2*ra9 ra10 = int(ra9/2):r13 = ra9- 2*ra10 ra11 = int(ra10/2):r14 = ra10- 2*ra11 ra12 = int(ra11/2):r15 = ra11- 2*ra12 ra13 = int(ra12/2):r16 = ra12- 2*ra13 'MSB r17 = 0 'r17,16 Antibacklash width r18 = 0 '0=3ns, 1=1.5ns, 2=6ns, 3=3ns r19 = 0 'Test Bit, use 0 r20 = 0 'Test Bit, use 0 r21 = 0 'Lock Detector Mode, 0=3 refcycles, 1=5 cycles r22 = 0 'resyncronization enable 0=normal, 1=resync prescaler r23 = 1 '0=resync with nondelayed rf input, 1=resync with delayed rf r24 = 0 'reserved, use 0 '[Command4112Rbuffer] out control, Jcontrol 'Enable the Control Board clk,data,and LE buffer out port, r24:out port, r24 + 2 out port, r23:out port, r23 + 2:out port, r22:out port, r22 + 2 out port, r21:out port, r21 + 2:out port, r20:out port, r20 + 2 out port, r19:out port, r19 + 2:out port, r18:out port, r18 + 2 out port, r17:out port, r17 + 2:out port, r16:out port, r16 + 2 out port, r15:out port, r15 + 2:out port, r14:out port, r14 + 2 out port, r13:out port, r13 + 2:out port, r12:out port, r12 + 2 out port, r11:out port, r11 + 2:out port, r10:out port, r10 + 2 out port, r9:out port, r9 + 2:out port, r8:out port, r8 + 2 out port, r7:out port, r7 + 2:out port, r6:out port, r6 + 2 out port, r5:out port, r5 + 2:out port, r4:out port, r4 + 2 out port, r3:out port, r3 + 2:out port, r2:out port, r2 + 2 out port, r1:out port, r1 + 2:out port, LEPLL:out port, 0 'Latch buffer out control, contclear 'Disable the Control Board clk,data,and LE buffer return '[endCommand4112R] [Command4112N]'needed: ncounter,preselector,Jcontrol,port,contclear,LEPLL ; commands AD4112 ncounter Bcounter = int(ncounter/preselector) Acounter = int(ncounter-(Bcounter*preselector)) if Bcounter < 3 then beep:errora$="4112 N counter <3" if Bcounter > 8191 then beep:errora$="4112 N counter >8191" if Bcounter < Acounter then beep:errora$="4112 B counter=.5 then base = base + 1 return [ResetParallelDDS]'needed:control,wclkfqud,contclear ; resets DDS on J5, parallel out control, wclkfqud 'wclk and fqud lines high out control, contclear 'wclk and fqud lines low (all control lines low) return [ResetSerialDDS]'needed:port,control,Jcontrol,swclk,fqud,contclear ; resets DDS, serially out control, Jcontrol 'enable Control Board J connector out port, swclk:out port, 0 ' DDSpin9, swclk up, DDS swclk down out port, fqud:out port, 0 ' DDSpin8, FQUD up, FQUD down. DDS will go to 0 Hz. out control, contclear 'disable Control Board J connector return [DDScommandParallel]'needed:base,word0,port,control,wclk,fqud,contclear ; commands DDS on J5, parallel w1= int(base/2^24) 'w1 thru w4 converts decimal base code to 4 words, each are 8 bit binary w2= int((base-(w1*2^24))/2^16) w3= int((base-(w1*2^24)-(w2*2^16))/2^8) w4= int(base-(w1*2^24)-(w2*2^16)-(w3*2^8)) 'set word 0 'set data of W0 to 0, phase info out port, word0 'a "1" here will activate the x4 internal multiplier, but not recommended out control, wclk 'wclk line goes high out control, contclear 'wclk line goes low 'set word 1 out port,w1:out control,wclk:out control, contclear 'set word 2 out port,w2:out control,wclk:out control, contclear 'set word 3 out port,w3:out control,wclk:out control, contclear 'set word 4 out port,w4:out control,wclk:out control, contclear out port, 0 'return the output port data lines to 0 'send fqud out control, fqud 'set fqud to 1, freq changes now out control, contclear 'set fqud to 0 and all others to 0 return [CreateGraph] 'for Spectrum Analyzer WindowWidth = windowwide WindowHeight = graphhigh UpperLeftX = 1 'the Graph window upper left corner is 1 pixel right.. UpperLeftY = 1 '...and 1 pixel down from the upper left of the screen open "Graph Window for MSA/VNA, Spectrum Analyzer Mode - version 110" for graphics_nsb as #handle print #handle, "when leftButtonDown [LeftButDown]" print #handle, "when rightButtonDown [RightButDown]" print #handle, "trapclose [finished]" 'goto [finished] if xit is clicked print #handle, "down" 'ready to draw print #handle, "line ";0;" ";y;" ";x;" ";y 'draw baseline print #handle, "line ";" ";x/2;" ";y;" ";x/2;" ";y+10 'draw center tickmark ticks = abs(steps/10) for tick = 0 to ticks print #handle, "line ";" ";x*tick/ticks;" ";y;" ";x*tick/ticks;" ";y+5 next tick 'this will draw a tickmark every 10 steps print #handle, "line ";0;" ";y-maxscale;" ";x;" ";y-maxscale 'draw a reference line for top power print #handle, "\";topref;" dBm" 'print reference pwr level print #handle, "line ";0;" ";y-.9*maxscale;" ";x;" ";y-.9*maxscale print #handle, "\";topref - .1*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.8*maxscale;" ";x;" ";y-.8*maxscale print #handle, "\";topref - .2*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.7*maxscale;" ";x;" ";y-.7*maxscale print #handle, "\";topref - .3*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.6*maxscale;" ";x;" ";y-.6*maxscale print #handle, "\";topref - .4*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.5*maxscale;" ";x;" ";y-.5*maxscale print #handle, "\";topref - .5*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.4*maxscale;" ";x;" ";y-.4*maxscale print #handle, "\";topref - .6*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.3*maxscale;" ";x;" ";y-.3*maxscale print #handle, "\";topref - .7*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.2*maxscale;" ";x;" ";y-.2*maxscale print #handle, "\";topref - .8*(topref - botref);" dBm" print #handle, "line ";0;" ";y-.1*maxscale;" ";x;" ";y-.1*maxscale print #handle, "\";topref - .9*(topref - botref);" dBm" print #handle, "line ";0;" ";y;" ";x;" ";y print #handle, "\";botref;" dBm" print #handle, "place 205 380" print #handle, "\ Center Frequency is: "; centfreq; " MHz Sweep Width is: ";sweepwidth;" MHz" print #handle, "place 565 15" print #handle, "\ Max Power Input is: "; maxpower-gain; " dBm" print #handle, "flush" 'make the graph lines stick return [CreateGraphforVNA] 'for Vector Network Analyzer WindowWidth = windowwide WindowHeight = graphhigh UpperLeftX = 1 'the Graph window upper left corner is 1 pixel right.. UpperLeftY = 1 '...and 1 pixel down from the upper left of the screen open "Graph Window for MSA/VNA, Vector Network Analyzer Mode - version 110" for graphics_nsb as #handle print #handle, "when leftButtonDown [LeftButDown]" print #handle, "when rightButtonDown [RightButDown]" print #handle, "trapclose [finished]" 'goto [finished] if xit is clicked print #handle, "down" 'ready to draw print #handle, "line ";0;" ";y;" ";x;" ";y 'draw baseline print #handle, "line ";" ";x/2;" ";y;" ";x/2;" ";y+10 'draw center tickmark ticks = abs(steps/10) for tick = 0 to ticks print #handle, "line ";" ";x*tick/ticks;" ";y;" ";x*tick/ticks;" ";y+5 next tick 'this will draw a tickmark every 10 steps print #handle, "line ";0;" ";y-maxscale;" ";x;" ";y-maxscale 'draw a reference line for top power print #handle, "\";topref;" dB" 'print reference pwr level print #handle, "line ";0;" ";y-.9*maxscale;" ";x;" ";y-.9*maxscale print #handle, "\";topref - .1*(topref - botref);" dB" print #handle, "line ";0;" ";y-.8*maxscale;" ";x;" ";y-.8*maxscale print #handle, "\";topref - .2*(topref - botref);" dB" print #handle, "line ";0;" ";y-.7*maxscale;" ";x;" ";y-.7*maxscale print #handle, "\";topref - .3*(topref - botref);" dB" print #handle, "line ";0;" ";y-.6*maxscale;" ";x;" ";y-.6*maxscale print #handle, "\";topref - .4*(topref - botref);" dB" print #handle, "line ";0;" ";y-.5*maxscale;" ";x;" ";y-.5*maxscale print #handle, "\";topref - .5*(topref - botref);" dB" print #handle, "line ";0;" ";y-.4*maxscale;" ";x;" ";y-.4*maxscale print #handle, "\";topref - .6*(topref - botref);" dB" print #handle, "line ";0;" ";y-.3*maxscale;" ";x;" ";y-.3*maxscale print #handle, "\";topref - .7*(topref - botref);" dB" print #handle, "line ";0;" ";y-.2*maxscale;" ";x;" ";y-.2*maxscale print #handle, "\";topref - .8*(topref - botref);" dB" print #handle, "line ";0;" ";y-.1*maxscale;" ";x;" ";y-.1*maxscale print #handle, "\";topref - .9*(topref - botref);" dB" print #handle, "line ";0;" ";y;" ";x;" ";y print #handle, "\";botref;" dB" print #handle, "place 205 380" print #handle, "\ Center Frequency is: "; centfreq; " MHz Sweep Width is: ";sweepwidth;" MHz" print #handle, "place 565 15" print #handle, "\ Max Power Input is: "; maxpower-gain; " dBm" print #handle, "place 2 40" print #handle, "color red" print #handle, "\";topphase;" Deg." print #handle, "place 2 320" print #handle, "\";botphase;" Deg." print #handle, "color black" print #handle, "flush" 'make the graph lines stick return [Reprintlines] print #handle, "line ";0;" ";y-maxscale;" ";x;" ";y-maxscale 'draw a reference line for top power print #handle, "line ";0;" ";y-.9*maxscale;" ";x;" ";y-.9*maxscale print #handle, "line ";0;" ";y-.8*maxscale;" ";x;" ";y-.8*maxscale print #handle, "line ";0;" ";y-.7*maxscale;" ";x;" ";y-.7*maxscale print #handle, "line ";0;" ";y-.6*maxscale;" ";x;" ";y-.6*maxscale print #handle, "line ";0;" ";y-.5*maxscale;" ";x;" ";y-.5*maxscale print #handle, "line ";0;" ";y-.4*maxscale;" ";x;" ";y-.4*maxscale print #handle, "line ";0;" ";y-.3*maxscale;" ";x;" ";y-.3*maxscale print #handle, "line ";0;" ";y-.2*maxscale;" ";x;" ";y-.2*maxscale print #handle, "line ";0;" ";y-.1*maxscale;" ";x;" ";y-.1*maxscale print #handle, "line ";0;" ";y;" ";x;" ";y print #handle, "flush" 'make the graph lines stick return [createWorkingWindow]'from [SetUpWorkingWindow] WindowWidth = windowwide 'the Working window is 800 pixels wide WindowHeight = windowhigh 'the Working window is 180 pixels in height UpperLeftX = 1 'the Working window upper left corner is 1 pixels right.. UpperLeftY = 415 '...and 415 pixels down from the upper left corner of the monitor screen BackgroundColor$ = "darkblue" ForegroundColor$ = "white" statictext #main.message, "Message:", 5, 5, 50, 15 statictext #main.finalif, "Final I.F.", 5, 65, 40, 12 statictext #main.centerfreq, "Center Frequency", 323, 1, 120, 12 statictext #main.centerfreq2, "MHz", 408, 18, 30, 12 statictext #main.placemarkers, "Place Markers at Steps:", 598, 1, 120, 12 statictext #main.topref, "Top Ref Line", 725, 1, 70, 12 statictext #main.topref2, "dBm", 765, 18, 30, 12 statictext #main.filter, "Select Final Filter:", 10, 25, 100, 12 statictext #main.sweepwidth, "Sweep Width:", 320, 40, 80, 12 statictext #main.sweepwidth2, "MHz", 383, 59, 30, 12 statictext #main.stepspersweep, "Steps/Sweep", 415, 40, 80, 12 statictext #main.stepspersweep2, "1-720", 460, 59, 40, 12 statictext #main.mhzperstep, "MHz/Step:", 530, 40, 80, 12 statictext #main.waittime, "Wait", 643, 40, 60, 12 statictext #main.botref, "Bot Ref Line", 725, 40, 70, 12 statictext #main.botref2, "dBm", 765, 59, 30, 12 statictext #main.resolutionbw, "Res. B.W.", 5, 88, 50, 12 statictext #main.hitanykey, "Hit any key", 5, 107, 80, 12 statictext #main.hitanykey2, "on keyboard", 5, 120, 80, 12 statictext #main.hitanykey3, "to Halt sweep", 5, 135, 80, 12 statictext #main.thisstep, "Step", 235, 90, 50, 15 statictext #main.thisfreq, "This Freq", 283, 90, 50, 15 statictext #main.thispower, "Power (dBm)", 385, 90, 60, 15 statictext #main.leftclick, "LeftClick", 170, 110, 50, 12 statictext #main.rightclick, "RightClick", 170, 133, 50, 15 TextboxColor$ = "red" 'the following textboxes will be red textbox #main.centerfreqbox, 325, 15, 80, 20 ' create Center Freq box textbox #main.marker1box, 600, 15, 30, 20 'create Marker box 1 textbox #main.marker2box, 640, 15, 30, 20 'create Marker box 2 textbox #main.marker3box, 680, 15, 30, 20 'create Marker box 3 textbox #main.toprefbox, 725, 15, 35, 20 'create top reference line box textbox #main.sweepwidthbox, 325, 55, 55, 20 'create Sweep Width box textbox #main.stepspersweepbox, 420, 55, 35, 20 'create Steps per Sweep box textbox #main.waitbox, 640, 55, 35, 20 ' create Wait box textbox #main.botrefbox, 725, 55, 35, 20 'create bottom reference linebox textbox #main.hitkeybox, 85, 120, 30, 20 'create Hit any Key box TextboxColor$ = "blue" 'the following textboxes will be blue textbox #main.msgbox, 65, 3, 165, 20 ' create Message box textbox #main.finalifbox, 65, 62, 65, 20 ' create Final IF box textbox #main.resolutionbox, 65, 86, 65, 20 ' create Resolution BW box textbox #main.mhzperstepbox, 522, 55, 80, 20 'create MHz per step box textbox #main.stepnobox, 230, 106, 35, 20 'create step box textbox #main.thisfreqbox, 270, 106, 75, 20 'create This Freq box textbox #main.thispowerbox, 385, 106, 65, 20 'create Power box textbox #main.stepnobox2, 230, 130, 35, 20 'create step box textbox #main.thisfreqbox2, 270, 130, 75, 20 'create This Freq box textbox #main.thispowerbox2, 385, 130, 65, 20 'create Power box button #main.f1button, "F1", [button1], UL, 5, 38, 25, 20 button #main.f2button, "F2", [button2], UL, 35, 38, 25, 20 button #main.f3button, "F3", [button3], UL, 65, 38, 25, 20 button #main.f4button, "F4", [button4], UL, 95, 38, 25, 20 button #main.centerbutton, "Cent", [centerbutton], UL, 350, 106, 30, 20 button #main.harmbutton, "Harmonic Window", [CreateHarmonicWindow], UL, 522, 80, 95, 20 if PLL3 > 0 and trkgen = 0 then button #main.trkbutton, "Track Gen is OFF", [Trkbutton], UL, 522, 105, 95, 20 if PLL3 > 0 and trkgen = 1 then button #main.trkbutton, "Track Gen is ON", [Trkbutton], UL, 522, 105, 95, 20 button #main.spurbutton, "Spur Test is OFF", [Spurtest], UL, 522, 130, 95, 20 button #main.rewrite, "REWRITE", [Rewrite], UL, 640, 80, 58, 20 button #main.onestep, "ONESTEP", [OneStep], UL, 640, 105, 58, 20 button #main.rewcont, "REW.CONT", [Rewcont], UL, 720, 80, 65, 20 button #main.continue, "CONTINUE", [Continue], UL, 720, 105, 65, 20 button #main.restart, "RESTART", [Restart], UL, 680, 130, 65, 20 button #main.showvar, "Show Variables", [Showvar], UL, 150, 38, 80, 20 if PLL3 > 0 then button #main.govna, "Go-VNA Mode", [GoVNAmode], UL, 150, 63, 80, 20 open "Working Window for MSA/VNA, Spectrum Analyzer Mode - version 110" for dialog as #main print #main, "trapclose [finished]" 'goto [finished] if xit is clicked print #main.finalifbox, "";finalfreq;" MHz" 'default final I.F. freq print #main.resolutionbox, "";finalbw;" KHz" 'default resolution BW print #main.centerfreqbox, "";centfreq 'default center freq print #main.sweepwidthbox, "";sweepwidth 'default sweep width print #main.stepspersweepbox, "";steps 'default steps per sweep print #main.marker1box, "";marker1 'insert marker1 default in Marker1 box print #main.marker2box, "";marker2 'insert marker2 default in Marker2 box print #main.marker3box, "";marker3 'insert marker3 default in Marker3 box print #main.waitbox, "";wate 'insert wate default in wait box print #main.toprefbox, "";topref 'insert default top reference line print #main.botrefbox, "";botref 'insert default bottom reference line return [createWorkingWindowforVNA] WindowWidth = windowwide 'the Working window is 800 pixels wide WindowHeight = windowhigh 'the Working window is 180 pixels in height UpperLeftX = 1 'the Working window upper left corner is 1 pixels right.. UpperLeftY = 415 '...and 415 pixels down from the upper left corner of the monitor screen BackgroundColor$ = "darkred" ForegroundColor$ = "white" statictext #main.message, "Message:", 5, 5, 50, 15 statictext #main.finalif, "Final I.F.", 5, 65, 40, 12 statictext #main.centerfreq, "Center Frequency", 323, 1, 120, 12 statictext #main.phasetop, "Phase Top", 245, 1, 60, 12 statictext #main.phasetop2, "Deg.", 290, 18, 30, 15 statictext #main.phasebot, "Phase Bot", 245, 40, 60, 12 statictext #main.phasebot2, "Deg.", 290, 59, 30, 15 statictext #main.centerfreq2, "MHz", 408, 18, 30, 12 statictext #main.pdminvert, "PDM Inversion", 450,18,80,15 statictext #main.placemarkers, "Place Markers at Steps:", 598, 1, 120, 12 statictext #main.topref, "Top Ref Line", 725, 1, 70, 12 statictext #main.topref2, "dBc", 765, 18, 30, 12 statictext #main.filter, "Select Final Filter:", 10, 25, 100, 12 statictext #main.sweepwidth, "Sweep Width:", 320, 40, 80, 12 statictext #main.sweepwidth2, "MHz", 383, 59, 30, 12 statictext #main.stepspersweep, "Steps/Sweep", 415, 40, 80, 12 statictext #main.stepspersweep2, "1-720", 460, 59, 40, 12 statictext #main.mhzperstep, "MHz/Step:", 530, 40, 80, 12 statictext #main.waittime, "Wait", 643, 40, 60, 12 statictext #main.botref, "Bot Ref Line", 725, 40, 70, 12 statictext #main.botref2, "dBc", 765, 59, 30, 12 statictext #main.resolutionbw, "Res. B.W.", 5, 88, 50, 12 statictext #main.hitanykey, "Hit any key", 5, 107, 80, 12 statictext #main.hitanykey2, "on keyboard", 5, 120, 80, 12 statictext #main.hitanykey3, "to Halt sweep", 5, 135, 80, 12 statictext #main.thisstep, "Step", 235, 90, 50, 15 statictext #main.thisfreq, "This Freq", 283, 90, 50, 15 statictext #main.thispower, "Power (dBc)", 385, 90, 60, 15 statictext #main.thisphase, "Phase", 460, 90, 50, 12 statictext #main.leftclick, "LeftClick", 170, 110, 50, 12 statictext #main.rightclick, "RightClick", 170, 133, 50, 15 TextboxColor$ = "red" 'the following textboxes will be red textbox #main.phasetopbox, 255, 15, 35, 20 ' create Phase top line reference box textbox #main.phasebotbox, 255, 55, 35, 20 ' create Phase bottom line reference box textbox #main.centerfreqbox, 325, 15, 80, 20 ' create Center Freq box textbox #main.invdegbox, 530, 15, 50, 20 textbox #main.marker1box, 600, 15, 30, 20 'create Marker box 1 textbox #main.marker2box, 640, 15, 30, 20 'create Marker box 2 textbox #main.marker3box, 680, 15, 30, 20 'create Marker box 3 textbox #main.toprefbox, 725, 15, 35, 20 'create top reference line box textbox #main.sweepwidthbox, 325, 55, 55, 20 'create Sweep Width box textbox #main.stepspersweepbox, 420, 55, 35, 20 'create Steps per Sweep box textbox #main.waitbox, 640, 55, 35, 20 ' create Wait box textbox #main.botrefbox, 725, 55, 35, 20 'create bottom reference linebox textbox #main.hitkeybox, 85, 120, 30, 20 'create Hit any Key box TextboxColor$ = "blue" 'the following textboxes will be blue textbox #main.msgbox, 65, 3, 165, 20 ' create Message box textbox #main.finalifbox, 65, 62, 65, 20 ' create Final IF box textbox #main.resolutionbox, 65, 86, 65, 20 ' create Resolution BW box textbox #main.mhzperstepbox, 522, 55, 80, 20 'create MHz per step box textbox #main.stepnobox, 230, 106, 35, 20 'create step box textbox #main.thisfreqbox, 270, 106, 75, 20 'create This Freq box textbox #main.thispowerbox, 385, 106, 65, 20 'create Power box textbox #main.thisphasebox, 455, 106, 60, 20 'create Phase box textbox #main.thisphasebox2, 455, 130, 60, 20 'create Phase box textbox #main.stepnobox2, 230, 130, 35, 20 'create step box textbox #main.thisfreqbox2, 270, 130, 75, 20 'create This Freq box textbox #main.thispowerbox2, 385, 130, 65, 20 'create Power box button #main.f1button, "F1", [button1], UL, 5, 38, 25, 20 button #main.f2button, "F2", [button2], UL, 35, 38, 25, 20 button #main.f3button, "F3", [button3], UL, 65, 38, 25, 20 button #main.f4button, "F4", [button4], UL, 95, 38, 25, 20 button #main.centerbutton, "Cent", [centerbutton], UL, 350, 106, 30, 20 if trkgen = 0 then button #main.trkbutton, "Track Gen is OFF", [Trkbutton], UL, 522, 105, 95, 20 if trkgen = 1 then button #main.trkbutton, "Track Gen is ON", [Trkbutton], UL, 522, 105, 95, 20 button #main.rewrite, "REWRITE", [Rewrite], UL, 640, 80, 58, 20 button #main.onestep, "ONESTEP", [OneStep], UL, 640, 105, 58, 20 button #main.rewcont, "REW.CONT", [Rewcont], UL, 720, 80, 65, 20 button #main.continue, "CONTINUE", [Continue], UL, 720, 105, 65, 20 button #main.restart, "RESTART", [Restart], UL, 680, 130, 65, 20 button #main.showvar, "Show Variables", [Showvar], UL, 150, 38, 80, 20 button #main.gomsa, "Go-MSA Mode", [GoMSAmode], UL, 150, 63, 80, 20 button #main.calibfwd, "Calibrate ?", [Calfwd], UL, 150, 86, 65, 20 open "Working Window for MSA/VNA, Vector Network Analyzer Mode - version 110" for dialog as #main print #main, "trapclose [finished]" 'goto [finished] if xit is clicked print #main.finalifbox, "";finalfreq;" MHz" 'default final I.F. freq print #main.resolutionbox, "";finalbw;" KHz" 'default resolution BW print #main.centerfreqbox, "";centfreq 'default center freq print #main.sweepwidthbox, "";sweepwidth 'default sweep width print #main.stepspersweepbox, "";steps 'default steps per sweep print #main.invdegbox,invdeg print #main.marker1box, "";marker1 'insert marker1 default in Marker1 box print #main.marker2box, "";marker2 'insert marker2 default in Marker2 box print #main.marker3box, "";marker3 'insert marker3 default in Marker3 box print #main.waitbox, "";1 'insert 1 in wait box when entering VNA mode. Slow down PDM print #main.toprefbox, "";topref 'insert default top reference line print #main.botrefbox, "";botref 'insert default bottom reference line print #main.phasetopbox,180 print #main.phasebotbox,-180 return [GoMSAmode] vna = 0 redim calarray(800,2) 'clear out the calibration array when changing to MSA mode close #main 'close out working window for VNA close #handle 'close out Graph window for VNA gosub [CreateGraph] gosub[createWorkingWindow] goto [Restart] [GoVNAmode] vna = 1 redim calarray(800,2) 'clear out the calibration array when changing to VNA mode close #main 'close out working window for SA close #handle 'close out Graph window for SA gosub [CreateGraphforVNA] gosub[createWorkingWindowforVNA] goto [Restart] [calcWindowInfo] 'from [GrabWorkingWindowData] print #main.centerfreqbox, "!contents? centfreq$"; 'Center Freq box centfreq = val(centfreq$) 'change global to what user entered print #main.sweepwidthbox, "!contents? sweepwidth$"; 'Sweep Width box sweepwidth = val(sweepwidth$) 'change global to what user entered print #main.stepspersweepbox, "!contents? steps$"; 'Steps per Sweep box steps = val(steps$) 'change global to what user entered startfreq = centfreq - sweepwidth/2 'start frequency of sweep stepfreq = sweepwidth/steps 'delta step frequency print #main.mhzperstepbox, stepfreq 'MHz per step box print #main.marker1box, "!contents? mark1$"; 'Marker1 box marker1 = val(mark1$) 'change global to what user entered print #main.marker2box, "!contents? mark2$"; 'Marker2 box marker2 = val(mark2$) 'change global to what user entered print #main.marker3box, "!contents? mark3$"; 'Marker3 box marker3 = val(mark3$) 'change global to what user entered print #main.waitbox, "!contents? wate$"; 'Wait box wate = val(wate$) 'change global to what user entered print #main.toprefbox, "!contents? topref$"; 'Top reference box topref = val(topref$) 'Log Det power, in dBm print #main.botrefbox, "!contents? botref$"; 'Bottom reference box botref = val(botref$) 'Log Det power, in dBm if botref>=topref then botref = topref-10:print #main.botrefbox, "";topref-10 if vna = 1 then print #main.invdegbox, "!contents? invdeg$"; if vna = 1 then invdeg = val(invdeg$) if vna = 1 then print #main.phasetopbox, "!contents? topphasescale$"; 'Top reference line from Phase Top box if vna = 1 then print #main.phasebotbox, "!contents? botphasescale$"; 'Bot reference line from Phase Bot box if vna = 1 then topphase = val(topphasescale$) 'this is the phase of the top scale ref line if vna = 1 then botphase = val(botphasescale$) 'this is the phase of the bottom scale ref line if vna = 1 and botphase>=topphase then botphase = topphase-10:print #main.phasebotbox, "";botphase if vna = 1 then centphase = (topphase+botphase)/2 'this is the phase of the center scale ref line return 'goto [endGrabWorkingWindowData] [LeftButDown] 'when left mouse button is pressed, do the following leftdownpixelx = MouseX if leftdownpixelx > x then leftdownpixelx=x leftstep = int(steps*leftdownpixelx/x) print #main.stepnobox,datatable(leftstep,0) 'display "thisstep" number from most current data print #main.thisfreqbox,datatable(leftstep,1) 'display "thisfreq" from most current data print #main.thispowerbox,datatable(leftstep,2) 'display "thispointpower" from most current data if vna = 1 then print #main.thisphasebox,datatable(leftstep,3);" deg" 'display phase measurement from most current data wait [RightButDown] 'when right mouse button is pressed, do the following rightdownpixelx = MouseX if rightdownpixelx > x then rightdownpixelx=x rightstep = int(steps*rightdownpixelx/x) print #main.stepnobox2,datatable(rightstep,0) 'display "thisstep" number from most current data print #main.thisfreqbox2,datatable(rightstep,1) 'display "thisfreq" from most current data print #main.thispowerbox2,datatable(rightstep,2) 'display "thispointpower" from most current data if vna = 1 then print #main.thisphasebox2,datatable(rightstep,3);" deg" 'display phase measurement from most current data lowerfreq = datatable(leftstep,1) upperfreq = datatable(rightstep,1) if lowerfreq>upperfreq then lowerfreq=datatable(rightstep,1):upperfreq=datatable(leftstep,1) newsweepwidth = upperfreq-lowerfreq newcenterfreq = lowerfreq + newsweepwidth/2 print #main.centerfreqbox, "";newcenterfreq print #main.sweepwidthbox, "";newsweepwidth wait [centerbutton]'this will take the contents of the "This Freq" box and put it in the "Center Frequency" box print #main.thisfreqbox, "!contents? newcentfreq$" print #main.centerfreqbox, "";newcentfreq$ wait [Halted] 'from [DetermineNextOperation], Sweep has Halted, do the following gosub [Reprintlines] 'retrace graph lines when sweep is stopped print #main.msgbox,error$ 'will print any error, when halted print #main.msgbox,test print #main.stepnobox,thisstep print #main.thisfreqbox,thisfreq print #main.thispowerbox,thispointpower if vna = 1 then print #main.thisphasebox,phaseofpdm;" deg" wait 'wait until any button is clicked [button1] finalfreq = finalfreq1 finalbw = finalbw1 gain = sagain1 out port, 16: out control, enat:out control, contclear: out port, 0 'the above line is an optional code for Final Xtal Filter relays: 'Data 4 up, Init Printer up, Init Printer down, Data 4 down print #main.finalifbox, "";finalfreq;" MHz" print #main.resolutionbox, "";finalbw;" KHz" 'default resolution BW wait [button2] finalfreq = finalfreq2 finalbw = finalbw2 gain = sagain2 out port, 32: out control, enat:out control, contclear: out port, 0 'Data 5 up, Init Printer up, Init Printer down, Data 5 down print #main.finalifbox, "";finalfreq;" MHz" print #main.resolutionbox, "";finalbw;" KHz" 'default resolution BW wait [button3] finalfreq = finalfreq3 finalbw = finalbw3 gain = sagain3 out port, 64: out control, enat:out control, contclear: out port, 0 'Data 6 up, Init Printer up, Init Printer down, Data 6 down print #main.finalifbox, "";finalfreq;" MHz" print #main.resolutionbox, "";finalbw;" KHz" 'default resolution BW wait [button4] finalfreq = finalfreq4 finalbw = finalbw4 gain = sagain4 out port, 128: out control, enat:out control, contclear: out port, 0 'Data 7 up, Init Printer up, Init Printer down, Data 7 down print #main.finalifbox, "";finalfreq;" MHz" print #main.resolutionbox, "";finalbw;" KHz" 'default resolution BW wait [Restart] close #handle 'close out graph window when restarting rewrite=0 print #main.hitkeybox, "" 'put "nothing" into HitAnyKey box print #main.hitkeybox, "!setfocus" 'make sure the "Hit any Key" box has the focus goto [GrabWorkingWindowData] [Rewrite] rewrite=1 goto [FocusKeyBox] [Rewcont] rewrite=1 goto [ClearKeyBox] [OneStep] rewrite=0 goto [FocusKeyBox] [Continue] rewrite=0 goto [ClearKeyBox] [ClearKeyBox] print #main.hitkeybox, "" 'put "nothing" into HitAnyKey box [FocusKeyBox] print #main.hitkeybox, "!setfocus" 'make sure the "Hit any Key" box has the focus goto [IncrementOneStep] [Trkbutton]'needed:LO2,finalfreq,trkgen,PLL3off,rcounter3,masterclock if PLL3top = 0 then PLL3on = LO2 - finalfreq + PLL3offset if PLL3top = 1 then PLL3on = LO2 + thisfreq + PLL3offset if trkgen = 1 then print #main.trkbutton, "Track Gen is OFF":LO3 = PLL3off:gosub [ChangeTGfreq]:trkgen = 0:wait if trkgen = 0 then print #main.trkbutton, "Track Gen is ON":LO3 = PLL3on:gosub [ChangeTGfreq]:trkgen = 1:wait [ChangeTGfreq] if PLL3top = 0 then gosub [ChangeFreqofPLL3old] if PLL3top = 1 then gosub [ChangeFreqofPLL3new] return [Spurtest] if spurcheck = 0 and PLL1mode = 0 then rcounter1=rcounter1+1:gosub[CommandPLL1R] if spurcheck = 0 then print #main.spurbutton, "Spur Test is ON":spurcheck=1:wait if spurcheck = 1 and PLL1mode = 0 then rcounter1=rcounter1-1:gosub[CommandPLL1R] if spurcheck = 1 then print #main.spurbutton, "Spur Test is OFF":spurcheck=0:wait [CreateHarmonicWindow] if harmonicwindow = 1 then close #harmonicwindow: harmonicwindow = 0 WindowWidth = 225 'the Harmonic Window is 800 pixels wide WindowHeight = 180 'the Harmonic Window is 180 pixels in height UpperLeftX = 1 'the Harmonic Window upper left corner is 1 pixels right.. UpperLeftY = 1 '...and 1 pixels down from the upper left of the screen BackgroundColor$ = "darkblue" ForegroundColor$ = "white" image0 = thisfreq image1 = LO2 + finalfreq - LO1 image2 = LO1 - finalfreq - LO2 image3 = 2*LO2 - finalfreq - 2*LO1 image4 = 2*LO2 + finalfreq - 2*LO1 image5 = LO1 - 2*LO2 + finalfreq image6 = 2*LO1 - 2*LO2 - finalfreq button #harmonicwindow.image0button, "X", [Image0], UL, 2, 10, 15, 15 statictext #harmonicwindow.image0text, " LO1 - ThisFreq (";image0;") = LO2-FinalIF", 17, 10, 223, 20 if image1 > 0 then button #harmonicwindow.image1button, "X", [Image1], UL, 2, 30, 15, 15 statictext #harmonicwindow.image1text, " LO1 + Image (";image1;") = LO2+FIF", 17, 30, 223, 20 if image2 > 0 then button #harmonicwindow.image2button, "X", [Image2], UL, 2, 50, 15, 15 statictext #harmonicwindow.image2text, " LO1 - Image (";image2;") = LO2+FIF", 17, 50, 223, 20 if image3 > 0 then button #harmonicwindow.image3button, "X", [Image3], UL, 2, 70, 15, 15 statictext #harmonicwindow.image3text, "2xLO1 + Image (";image3;") = 2LO2-FIF", 17, 70, 223, 20 if image4 > 0 then button #harmonicwindow.image4button, "X", [Image4], UL, 2, 90, 15, 15 statictext #harmonicwindow.image4text, "2xLO1 + Image (";image4;") = 2LO2+FIF", 17, 90, 223, 20 if image5 > 0 then button #harmonicwindow.image5button, "X", [Image5], UL, 2, 110, 15, 15 statictext #harmonicwindow.image5text, "2xLO1 - Image (";image5;") = 2LO2-FIF", 17, 110, 223, 20 if image6 > 0 then button #harmonicwindow.image6button, "X", [Image6], UL, 2, 130, 15, 15 statictext #harmonicwindow.image6text, "2xLO1 - Image (";image6;") = 2LO2+FIF", 17, 130, 223, 20 open "Harmonic Images" for dialog as #harmonicwindow harmonicwindow = 1 print #harmonicwindow, "trapclose [CloseHarmonicWindow]" 'goto [CloseHarmonicWindow] if xit is clicked wait [Image0] print #main.centerfreqbox, "";image0 goto[Restart] [Image1] print #main.centerfreqbox, "";image1 goto[Restart] [Image2] print #main.centerfreqbox, "";image2 goto[Restart] [Image3] print #main.centerfreqbox, "";image3 goto[Restart] [Image4] print #main.centerfreqbox, "";image4 goto[Restart] [Image5] print #main.centerfreqbox, "";image5 goto[Restart] [Image6] print #main.centerfreqbox, "";image6 goto[Restart] [CloseHarmonicWindow] close #harmonicwindow 'close out harmonicwindow harmonicwindow = 0 wait [Showvar] if varwindow=1 then goto [Closevarwin] WindowWidth = 200 WindowHeight = 410 UpperLeftX = 590 UpperLeftY = 5 BackgroundColor$ = "darkblue" ForegroundColor$ = "white" statictext #varwin.variable1, "ddsoutput = ";ddsoutput;" MHz", 5, 5, 180, 15 statictext #varwin.variable2, "LO 1 = ";LO1;" MHz", 5, 20, 180, 15 statictext #varwin.variable3, "pdf1 = ";pdf1;" MHz", 5, 35, 180, 15 statictext #varwin.variable4, "ncount1 = ";ncount1, 5, 50, 180, 15 statictext #varwin.variable5, "ncounter1 = ";ncounter1, 5, 65, 180, 15 statictext #varwin.variable6, "Bcounter1 = ";Bcounter1, 5, 80, 180, 15 statictext #varwin.variable7, "Acounter1 = ";Acounter1, 5, 95, 180, 15 statictext #varwin.variable8, "fcounter1 = ";fcounter1, 5, 110, 180, 15 statictext #varwin.variable9, "rcounter1 = ";rcounter1, 5, 125, 180, 15 statictext #varwin.variable10, "LO2 = ";LO2;" MHz", 5, 140, 180, 15 statictext #varwin.variable11, "pdf2 = ";pdf2;" MHz", 5, 155, 180, 15 statictext #varwin.variable12, "ncounter2 = ";ncounter2, 5, 170, 180, 15 statictext #varwin.variable13, "Bcounter2 = ";Bcounter2, 5, 185, 180, 15 statictext #varwin.variable14, "Acounter2 = ";Acounter2, 5, 200, 180, 15 statictext #varwin.variable15, "rcounter2 = ";rcounter2, 5, 215, 180, 15 statictext #varwin.variable16, "LO3 = ";LO3;" MHz", 5, 230, 180, 15 statictext #varwin.variable17, "pdf3 = ";pdf3;" MHz", 5, 245, 180, 15 statictext #varwin.variable18, "ncounter3 = ";ncounter3, 5, 260, 180, 15 statictext #varwin.variable19, "Bcounter3 = ";Bcounter3, 5, 275, 180, 15 statictext #varwin.variable20, "Acounter3 = ";Acounter3, 5, 290, 180, 15 statictext #varwin.variable21, "fcounter3 = ";fcounter3, 5, 305, 180, 15 statictext #varwin.variable22, "rcounter3 = ";rcounter3, 5, 320, 180, 15 statictext #varwin.variable23, "dds3output = ";dds3output, 5, 335, 180, 15 statictext #varwin.variable24, "Mag AtoD Bits = ";magdata, 5, 350, 180, 15 statictext #varwin.variable25, "Pha AtoD Bits = ";phadata;" PDM = ";pdm, 5, 365, 180, 15 open "Variables" for dialog as #varwin:varwindow = 1 print #varwin, "trapclose [Closevarwin]" 'goto [Closevarwin] if xit is clicked print #main.showvar, "Close Variables" wait [updatevar] print #varwin.variable1, "ddsoutput = ";ddsoutput;" MHz" print #varwin.variable2, "LO 1 = ";LO1;" MHz" print #varwin.variable3, "pdf1 = ";pdf1;" MHz" print #varwin.variable4, "ncount1 = ";ncount1 print #varwin.variable5, "ncounter1 = ";ncounter1 print #varwin.variable6, "Bcounter1 = ";Bcounter1 print #varwin.variable7, "Acounter1 = ";Acounter1 print #varwin.variable8, "fcounter1 = ";fcounter1 print #varwin.variable9, "rcounter1 = ";rcounter1 print #varwin.variable10, "LO2 = ";LO2;" MHz" print #varwin.variable11, "pdf2 = ";pdf2;" MHz" print #varwin.variable12, "ncounter2 = ";ncounter2 print #varwin.variable13, "Bcounter2 = ";Bcounter2 print #varwin.variable14, "Acounter2 = ";Acounter2 print #varwin.variable15, "rcounter2 = ";rcounter2 print #varwin.variable16, "LO3 = ";LO3;" MHz" print #varwin.variable17, "pdf3 = ";pdf3;" MHz" print #varwin.variable18, "ncounter3 = ";ncounter3 print #varwin.variable19, "Bcounter3 = ";Bcounter3 print #varwin.variable20, "Acounter3 = ";Acounter3 print #varwin.variable21, "fcounter3 = ";fcounter3 print #varwin.variable22, "rcounter3 = ";rcounter3 print #varwin.variable23, "dds3output = ";dds3output print #varwin.variable24, "Mag AtoD Bits = ";magdata print #varwin.variable25, "Pha AtoD Bits = ";phadata;" PDM = ";pdm return [Closevarwin] close #varwin:varwindow = 0 'close out variables window print #main.showvar, "Show Variables" wait [CreateRcounterPLL3old]'needed:masterclock,PLL3phasefreq ; creates:rcounter3,pdf3 rcounter3 = int(masterclock/PLL3phasefreq) if (masterclock/PLL3phasefreq) - rcounter3 >= .5 then rcounter3 = rcounter3 + 1 'rounds off rcounter3 pdf3 = masterclock/rcounter3 'actual phase detector frequency of PLL 3 return 'with:rcounter3,pdf3 [CreateRcounterPLL3new]'needed:appxDDS3,dds3filbw,PLL3phasefreq ; creates:rcounter3 rcounter3 = int((appxDDS3 + (.5*dds3filbw))/PLL3phasefreq) 'This determines the whole number Reference divide ratio for PLL 3 if ((appxDDS3 + (.5*dds3filbw))/PLL3phasefreq) - rcounter3 >= .5 then rcounter3 = rcounter3 +1 return 'with:rcounter3 [ChangeFreqofPLL3old]'needed:LO3,rcounter3,masterclock ; changes PLL3 freq : creates:ncounter3,fcounter3 appxVCO = LO3 reference = masterclock rcounter = rcounter3 if PLL3mode = 0 then gosub [CreateIntegerNcounter]'needs:appxVCO,reference,rcounter ; creates:ncounter,fcounter(0) if PLL3mode = 1 then gosub [CreateFractionalNcounter]'needs:appxVCO,reference,rcounter ; creates:ncounter,fcounter ncounter3 = ncounter : fcounter3 = fcounter gosub [CommandPLL3N]'needs:ncounter,fcounter,PLL1mode,enat,PLL3 Bcounter3=Bcounter: Acounter3=Acounter LO3=((Bcounter*preselector)+Acounter+(fcounter/16))*pdf3 'actual LO3 frequency return [ChangeFreqofPLL3new]'needed:LO3,rcounter3,appxDDS3,enat ; commands PLL3 Ncounters ; creates:ncounter3,fcounter3(0),dds3output,pdf3 if LO3 = lastLO3 then return 'don't waste time commanding, if not needed lastLO3 = LO3 Jcontrol=enat : swclk=32 : sfqudsfqud=2 gosub [CreateNcounter3andDDS3output]'needs:LO3,rcounter3,appxDDS3 ; creates:ncounter3,fcounter3(0),dds3output,base gosub [DDScommandSerial]'needed:port,control,base,Jcontrol,swclk,sfqud,contclear ; commands DDS, serially ncounter=ncounter3 : fcounter=fcounter3 if ncounter3 = lastncounter3 then return lastncounter3 = ncounter3 gosub [CommandPLL3N]'needed:ncounter,fcounter,PLL3mode,enat,PLL3 Bcounter3=Bcounter: Acounter3=Acounter return [CreateNcounter3andDDS3output]'needed:LO3,rcounter3,appxDDS3 ; creates:ncounter3,fcounter3,dds3output,base ncount3 = LO3/(appxDDS3/rcounter3) 'approximates the Ncount for PLL 3/DDS3 ncounter3 = int(ncount3) 'actual value for PLL3 Ncounter if ncount3 - ncounter3 >= .5 then ncounter3 = ncounter3 + 1 fcounter3 = 0 pdf3 = LO3/ncounter3 'actual phase freq of PLL3 dds3output = pdf3 * rcounter3 'actual output of DDS3(input Ref to PLL3) fullbase=(dds3output*2^32/masterclock) base = int(fullbase) '32 bit frequency code in decimal overbase = fullbase-base if overbase>=.5 then base = base + 1 return 'with ncounter3,fcounter3,dds3output,base [DDScommandSerial]'needed:port,control,base,Jcontrol,swclk,sfqud,contclear ; commands DDS, serially if base = lastbase4 then return lastbase4 = base b0 = int(base/2):sw0 = base - 2*b0 'LSB, Freq-b0. sw is serial word bit b1 = int(b0/2):sw1 = b0 - 2*b1:b2 = int(b1/2):sw2 = b1 - 2*b2 b3 = int(b2/2):sw3 = b2 - 2*b3:b4 = int(b3/2):sw4 = b3 - 2*b4 b5 = int(b4/2):sw5 = b4 - 2*b5:b6 = int(b5/2):sw6 = b5 - 2*b6 b7 = int(b6/2):sw7 = b6 - 2*b7:b8 = int(b7/2):sw8 = b7 - 2*b8 b9 = int(b8/2):sw9 = b8 - 2*b9:b10 = int(b9/2):sw10 = b9 - 2*b10 b11 = int(b10/2):sw11 = b10 - 2*b11:b12 = int(b11/2):sw12 = b11 - 2*b12 b13 = int(b12/2):sw13 = b12 - 2*b13:b14 = int(b13/2):sw14 = b13 - 2*b14 b15 = int(b14/2):sw15 = b14 - 2*b15:b16 = int(b15/2):sw16 = b15 - 2*b16 b17 = int(b16/2):sw17 = b16 - 2*b17:b18 = int(b17/2):sw18 = b17 - 2*b18 b19 = int(b18/2):sw19 = b18 - 2*b19:b20 = int(b19/2):sw20 = b19 - 2*b20 b21 = int(b20/2):sw21 = b20 - 2*b21:b22 = int(b21/2):sw22 = b21 - 2*b22 b23 = int(b22/2):sw23 = b22 - 2*b23:b24 = int(b23/2):sw24 = b23 - 2*b24 b25 = int(b24/2):sw25 = b24 - 2*b25:b26 = int(b25/2):sw26 = b25 - 2*b26 b27 = int(b26/2):sw27 = b26 - 2*b27:b28 = int(b27/2):sw28 = b27 - 2*b28 b29 = int(b28/2):sw29 = b28 - 2*b29:b30 = int(b29/2):sw30 = b29 - 2*b30 b31 = int(b30/2):sw31 = b30 - 2*b31 'MSB, Freq-b31 sw32 = 0 'x4 multiplier, 1=enable sw33 = 0 'control bit sw34 = 0 'power down bit sw35 = 0 'phase data sw36 = 0 'phase data sw37 = 0 'phase data sw38 = 0 'phase data sw39 = 0 'phase data 'the following will send the above bits to the DDS for Commanding out control, Jcontrol 'enable Control Board J connector out port, sw0:out port, sw0 + swclk 'first sw active, first sw active and swclk up out port, sw1:out port, sw1 + swclk '2nd sw active and swclk down, 2nd sw active and swclk up out port, sw2:out port, sw2 + swclk 'etc. out port, sw3:out port, sw3 + swclk :out port, sw4:out port, sw4 + swclk 'etc. out port, sw5:out port, sw5 + swclk :out port, sw6:out port, sw6 + swclk 'etc. out port, sw7:out port, sw7 + swclk :out port, sw8:out port, sw8 + swclk 'etc. out port, sw9:out port, sw9 + swclk :out port, sw10:out port, sw10 + swclk 'etc. out port, sw11:out port, sw11 + swclk :out port, sw12:out port, sw12 + swclk 'etc. out port, sw13:out port, sw13 + swclk :out port, sw14:out port, sw14 + swclk 'etc. out port, sw15:out port, sw15 + swclk :out port, sw16:out port, sw16 + swclk 'etc. out port, sw17:out port, sw17 + swclk :out port, sw18:out port, sw18 + swclk 'etc. out port, sw19:out port, sw19 + swclk :out port, sw20:out port, sw20 + swclk 'etc. out port, sw21:out port, sw21 + swclk :out port, sw22:out port, sw22 + swclk 'etc. out port, sw23:out port, sw23 + swclk :out port, sw24:out port, sw24 + swclk 'etc. out port, sw25:out port, sw25 + swclk :out port, sw26:out port, sw26 + swclk 'etc. out port, sw27:out port, sw27 + swclk :out port, sw28:out port, sw28 + swclk 'etc. out port, sw29:out port, sw29 + swclk :out port, sw30:out port, sw30 + swclk 'etc. out port, sw31:out port, sw31 + swclk :out port, sw32:out port, sw32 + swclk 'etc. out port, sw33:out port, sw33 + swclk :out port, sw34:out port, sw34 + swclk 'etc. out port, sw35:out port, sw35 + swclk :out port, sw36:out port, sw36 + swclk 'etc. out port, sw37:out port, sw37 + swclk 'etc. out port, sw38:out port, sw38 + swclk '39th sw active and swclk down, 39th sw active and swclk up out port, sw39:out port, sw39 + swclk '40th sw active and swclk down, 40th sw active and swclk up out port, 0:out port, sfqud:out port, 0 'last sw down and swclk down, sfqud up, sfqud down out control, contclear 'disable J connector return [Calfwd] calfwd = 1 pdm = 0 'begin the cal with the PDM set to "Normal", for proper print #main.calibfwd, "Calibrating" goto [Restart] [finished] close #main 'close out working window close #handle 'close out graph window if harmonicwindow = 1 then close #harmonicwindow 'close out harmonicwindow if varwindow = 1 then close #varwin 'close out variable window end '------------ ' The following are error messages and are not compiled: ' "DDSoutput too high for filter" decrease global variable, PLL1phasefreq or widen DDS output filter ' "DDSoutput too low for filter" decrease global variable, PLL1phasefreq or widen DDS output filter ' "2325 Rcounter is < 3" ' "2325 Rcounter is > 16383" ' "2325 Bcounter < 3" ' "2325 Bcounter > 2047" ' "2325 Bcounter16383" ' "2326 B counter <3" ' "2326 B counter >8191" ' "2326 B counter32767" ' "2350 Rcounter <3" ' "2350 Rcounter >1023" ' "2350 Bcounter 32767" ' "2353 Bcounter is < 3" ' "2353 Bcounter is > 1023" ' "2353 Bcounter < Acounter+1" 'when the sweep is Halted: 'at the point where it is halted, the last step's data is shown in the ' (LeftClick) "Step", "This Freq", "Power", and "Phase" boxes 'place the mouse pointer on the graph and click the left Mouse button, will grab the closest step and change 'the (LeftClick) "Step", "This Freq", "Power", and "Phase" boxes to the data that was taken last. 'place the mouse pointer on the graph and click the right Mouse button, will grab the closest step and: '1. calculate the frequency difference from the previous left Mouse click and place it in the "Sweep Width" box. '2. calculate the center frequency of the two points and place it in the "Center Frequency" box. '3. wait for a "RESTART", which will then begin a new sweep with the new "Center Frequency" and "Sweep Width" 'Click the "Cent" button, will install the "This Freq" box data, into the "Center Frequency" box. 'Click the "Show Variables" button, will open a small window, displaying the variables being used in the program. 'Click the "Track Gen is OFF" button, will command the Tracking Generator to the frequency at which the ' sweep is halted. The button will change to "Track Gen is ON". Click button again, will command the Tracking ' Generator to the "PLL3off" frequency, which is 970 MHz. ' To see linearity of PDM (where the indeterminate zone is): ' Install 4 foot cable from TG out (Mag Ref out) ' find this line of code and make it a "remark" by inserting a ' at the beginning of the line: ' "if phadata/maxpdmout < .2 or phadata/maxpdmout > .8 then gosub [InvertPDmodule]" ' do not click "Calibrate ?" ' Sweep wide enough to get at least one full ramp. The plot will show the unlinearity around 0 degrees. ' My zone is from -20 degrees to + 30 degrees. Using 80% to 20% in software = -72 deg to +72 deg