'11-28-05 version106 'updated from version105, the new code lines are on left margin and marked ,v106 'change resolution to .01 dB (this is effective only if a 12 bit AtoD is utilized) 'add feature: left and right click mouse for step, freq and power using array 'add Step, This Freq and Power boxes 'make boxes smaller and re-arrange in Working Window 'The globals are preset for MSA, with PLL1, PLL2,and PLL3 as LMX2326; 8 Bit A/D 'Find "test=" and change its value to a variable name you would like in message box: ie, test= thisstep (optional) 'The [8Bit] table values are nominal for an LM3356 @0dBm = 255 bits and 'The [12Bit] table values are nominal for an AD8306 @+10 dBm = 4095 bits nomainwin masterclock = 64 'nominal frequency of the Master Clock (in MHz) actualclock = 64 'actual output frequency of the Master Clock (in MHz) cf = 0 'center frequency default, all frequencies in MHz sw = .02 'sweep width in MHz, default wat = 0 'wait before data take, default sps = 400 'default steps per sweep mkr1 = 100 'marker 1 step placement, default mkr2 = 200 'marker 2 step placement, default mkr3 = 300 'marker 3 step placement, default finalfreq1 = 9.954 'freq of Final Xtal Filter # 1 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 finalbw2 = 2 'BW (in KHz)of Final Xtal Filter # 2 sagain2 = 0 'total gain of SA with Final Filter #2 installed finalfreq3 = 10.695 'freq of Final Xtal Filter # 3 finalbw3 = 4.5 '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 finalbw4 = 30 'BW (in KHz)of Final Xtal Filter # 4 sagain4 = 0 'total gain of SA with Final Filter #4 installed appxLO2 = 1024 '2nd LO frequency,1024 MHz or greater, 4 MHz steps PLL1 = 2326 'enter PLL type, (LMX) 2325, 2326, 2350, 2353, (ADF)4112 PLL2 = 2326 'enter PLL type, (LMX) 2325, 2326, 2350, 2353, 0 for SRD PLL3 = 2326 'enter PLL type, (LMX) 2325, 2326, 2350, 2353, 0 for no Tracking Generator PLL1phasefreq = .974 'This is the maximum Phase Detector Frequency (PDF) for PLL 1 PLL1mode = 0 '1 = Fractional Mode, 0 = Integer Mode PLL2phasefreq = 4 '2nd LO's PLL2 phase frequency is 4 MHz PLL3off = 970 'Output freq of PLL3/VCO3 when Trk Gen "off", v103 PLL3phasefreq = .005 'TrkGen LO's PLL3 phase frequency, which will determine step size PLL3mode = 0 '1 = Fractional Mode, 0 = Integer Mode appxDDS = 10.7 'this DDS output(Ref. for PLL1), and center freq. of DDS xtal filter xfilbw = .015 'this is the DDS xtal filter bandwidth, must be > .0045 (MHz) glitchtime = 5000 'this is time added when the DDS or PLL changes drastically topref = 0 'default top reference line on scale, in dBm input to SSA, ver105 botref = -100 'default bottom reference line on scale, in dBm input to SSA, ver105 dabits = 8 'use "8" for original 8 bit, or "12" for optional 12 bit A to D network, ver105 '[8Bit] 'insert the proper values below, for an 8 bit A to D network, ver105 maxpower = 0 'power level at the input to the Log Det at compression, in dBm, ver105 maxbits = 255 'bit values to be modified during cal procedure 'maxpower, ver105 minus10bits = 241 'bit value from A to D converter when "maxpower" is applied to the Log Det.'maxpower-10dB, ver105 minus20bits = 213 'bit value when "maxpower" - 10 dB is applied to the Log Det.'maxpower-20dB, ver105 minus30bits = 185 'bit value when "maxpower" - 20 dB is applied to the Log Det.'maxpower-30dB, ver105 minus40bits = 157 'etc. 'maxpower-40dB, ver105 minus50bits = 125 'these defaults were inserted after my calibration 'maxpower-50dB, ver105 minus60bits = 97 'of my MSA, using the LM3356 'maxpower-60dB, ver105 minus70bits = 65 'maxpower-70dB, ver105 minus80bits = 39 'maxpower-80dB, ver105 minus90bits = 25 'maxpower-90dB, ver105 minus100bits = 23 'maxpower-100dB, ver105 minus110bits = 23 'maxpower-110dB, ver105 minus120bits = 23 'maxpower-120dB, ver105 minus130bits = 23 'maxpower-130dB, ver105 if dabits = 8 then goto [end12bit] ' ver105 '[12Bit] 'insert the proper values below, for a 12 bit A to D network ver105 maxpower = 10 'power level (in dBm) to the Log Det at compression, ver105 maxbits = 4095 'and should be modified during cal procedure 'maxpower, ver105 minus10bits = 3741 'These values are when using AD8306 as Log Det 'maxpower-10dB, ver105 minus20bits = 3384 'maxpower-20dB, ver105 minus30bits = 3024 'maxpower-30dB, ver105 minus40bits = 2673 'maxpower-40dB, ver105 minus50bits = 2323 'maxpower-50dB, ver105 minus60bits = 1981 'maxpower-60dB, ver105 minus70bits = 1631 'maxpower-70dB, ver105 minus80bits = 1299 'maxpower-80dB, ver105 minus90bits = 971 'maxpower-90dB, ver105 minus100bits = 697 'maxpower-100dB, ver105 minus110bits = 577 'maxpower-110dB, ver105 minus120bits = 556 'maxpower-120dB, ver105 minus130bits = 553 'maxpower-130dB, ver105 [end12bit] ' ver105 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 command address for specific computer 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, ver105 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. contclear = 11 'global control bits to take all command lines low cont1and2 = 3 'global control bits to activate PLL1/PLL2(EnaP),J1 and J2 cont3and4 = 15 'global control bits to activate PLL3/spare(EnaT)J3 and J4 contwclk = 9 'global control bits to take DDS wclk line high contfqud = 10 'global control bits to take DDS fqud line high contreset = 8 'global control bits to take DDS wclk and fqud lines high lepllj1 = 4 'global port data to send LE on J1 (PLL 1), if cont1and2 is set lepllj2 = 8 'global port data to send LE on J2 (PLL 2), if cont1and2 is set lepllj3 = 16 'global port data to send LE on J3 (PLL 3), if cont3and4 is set lepllj4 = 32 'global port data to send LE on J4 (spare), if cont3and4 is set (not used) out port, 0 'begin with all data lines low out control, contreset 'begin by resetting DDS (If hardware has diodes) out control, contclear 'begin with all command lines low dim datatable(800,2) ' ver106 '[CommandPLL3] PLL3output = PLL3off:gosub [SetUpPLL3]:trkgen = 0 'v103, this sets the PLL3 "off" frequency '[CommandPLL2]'will initialize, command R and command N for PLL2, set the Frequency of LO2 'need appxLO2,PLL2phasefreq,masterclock rcounter = int(masterclock / PLL2phasefreq) '64/4 = 16 ncounter = int(appxLO2/PLL2phasefreq) '1024/16 = 256 LO2 = appxLO2*(actualclock/masterclock) 'actual value of LO2 freq preselector = 32 '16,32 or 64 for preselector, use 32 fractional = 0 'enter 1 for Fractional-N, 0 for Integer-N;fractional not allowed for PLL2 phasepolarity = 1 'enter 0 for opamp, 1 for direct loop(no op amp) Jcontrol = cont1and2 'If PLL1 or PLL2, = cont1and2, for PLL3 or spare = cont3and4 LEPLL = lepllj2 'Latch/Enable: PLL1=lepllj1, PLL2=lepllj2, PLL3=lepllj3 fraction = 0 'fractions are not allowed for PLL2 if PLL2 = 2325 then gosub [Command2325R] if PLL2 = 2325 then gosub [Command2325N] if PLL2 = 2326 then gosub [Command2326R] if PLL2 = 2326 then gosub [Command2326N] if PLL2 = 2350 then gosub [Command2350R] if PLL2 = 2350 then gosub [Command2350N] if PLL2 = 2353 then gosub [Command2353R] if PLL2 = 2353 then gosub [Command2353N] if PLL2 = 4112 then gosub [Command4112R] if PLL2 = 4112 then gosub [Command4112N] if len(errora$)>0 then error$ = "PLL 2, " + errora$:errora$ = "" '[endSetUpPLL2] '[DeterminePLL1ReferenceDivider] 'need appxDDS,PLL1phasefreq,PLL1mode rcounter1 = 1 + int(appxDDS/PLL1phasefreq) 'determine PLL1 rcounter gosub [CommandPLL1ReferenceDivider] 'v104 '[endDeterminePLL1ReferenceDivider] '[SetUpWorkingWindow] using global variables gosub [createWorkingWindow] 'create Working Window with nominal values '[endSetUpWorkingWindow] 'and return here [GrabWorkingWindowData] 'get info from Working window to create Graph Window gosub [calcWindowInfo] '[endGrabWorkingWindowData] '[SetUpGraphWindow] 'create a boilerplate log graph for MC3356 gosub [CreateGraph] 'and then return here if harmonicwindow = 1 then print #harmonicwindow.image0button, "!setfocus" 'v105 print #main.hitkeybox, "!setfocus" 'make sure the "Hit any Key" box has the focus '[endSetUpGraphWindow] [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 '[endSweepFromStartFreq] [CalculateNextStep] 'create thisfreq,LO1,appxncounter 'need LO2,startfreq,stepfreq,thisstep,finalfreq thisfreq = startfreq + (stepfreq * thisstep) 'calculates input freq. at this new step LO1 = thisfreq + LO2 - finalfreq 'calculates the actual LO1 frequency appxphasef = appxDDS/rcounter1 'approximates the PLL1 phase freq. detector appxncounter = LO1/appxphasef 'approximates the Ncounter for PLL1 '[endCalculateNextStep] '[CreatePLL1] if PLL1mode = 0 then goto [CreatePLL1asInteger] '[CreatePLL1asFractional]'create Ncounter,fraction,actphasef, when PLL1 is Fractional-N ncounter = int(appxncounter) ndecimal = appxncounter - ncounter fraction1 = ndecimal * 16 fraction2 = fraction1 /10 fraction = 10*val(using("##.#",fraction2)) if fraction = 16 then ncounter = ncounter + 1 if fraction = 16 then fraction = 0 actphasef = LO1/(ncounter + (fraction/16)) ddsoutput = actphasef * rcounter1 'actual output of DDS(input Ref to PLL1) spur = 0 'reset spur, and determine if there is potential for a spur firstif = LO2 - finalfreq fractionalfreq = ddsoutput/(rcounter1*16) harnonicb = int(firstif/fractionalfreq) 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 fraction = fraction + 1 if fraction = 16 then ncounter = ncounter + 1 if fraction = 16 then fraction = 0 if fraction <0 then ncounter = ncounter - 1 if fraction <0 then fraction = 15 actphasef = LO1/(ncounter + (fraction/16)) ddsoutput = actphasef * rcounter1 'actual output of DDS(input Ref to PLL1) if spurcheck = 1 and (ddsoutputappxDDS) then fraction = fraction + 1 if fraction = 16 then ncounter = ncounter + 1 if fraction = 16 then fraction = 0 if fraction < 0 then ncounter = ncounter - 1 if fraction < 0 then fraction = 15 actphasef = LO1/(ncounter + (fraction/16)) ddsoutput = actphasef * rcounter1 'actual output of DDS(input Ref to PLL1) goto [CommandPLL1Ndivider] [CreatePLL1asInteger]'create PLL1 Ncounter,actphasef, and DDSoutput ncounter$ = using("####.#", appxncounter/10) 'rounding off appxncounter ncounter = 10*val(ncounter$) 'actual value for PLL1 Ncounter actphasef = LO1/ncounter 'actual phase freq for PLL1 fraction = 0 ddsoutput = actphasef * rcounter1 'actual output of DDS(input Ref to PLL1) '[endCreatePLL1] [CommandPLL1Ndivider] 'need ncounter,fraction,PLL1mode,cont1and2,lepllj1 glitch = 0 if (ncount = ncounter) and (fcount = fraction) then goto [endCommandPLL1Ndivider] 'don't waste time commanding PLL1 if it doesn't need to change frequency glitch=1 'add delay to prevent PLL settling glitch preselector = 32 '8,16,32 or 64 for preselector, use 16 when Fractional-N if PLL1mode = 1 then preselector = 16 Jcontrol = cont1and2 'If PLL1 or PLL2, = cont1and2, for TrackPLL = cont3and4 (3, 15) LEPLL = lepllj1 'Latch/Enable: PLL1=lepllj1,PLL2=lepllj2,PLL3=lepllj3 (4,8,16) if PLL1 = 2325 then gosub [Command2325N] if PLL1 = 2326 then gosub [Command2326N] if PLL1 = 2350 then gosub [Command2350N] if PLL1 = 2353 then gosub [Command2353N] if PLL1 = 4112 then gosub [Command4112N] if len(errora$)>0 then error$ = "PLL 1, " + errora$:errora$ = "" ncount = ncounter fcount = fraction [endCommandPLL1Ndivider] '[CommandDDS] 'command DDS if ddsoutput-appxDDS>xfilbw/2 then beep:error$="DDSoutput too high for filter" if appxDDS-ddsoutput>xfilbw/2 then beep:error$="DDSoutput too low for filter" if ddsoutput < lastddsoutput then glitch = 1 'add delay to prevent PLL settling glitch gosub [DDScommand] 'and return here lastddsoutput = ddsoutput '[endCommandDDS] '[SettleDownTime] for waittime=0 to (wats * 100)+(glitch*glitchtime) 'allows time for ckts to settle before data sampling next waittime '[endSettleDownTime] '[ReadLogData] 'A to D process to get Log Det video amplitude in bits if dabits = 8 then gosub [logData8Bit] 'and return here with bitsy value, ver106, name change if dabits = 12 then gosub [logData12Bit] 'and return here with bitsy value, ver105 '[endReadLogData] '[ConvertLogData] gosub [ConvertBitsToPower] 'and return with thispointpower = power relative to SSA input,v105 gosub [ConvertPowerToPixels] 'and return with thispointy,v105 datatable(thisstep,0) = thisstep 'put this step number into the array, line value= thisstep, ver106 datatable(thisstep,1) = thisfreq 'put this frequency into the array, line value= thisstep, ver106 datatable(thisstep,2) = thispointpower 'put this power measurement into the array, line value= thisstep, ver106 '[endConvertLogData] '[PlotLogData] gosub [PlotData] 'plot data using thisstep, x, steps, y, thispointy, lastpointx and lastpointy '[endPlotLogData] ' test= actphasef 'put in any variable for display in Message Box '[DetermineNextOperation] print #main.hitkeybox, "!contents? stop$" 'look at Hit any key box, stop sweep if anything there,v106 if len(stop$)>0 then gosub [Halted] ',v106 [IncrementOneStep] thisstep = thisstep + 1 'add 1 to step and continue sweeping if thisstep > steps then goto [SweepFromStartFreq] 'end of sweep, start over goto [CalculateNextStep] '[endIncrementOneStep] '---------------------------------------------------------------- 'The following are subroutines used in above steps [CommandPLL1ReferenceDivider] 'v104, now a subroutine rcounter = rcounter1 preselector = 32 '16,32 or 64 for preselector, use 32 fractional = PLL1mode 'PLL1mode is 1 for fractional-N, 0 for integer-N phasepolarity = 0 'enter 0 for opamp, 1 for direct loop Jcontrol = cont1and2 'If PLL1 or PLL2, = cont1and2, for TrackPLL = cont3and4 (3, 15) LEPLL = lepllj1 'Latch/Enable: PLL1=lepllj1, PLL2=lepllj2,PLL3=lepllj3 (4,8,16) if PLL1mode = 1 then preselector = 16 if PLL1 = 2325 then gosub [Command2325R] if PLL1 = 2326 then gosub [Command2326R] if PLL1 = 2350 then gosub [Command2350R] if PLL1 = 2353 then gosub [Command2353R] if PLL1 = 4112 then gosub [Command4112R] if len(errora$)>0 then error$ = "PLL 1, " + errora$:errora$ = "" return '[endCommandPLL1ReferenceDivider] [logData8Bit] 'from [ReadLogData], Successive Approximation subroutine converts Log Det to bitsy (binary) ' if inp(status) < 128 then busy (status bit 7) line is high (D/A 127 then busy line is low (D/A>log det. voltage) out port, 128 'set D/A MSB to "1", creates 2.5v out of D/A ladder, ver105 onetwentyeight = 128 'ver105 if inp(status) > 127 then onetwentyeight = 0 'ver105 out port, onetwentyeight + 64 'ver105 sixtyfour = 64 'ver105 if inp(status) > 127 then sixtyfour = 0 'ver105 out port, onetwentyeight + sixtyfour+32 'ver105 thirtytwo = 32 'ver105 if inp(status) > 127 then thirtytwo = 0 'ver105 out port, onetwentyeight + sixtyfour+thirtytwo+16 'ver105 sixteen = 16 'ver105 if inp(status) > 127 then sixteen = 0 'ver105 out port, onetwentyeight + sixtyfour+thirtytwo+sixteen+8 'ver105 eight = 8 'ver105 if inp(status) > 127 then eight = 0 'ver105 out port, onetwentyeight + sixtyfour+thirtytwo+sixteen+eight+4 'ver105 four = 4 'ver105 if inp(status) > 127 then four = 0 'ver105 out port, onetwentyeight + sixtyfour+thirtytwo+sixteen+eight+four+2 'ver105 two = 2 'ver105 if inp(status) > 127 then two = 0 'ver105 out port, onetwentyeight + sixtyfour+thirtytwo+sixteen+eight+four+two+1 'ver105 one = 1 'ver105 if inp(status) > 127 then one = 0 'ver105 out port, 0 'return data to zero 'ver105 bitsy = onetwentyeight+sixtyfour+thirtytwo+sixteen+eight+four+two+one 'ver105 return '[endlogData8bit] [logData12Bit] 'from [ReadLogData], Successive Approximation subroutine converts Log Det to bitsy (12bitbinary) ' if inp(status) < 128 then busy (status bit 7) line is high (D/A 127 then busy line is low (D/A>log det. voltage) out port,0 'preset to zero, ver105 out port,0 +64 +32 +16 'latch 0 into all 3 latches ver105 twentyfortyeight = 8 tentwentyfour = 4 fivetwelve = 2 twofiftysix = 1 onetwentyeight = 8 sixtyfour = 4 thirtytwo = 2 sixteen = 1 eight = 8 four = 4 two = 2 one = 1 out port,8 +16 +32 ' put 8 into MSB latch, D/A = 2048 creates 2.5v out of D/A ladder, ver105 if inp(status) > 127 then twentyfortyeight = 0 ' ver105 out port,twentyfortyeight +4 +16 +32 ' put 4 into MSB latch, D/A = 1024 if inp(status) > 127 then tentwentyfour = 0 out port,twentyfortyeight +tentwentyfour +2 +16 +32 ' put 2 into MSB latch, D/A = 512 if inp(status) > 127 then fivetwelve = 0 out port,twentyfortyeight +tentwentyfour +fivetwelve +1 +16 +32 ' put 1 into MSB latch, D/A = 256 if inp(status) > 127 then twofiftysix = 0 out port,twentyfortyeight +tentwentyfour +fivetwelve +twofiftysix +16 +32 ' put appxm. into MSB latch, D/A = appx out port,twentyfortyeight +tentwentyfour +fivetwelve +twofiftysix +16 +32 +64 ' latch MSB with appx out port,8 +16 +64 ' put 8 into middle latch, D/A = 128 if inp(status) > 127 then onetwentyeight = 0 out port,onetwentyeight +4 +16 +64 ' put 4 into middle latch, D/A = 64 if inp(status) > 127 then sixtyfour = 0 out port,onetwentyeight +sixtyfour +2 +16 +64 ' put 2 into middle latch, D/A = 32 if inp(status) > 127 then thirtytwo = 0 out port,onetwentyeight +sixtyfour +thirtytwo +1 +16 +64 ' put 1 into middle latch, D/A = 16 if inp(status) > 127 then sixteen = 0 out port,onetwentyeight +sixtyfour +thirtytwo +sixteen +16 +64 ' put appxm. into middle latch, D/A = appx out port,onetwentyeight +sixtyfour +thirtytwo +sixteen +16 +32 +64 ' latch middle with appx out port,8 +32 +64 ' put 8 into LSB latch, D/A = 8 if inp(status) > 127 then eight = 0 out port,eight +4 +32 +64 ' put 4 into LSB latch, D/A = 4 if inp(status) > 127 then four = 0 out port,eight +four +2 +32 +64 ' put 2 into LSB latch, D/A = 2 if inp(status) > 127 then two = 0 out port,eight +four +two +1 +32 +64 ' put 1 into LSB latch, D/A = 1 if inp(status) > 127 then one = 0 out port, 0 'return data to zero 'ver105 bitsy = (twentyfortyeight*256)+(tentwentyfour*256)+(fivetwelve*256)+(twofiftysix*256)+(onetwentyeight*16)+(sixtyfour*16)+(thirtytwo*16)+(sixteen*16)+eight+four+two+one 'ver105 return ' ver105 '[endlogData12Bit] [ConvertBitsToPower] 'convert Log bits to power using cal table if bitsy < minus130bits then power = maxpower-130 if bitsy >= minus130bits and bitsy = minus120bits and bitsy = minus110bits and bitsy = minus100bits and bitsy = minus90bits and bitsy = minus80bits and bitsy = minus70bits and bitsy = minus60bits and bitsy = minus50bits and bitsy = minus40bits and bitsy = minus30bits and bitsy = minus20bits and bitsy = minus10bits and bitsy = maxbits then power = maxpower'v105 if dabits = 8 then thispointpower = val(using("####.#",power))-gain 'round off power to .1 dB, ssa power 'v106 if dabits = 12 then thispointpower = val(using("####.##",power))-gain 'round off power to .01 dB, ssa power 'v106 return [ConvertPowerToPixels] 'v105 if thispointpower > scale0power then thispointy = maxscale 'v105 if thispointpower <= scale0power and thispointpower >= scale10power then thispointy = maxscale*(thispointpower-scale10power)/(scale0power-scale10power) 'v105 if thispointpower < scale10power then thispointy = 0 'v105 return [PlotData] 'plot data using thisstep, x, steps, y, thispointy, lastpointx and lastpointy 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)-thispointy 'display a data line during normal sweep if rewrite = 1 then print #handle, "line ";thispointx;" ";(y-1)-thispointy;" ";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)-thispointy return 'return to [endPlotLogData] [insertMarker] 'display marker info (vertical line and data info) print #handle, "line ";thispointx;" ";(y-15)-thispointy;" ";thispointx;" ";(y-2)-thispointy print #handle, "line ";thispointx;" ";y+6;" ";thispointx;" ";y+10 print #handle, "\\"; thisfreq;" MHz\";bitsy; " = bits\";thispointpower;" dBm" 'v105 return 'return to (if thisstep = marker(x) then gosub) [createWorkingWindow] 'from StepOne 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 'ver106 statictext #main.finalif, "Final I.F.", 5, 65, 40, 12 'ver106 statictext #main.centerfreq, "Center Frequency", 323, 1, 120, 12 'ver106 statictext #main.centerfreq2, "MHz", 408, 18, 30, 12 'ver106 statictext #main.placemarkers, "Place Markers at Steps:", 598, 1, 120, 12 'ver106 statictext #main.topref, "Top Ref Line", 725, 1, 70, 12 'v106 statictext #main.topref2, "dBm", 765, 18, 30, 12 'v106 statictext #main.filter, "Select Final Filter:", 10, 25, 100, 12 'ver106 statictext #main.sweepwidth, "Sweep Width:", 320, 40, 80, 12 'ver106 statictext #main.sweepwidth2, "MHz", 383, 59, 30, 12 'ver106 statictext #main.stepspersweep, "Steps/Sweep", 415, 40, 80, 12 'ver106 statictext #main.stepspersweep2, "1-720", 460, 59, 40, 12 'ver106 statictext #main.mhzperstep, "MHz/Step:", 530, 40, 80, 12 'ver106 statictext #main.waittime, "Wait", 643, 40, 60, 12 'ver106 statictext #main.botref, "Bot Ref Line", 725, 40, 70, 12 'ver106 statictext #main.botref2, "dBm", 765, 59, 30, 12 'ver106 statictext #main.resolutionbw, "Res. B.W.", 5, 88, 50, 12 'ver106 statictext #main.hitanykey, "Hit any key", 5, 107, 80, 12 'ver106 statictext #main.hitanykey2, "on keyboard", 5, 120, 80, 12 'ver106 statictext #main.hitanykey3, "to Halt sweep", 5, 135, 80, 12 'ver106 statictext #main.thisstep, "Step", 285, 90, 50, 15 'ver106 statictext #main.thisfreq, "This Freq", 333, 90, 50, 15 'ver106 statictext #main.thispower, "Power", 450, 90, 50, 12 'ver106 statictext #main.leftclick, "LeftClick", 220, 110, 50, 12 'ver106 statictext #main.rightclick, "RightClick", 220, 133, 50, 15 'ver106 TextboxColor$ = "red" 'the following textboxes will be red textbox #main.centerfreqbox, 325, 15, 80, 20 ' create Center Freq box 'ver106 textbox #main.marker1box, 600, 15, 30, 20 'create Marker box 1 'ver106 textbox #main.marker2box, 640, 15, 30, 20 'create Marker box 2 'ver106 textbox #main.marker3box, 680, 15, 30, 20 'create Marker box 3 'ver106 textbox #main.toprefbox, 725, 15, 35, 20 'create top reference line box 'ver106 textbox #main.sweepwidthbox, 325, 55, 55, 20 'create Sweep Width box,ver106 textbox #main.stepspersweepbox, 420, 55, 35, 20 'create Steps per Sweep box 'ver106 textbox #main.waitbox, 640, 55, 35, 20 ' create Wait box 'ver106 textbox #main.botrefbox, 725, 55, 35, 20 'create bottom reference linebox 'ver106 textbox #main.hitkeybox, 85, 120, 30, 20 'create Hit any Key box 'ver106 TextboxColor$ = "blue" 'the following textboxes will be blue textbox #main.msgbox, 65, 3, 210, 20 ' create Message box 'ver106 textbox #main.finalifbox, 65, 62, 65, 20 ' create Final IF box, ver106 textbox #main.resolutionbox, 65, 86, 65, 20 ' create Resolution BW box, ver106 textbox #main.mhzperstepbox, 522, 55, 80, 20 'create MHz per step box 'ver106 textbox #main.stepnobox, 280, 106, 35, 20 'create step box v106 textbox #main.thisfreqbox, 320, 106, 75, 20 'create This Freq box v106 textbox #main.thispowerbox, 435, 106, 65, 20 'create Power box v106 textbox #main.stepnobox2, 280, 130, 35, 20 'create step box v106 textbox #main.thisfreqbox2, 320, 130, 75, 20 'create This Freq box v106 textbox #main.thispowerbox2, 435, 130, 65, 20 'create Power box v106 button #main.f1button, "F1", [button1], UL, 5, 38, 25, 20 'ver106 button #main.f2button, "F2", [button2], UL, 35, 38, 25, 20 'ver106 button #main.f3button, "F3", [button3], UL, 65, 38, 25, 20 'ver106 button #main.f4button, "F4", [button4], UL, 95, 38, 25, 20 'ver106 button #main.centerbutton, "Cent", [centerbutton], UL, 400, 106, 30, 20 'ver106 button #main.harmbutton, "Harmonic Window", [CreateHarmonicWindow], UL, 522, 80, 95, 20 'ver106 button #main.trkbutton, "Track Gen is OFF", [Trkbutton], UL, 522, 105, 95, 20 'ver106 button #main.spurbutton, "Spur Test is OFF", [Spurtest], UL, 522, 130, 95, 20 'ver106 button #main.rewrite, "REWRITE", [Rewrite], UL, 640, 80, 58, 20 'ver106 button #main.onestep, "ONESTEP", [OneStep], UL, 640, 105, 58, 20 'ver106 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 'ver106 open "Working Window for Spectrum Analyzer, version 106" for dialog as #main 'ver106 print #main, "trapclose [finished]" 'goto [finished] if xit is clicked print #main.finalifbox, "";finalfreq;" MHz" 'default final I.F. freq 'ver106 print #main.resolutionbox, "";finalbw;" KHz" 'default resolution BW 'ver106 print #main.centerfreqbox, "";cf 'default center freq print #main.sweepwidthbox, "";sw 'default sweep width print #main.stepspersweepbox, "";sps 'default steps per sweep print #main.marker1box, "";mkr1 'insert mkr1 default in Marker1 box print #main.marker2box, "";mkr2 'insert mkr2 default in Marker2 box print #main.marker3box, "";mkr3 'insert mkr3 default in Marker3 box print #main.waitbox, "";wat 'insert wat default in wait box print #main.toprefbox, "";topref 'insert default top reference line 'v105 print #main.botrefbox, "";botref 'insert default bottom reference line 'v105 return 'return to [endStepOne] '[endCreateWorkingWindow] [calcWindowInfo] 'from [GrabWorkingWindowData] print #main.centerfreqbox, "!contents? centfreq$"; 'Center Freq box print #main.sweepwidthbox, "!contents? widthfreq$"; 'Sweep Width box print #main.stepspersweepbox, "!contents? steps$"; 'Steps per Sweep box print #main.marker1box, "!contents? mark1$"; 'Marker1 box print #main.marker2box, "!contents? mark2$"; 'Marker2 box print #main.marker3box, "!contents? mark3$"; 'Marker3 box print #main.waitbox, "!contents? wats$"; 'Wait box print #main.toprefbox, "!contents? scale0pwr$"; 'Top reference box, v105 print #main.botrefbox, "!contents? scale10pwr$"; 'Bottom reference box, 'v105 scale0power = val(scale0pwr$) 'Log Det power, in dBm, v105 scale10power = val(scale10pwr$) 'Log Det power, in dBm, v105 if scale0power>maxpower-gain then scale0power = maxpower-gain:print #main.toprefbox, "";maxpower-gain ' v105 if scale10power>=scale0power then scale10power = scale0power-10:print #main.botrefbox, "";scale0power-10 ' v105 marker1 = val(mark1$) marker2 = val(mark2$) marker3 = val(mark3$) centfreq = val(centfreq$) widthfreq = val(widthfreq$) steps = val(steps$) wats = val(wats$) startfreq = centfreq - widthfreq/2 'start frequency of sweep stepfreq = widthfreq/steps 'delta step frequency print #main.mhzperstepbox, stepfreq 'MHz per step box return 'goto [endGrabWorkingWindowData] '[endcalcWindowInfo] [LeftButDown] 'when left mouse button is pressed, do the following, ver106 leftdownpixelx = MouseX ' ver106 if leftdownpixelx > x then leftdownpixelx=x ' ver106 leftstep = int(steps*leftdownpixelx/x) ' ver106 print #main.stepnobox,datatable(leftstep,0) ' ver106 print #main.thisfreqbox,datatable(leftstep,1) ' ver106 print #main.thispowerbox,datatable(leftstep,2);" dBm" ' ver106 wait ' ver106 [RightButDown] 'when left mouse button is pressed, do the following, ver106 rightdownpixelx = MouseX ' ver106 if rightdownpixelx > x then rightdownpixelx=x ' ver106 rightstep = int(steps*rightdownpixelx/x) ' ver106 print #main.stepnobox2,datatable(rightstep,0) ' ver106 print #main.thisfreqbox2,datatable(rightstep,1) ' ver106 print #main.thispowerbox2,datatable(rightstep,2);" dBm" ' ver106 lowerfreq = datatable(leftstep,1) ' ver106 upperfreq = datatable(rightstep,1) ' ver106 if lowerfreq>upperfreq then lowerfreq=datatable(rightstep,1):upperfreq=datatable(leftstep,1) ' ver106 newsweepwidth = upperfreq-lowerfreq ' ver106 newcenterfreq = lowerfreq + newsweepwidth/2 ' ver106 print #main.centerfreqbox, "";newcenterfreq ' ver106 print #main.sweepwidthbox, "";newsweepwidth ' ver106 wait ' ver106 [centerbutton]'this will take the contents of the "This Freq" box and put it in the "Center Frequency" box print #main.thisfreqbox, "!contents? newcentfreq$" ' ver106 print #main.centerfreqbox, "";newcentfreq$ ' ver106 wait [CreateGraph] 'from [SetUpGraphWindow] 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 Spectrum Analyzer, version 106" for graphics_nsb as #handle 'ver106 print #handle, "when leftButtonDown [LeftButDown]" ' ver106 print #handle, "when rightButtonDown [RightButDown]" ' ver106 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 ' v105 print #handle, "\";scale0power;" dBm" 'print reference pwr level ' v105 print #handle, "line ";0;" ";y-.9*maxscale;" ";x;" ";y-.9*maxscale ' v105 print #handle, "\";scale0power - .1*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.8*maxscale;" ";x;" ";y-.8*maxscale ' v105 print #handle, "\";scale0power - .2*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.7*maxscale;" ";x;" ";y-.7*maxscale ' v105 print #handle, "\";scale0power - .3*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.6*maxscale;" ";x;" ";y-.6*maxscale ' v105 print #handle, "\";scale0power - .4*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.5*maxscale;" ";x;" ";y-.5*maxscale ' v105 print #handle, "\";scale0power - .5*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.4*maxscale;" ";x;" ";y-.4*maxscale ' v105 print #handle, "\";scale0power - .6*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.3*maxscale;" ";x;" ";y-.3*maxscale ' v105 print #handle, "\";scale0power - .7*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.2*maxscale;" ";x;" ";y-.2*maxscale ' v105 print #handle, "\";scale0power - .8*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y-.1*maxscale;" ";x;" ";y-.1*maxscale ' v105 print #handle, "\";scale0power - .9*(scale0power - scale10power);" dBm" ' v105 print #handle, "line ";0;" ";y;" ";x;" ";y ' v105 print #handle, "\";scale10power;" dBm" ' v105 print #handle, "place 205 380" print #handle, "\ Center Frequency is: "; centfreq; " MHz Sweep Width is: ";widthfreq;" MHz" print #handle, "flush" 'make the graph lines stick return 'goto [endSetUpGraphWindow] '[EndCreateGraph] [Halted] 'from [DetermineNextOperation], Sweep has Halted, do the following, ver106 gosub [Reprintlines] 'retrace graph lines when sweep is stopped, ver106 print #main.msgbox,error$;" ";test 'will print error and whatever "test=" is, ver106 print #main.stepnobox,thisstep ' ver106 print #main.thisfreqbox,thisfreq ' ver106 print #main.thispowerbox,thispointpower;" dBm" ' ver106 wait 'wait until any button is clicked [Reprintlines] print #handle, "line ";0;" ";y-maxscale;" ";x;" ";y-maxscale 'draw a reference line for top power ' v105 print #handle, "line ";0;" ";y-.9*maxscale;" ";x;" ";y-.9*maxscale ' v105 print #handle, "line ";0;" ";y-.8*maxscale;" ";x;" ";y-.8*maxscale ' v105 print #handle, "line ";0;" ";y-.7*maxscale;" ";x;" ";y-.7*maxscale ' v105 print #handle, "line ";0;" ";y-.6*maxscale;" ";x;" ";y-.6*maxscale ' v105 print #handle, "line ";0;" ";y-.5*maxscale;" ";x;" ";y-.5*maxscale ' v105 print #handle, "line ";0;" ";y-.4*maxscale;" ";x;" ";y-.4*maxscale ' v105 print #handle, "line ";0;" ";y-.3*maxscale;" ";x;" ";y-.3*maxscale ' v105 print #handle, "line ";0;" ";y-.2*maxscale;" ";x;" ";y-.2*maxscale ' v105 print #handle, "line ";0;" ";y-.1*maxscale;" ";x;" ";y-.1*maxscale ' v105 print #handle, "line ";0;" ";y;" ";x;" ";y ' v105 print #handle, "flush" 'make the graph lines stick return [DDScommand]'Command AD9850 DDS, globals required:ddsoutput,masterclock,contwclk,contclear,contfqud base=(ddsoutput*2^32/masterclock) '32 bit frequency code in decimal w1= int(base/2^24) 'w1 thru w4 converts decimal code to 4 words of 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,0 'a "1" here will activate the x4 internal multiplier, but not recommended out control, contwclk 'wclk line goes high out control, contclear 'wclk line goes low 'set word 1 out port,w1:out control,contwclk:out control, contclear 'set word 2 out port,w2:out control,contwclk:out control, contclear 'set word 3 out port,w3:out control,contwclk:out control, contclear 'set word 4 out port,w4:out control,contwclk:out control, contclear out port, 0 'return the output port data lines to 0 'send fqud out control, contfqud 'set fqud to 1, freq changes now out control, contclear 'set fqud to 0 and all others to 0 return '9825 has finished commanding, go back to [endCommandDDS] '[endDDScommand] [Command2325R]'create and command LMX2325 Rbuffer 'globals required: rcounter,preselector,Jcontrol,contclear, LEPLL 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 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 the clk, data, and LE to PLLs 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, r0:out port, r0 + 2 out port, LEPLL:out port, 0 'Latch R data into PLL out control, contclear 'Disable the Control Board clk,data,and LE buffer return '[endCommand2325R] [Command2325N] 'create and command LMX2325 Nbuffer 'globals required: ncounter,preselector,Jcontrol,LEPLL,contclear 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 clk,data,and LE buffer 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 '[endCommand2326R] [Command2326N]'create and command N buffer 'need ncounter,Jcontrol,LEPLL,contclear Bcounter = int(ncounter/32) Acounter = int(ncounter-(Bcounter*32)) if Bcounter < 3 then beep:errora$="2326 N counter <3" if Bcounter > 8191 then beep:errora$="2326 N 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]'globals required: none, IF section is turned off ifr23=0 'osc. 0=separate ifr22=1 'fraction, 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]'globals required: none, 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, In power down mode 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] 'globals required:Jcontrol,LEPLL,contclear out control, Jcontrol 'enable the Control Board clk,data,and LE buffer 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 clk,data,and LE buffer return '[endCommand2350R] [Command2350N]'create and command RFN buffer '[CreateRFNbuffer2350] 'globals required: ncounter,preselector,fraction Bcounter = int(ncounter/preselector) Acounter = int(ncounter-(Bcounter*preselector)) if Bcounter < 3 then beep:errora$="2350 Rcounter <3" if Bcounter > 1023 then beep:errora$="2350 Rcounter >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]'globals reqd: Jcontrol, LEPLL 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]'globals reqd: LEPLL '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]globals reqd: LEPLL, contclear '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 clk,data,and LE buffer return '[endCommand2353R] [Command2353N]'create and command LMX2353 N buffer '[Create2353Nbuffer]'globals reqd: ncounter,preselector,fraction 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 + 1 then beep:errora$ = "2353 Bcounter < Acounter+1" nbit0 = 1 'n address bit 0 nbit1 = 1 'n address bit 1 f0 = int(fraction/2):nbit2 = fraction - 2*f0 'fraction bit 0 f1 = int(f0/2):nbit3 = f0 - 2*f1 'fraction bit 1 f2 = int(f1/2):nbit4 = f1 - 2*f2 'fraction bit 2 f3 = int(f2/2):nbit5 = f2 - 2*f3 'fraction 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 nbit22 = 0 'power down if 1 nbit23 = 0 'counter reset if 1 '[Command2353NBuffer]' globals reqd: Jcontrol, LEPLL, contclear out control, Jcontrol 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 the Control Board clk,data,and LE buffer return '[endCommand2353N] [Command4112R]'create and command Init and R buffers '[Create4112InitBuffer]'need phasepolarity,preselector I24=1 'I24,23 prescaler: 0=8, 1=16, 2=32, 3=64 I23=0 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 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 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]'need Jcontrol,LEPLL,contclear 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]'need rcounter 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]'need Jcontrol,LEPLL,contclear 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]'create and command N buffer 'need ncounter,Jcontrol,LEPLL,contclear,preselector 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 counter0 then error$ = "PLL 3, " + errora$:errora$ = "" return [Spurtest] if spurcheck = 0 and PLL1mode = 0 then rcounter1=rcounter1+1:gosub[CommandPLL1ReferenceDivider] 'v104 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[CommandPLL1ReferenceDivider] 'v104 if spurcheck = 1 then print #main.spurbutton, "Spur Test is OFF":spurcheck=0:wait [CreateHarmonicWindow] 'v105 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 [finished] close #main 'close out working window close #handle 'close out graph window if harmonicwindow = 1 then close #harmonicwindow 'close out harmonicwindow 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 N counter <3" ' "2326 N 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 data is placed in the "Step", "This Freq", and "Power" boxes 'placing the mouse pointer on the graph and clicking the left Mouse button will grab the closest step and place 'that point's data into the "Step", "This Freq", and "Power" boxes 'placing the mouse pointer on the graph and clicking 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 begin a new sweep with the new "Center Frequency" and "Sweep Width" 'Clicking the "Cent" button will install the "This Freq" box data, into the "Center Frequency" box.