'11-30-04 msaversion101, will work with SSAP, SSAB, or MSA 'The globals are preset for Spectrum Analyzer Board SSAB and with 'all PLLs as LMX2353's. PLL2 operates as Integer PLL, PLL1 and 3 are Fractional 'For troubleshooting, email this file back to me with your global changes 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 = 10.695 'freq of Final Xtal Filter # 1 finalbw1 = 2.6 'BW (in KHz)of Final Xtal Filter # 1 sagain1 = 16.1 'total gain of SA with Final Filter #1 installed finalfreq2 = 11.15 'freq of Final Xtal Filter # 2 finalbw2 = 2.0 'BW (in KHz)of Final Xtal Filter # 2 sagain2 = 16.1 'total gain of SA with Final Filter #2 installed finalfreq3 = 10.67 'freq of Final Xtal Filter # 3 finalbw3 = .2 'BW (in KHz)of Final Xtal Filter # 3 sagain3 = 2.2 '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 = 16.4 'total gain of SA with Final Filter #4 installed appxLO2 = 1024 '2nd LO frequency,1024 MHz or greater, 4 MHz steps PLL1 = 2353 'enter PLL type, (LMX) 2325, 2326, 2350, 2353 PLL2 = 2353 'enter PLL type, (LMX) 2325, 2326, 2350, 2353, 0 for SRD PLL3 = 2353 'enter PLL type, (LMX) 2325, 2326, 2350, 2353, 0 for no Tracking Generator PLL1phasefreq = 3.57 'This is the maximum Phase Detector Frequency (PDF) for PLL 1 PLL1mode = 1 '1 = Fractional Mode, 0 = Integer Mode PLL2phasefreq = 4 '2nd LO's PLL2 phase frequency is 4 MHz PLL3phasefreq = .08 'TrkGen LO's PLL3 phase frequency, which will determine step size PLL3mode = 1 '1 = Fractional Mode, 0 = Integer Mode appxDDS = 10.7 'this DDS output(Ref. for PLL1), and center freq. of DDS xtal filter xfilbw = .0075 'this is the DDS xtal filter bandwidth, must be > .0045 (MHz) glitchtime = 5000 'this is time added when the DDS or PLL changes drastically 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) y = 300 'graph vertical is 300 pixels in amplitude(y) windowwide = 800 'working and graph windows are 800 pixels wide windowhigh = 180 '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 sagain = sagain1 'default gain for SA using sagain1 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 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, contclear 'begin with all command lines low PLL3output = 1000:gosub [SetUpPLL3]:trkgen = 0 'set TG's PLL3 to 1000 MHz '[CommandPLL2]'will initialize, command R and command N for PLL2 '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 phasepolarity = 1 'enter 0 for opamp, 1 for direct loop Jcontrol = cont1and2 'If PLL1 or PLL2, = cont1and2, for TrackPLL = cont3and4 (3, 15) LEPLL = lepllj2 'Latch/Enable: PLL1=lepllj1, PLL2=lepllj2,PLL3=lepllj3 (4,8,16) 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] '[CommandPLL1ReferenceDivider] 'need appxDDS,PLL1phasefreq,PLL1mode rcounter1 = 1 + int(appxDDS/PLL1phasefreq) 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$ = "" '[endSetUpPLL1ReferenceDivider] '[SetUpWorkingWindow] using global variables gosub [createWorkingWindow] 'create Working Window with nominal values '[endSetUpWorkingWindow] 'and return here [GrabWorkingWindowData] 'get info from working window to gosub [calcWindowInfo] 'create Graph and start sweep '[endGrabWorkingWindowData] '[SetUpGraphWindow] 'create a boilerplate log graph for MC3356 gosub [CreateGraph] 'and then return here 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 glitch=0 'reset glitch counter 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 PLL1 Ncounter,fraction,actphasef ncounter = int(appxncounter) '(284) ndecimal = appxncounter - ncounter '(.31196) fraction1 = ndecimal * 16 '(4.99136) fraction2 = fraction1 /10 '(.499136) fraction = 10*val(using("##.#",fraction2)) '(5) 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 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 '16, or 32 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 print #main.thisfreqbox, thisfreq 'Print this frequency into This Freq box..takes 0.3 msec. '[endSettleDownTime] '[ReadLogData] 'iterate D/A to get Video amplitude gosub [logData] 'and return here with thispointy value out port, 0 '[endReadLogData] '[PlotLogData] gosub [PlotData] '[endPlotLogData] test=0 '[DetermineNextOperation] gosub [CheckHitAnyKey] 'check for "Hit Any Key" box Input, [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 [logData] 'from [ReadLogData] out port, thispointy 'this was the last sweep data logged ' if inp(status) < 128 then busy (status bit 7) line is high (analog voltage >A/D data) ' if inp(status) > 127 then busy line is low (analog voltage 127 then goto [IterateLower] [IterateHigherFirst] 'until A/D is too high thispointy = thispointy + 10 if thispointy > 255 then thispointy = 255 out port, thispointy if inp(status) < 128 and thispointy = 255 then return if inp(status) < 128 then goto [IterateHigherFirst] [IterateLower] 'until A/D is too low thispointy = thispointy - 5 if thispointy < 0 then thispointy = 0 out port, thispointy if inp(status) > 127 and thispointy = 0 then return if inp(status) > 127 then goto [IterateLower] [IterateHigherLast] 'until A/D goes high by one bit thispointy = thispointy + 1 if thispointy = 255 then return out port, thispointy if inp(status) < 128 then goto [IterateHigherLast] return [PlotData] 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 if thispointy < db90 then power = -90 if thispointy >= db90 and thispointy = db80 and thispointy = db70 and thispointy = db60 and thispointy = db50 and thispointy = db40 and thispointy = db30 and thispointy = db20 and thispointy = db10 and thispointy <256 then power = -10*(db0-thispointy)/(db0-db10) power = val(using("####.#",power)) print #handle, "\\"; thisfreq;" MHz\";thispointy; " = bits\";power-gain;" dBm" 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 of the screen BackgroundColor$ = "darkblue" ForegroundColor$ = "white" TextboxColor$ = "red" 'the following textboxes will be red statictext #main.finalif, "Final I.F. Freq:", 22, 50, 80, 20 statictext #main.centerfreq, "Center Freq:", 245, 20, 80, 20 textbox #main.centerfreqbox, 325, 16, 88, 25 ' create Center Freq box statictext #main.filter, "Final Filter:", 245, 50, 80, 20 statictext #main.message, "Messages:", 245, 80, 50, 20 statictext #main.sweepwidth, "Sweep Width:", 22, 20, 80, 20 statictext #main.sweepwidthmhz, "MHz", 165, 20, 30, 20 statictext #main.mhzperstep, "MHz per step:", 22, 80, 80, 20 statictext #main.stepspersweep, "Steps per Sweep:", 522, 50, 80, 30 statictext #main.hitanykey, "Hit any key....", 22, 105, 80, 20 statictext #main.tostopsweep, "to stop sweep", 22, 120, 80, 20 statictext #main.thisfreq, "This Freq:", 270, 110, 50, 20 statictext #main.centerfreqmhz, "MHz", 423, 20, 50, 20 statictext #main.stepspersweep2, "Use submult up to 720", 655, 55, 200, 20 statictext #main.placemarkers, "Place Markers at Steps:", 480, 20, 120, 20 statictext #main.wait, "Sweep Time", 522, 85, 70, 20 textbox #main.waitbox, 602, 80, 35, 25 ' create Wait box textbox #main.sweepwidthbox, 102, 16, 55, 25 'create Sweep Width box textbox #main.stepspersweepbox, 602, 50, 35, 25 'create Steps per Sweep box textbox #main.marker1box, 602, 16, 35, 25 'create Marker box 1 textbox #main.marker2box, 655, 16, 35, 25 'create Marker box 2 textbox #main.marker3box, 708, 16, 35, 25 'create Marker box 3 textbox #main.hitkeybox, 102, 106, 30, 25 'create Hit any Key box TextboxColor$ = "blue" 'the following textboxes will be blue textbox #main.finalifbox, 102, 46, 88, 25 ' create Final IF box textbox #main.msgbox, 300, 76, 210, 25 ' create Message box textbox #main.thisfreqbox, 325, 106, 88, 25 'create This Freq box textbox #main.mhzperstepbox, 102, 76, 88, 25 'create MHz per step box button #main.f1button, "F1", [button1], UL, 325, 46, 25, 25 button #main.f2button, "F2", [button2], UL, 355, 46, 25, 25 button #main.f3button, "F3", [button3], UL, 385, 46, 25, 25 button #main.f4button, "F4", [button4], UL, 415, 46, 25, 25 button #main.rewrite, "REWRITE", [Rewrite], UL, 650, 80, 58, 25 button #main.rewcont, "REW.CONT", [Rewcont], UL, 720, 80, 65, 25 button #main.restart, "RESTART", [Restart], UL, 580, 108, 58, 25 button #main.onestep, "ONESTEP", [OneStep], UL, 650, 108, 58, 25 button #main.continue, "CONTINUE", [Continue], UL, 720, 108, 65, 25 button #main.trkbutton, "Track Gen is OFF", [Trkbutton], UL, 450, 108, 90, 25 if PLL1mode=1 then button #main.spurbutton, "Spur Test is OFF", [Spurtest], UL, 150, 108, 90, 25 open "Working Window for Spectrum Analyzer" for dialog as #main print #main, "trapclose [finished]" 'goto [finished] if xit is clicked print #main.finalifbox, "";finalfreq;" / ";finalbw;" KHz" 'default final I.F. freq 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 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 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] [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" for graphics_nsb as #handle print #handle, "trapclose [finished]" 'goto [finished] if xit is clicked db0 = 255 'these are initial values db10 = 241 'and should be modified during db20 = 212 'calibration procedure db30 = 184 db40 = 156 db50 = 124 db60 = 96 db70 = 63 db80 = 38 db90 = 22 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 gain = sagain print #handle, "line ";0;" ";y-db0;" ";x;" ";y-db0 'draw a reference line print #handle, "\";0-gain;" dBm" 'print reference pwr level print #handle, "\";0-10-gain;" dBm" print #handle, "line ";0;" ";y-db10;" ";x;" ";y-db10 print #handle, "line ";0;" ";y-db20;" ";x;" ";y-db20 print #handle, "\";0-20-gain;" dBm" print #handle, "line ";0;" ";y-db30;" ";x;" ";y-db30 print #handle, "\";0-30-gain;" dBm" print #handle, "line ";0;" ";y-db40;" ";x;" ";y-db40 print #handle, "\";0-40-gain;" dBm" print #handle, "line ";0;" ";y-db50;" ";x;" ";y-db50 print #handle, "\";0-50-gain;" dBm" print #handle, "line ";0;" ";y-db60;" ";x;" ";y-db60 print #handle, "\";0-60-gain;" dBm" print #handle, "line ";0;" ";y-db70;" ";x;" ";y-db70 print #handle, "\";0-70-gain;" dBm" print #handle, "line ";0;" ";y-db80;" ";x;" ";y-db80 print #handle, "\";0-80-gain;" dBm" print #handle, "\";0-90-gain;" dBm" print #handle, "line ";0;" ";y-db90;" ";x;" ";y-db90 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] [CheckHitAnyKey] 'from [CheckForHalt] 'The following will stop the sweeping if any key is typed into the hitanykeybox. print #main.hitkeybox, "!contents? stop$"; 'look at Hit any key box if len(stop$)>0 then gosub [Reprintlines] if len(stop$)>0 then print #main.msgbox,error$;" ";test if len(stop$)>0 then wait 'if hitanykeybox has data, then wait for button click return 'goto[endCheckForHalt] [Reprintlines] print #handle, "line ";0;" ";y-db0;" ";x;" ";y-db0 'draw a reference line print #handle, "line ";0;" ";y-db10;" ";x;" ";y-db10 print #handle, "line ";0;" ";y-db20;" ";x;" ";y-db20 print #handle, "line ";0;" ";y-db30;" ";x;" ";y-db30 print #handle, "line ";0;" ";y-db40;" ";x;" ";y-db40 print #handle, "line ";0;" ";y-db50;" ";x;" ";y-db50 print #handle, "line ";0;" ";y-db60;" ";x;" ";y-db60 print #handle, "line ";0;" ";y-db70;" ";x;" ";y-db70 print #handle, "line ";0;" ";y-db80;" ";x;" ";y-db80 print #handle, "line ";0;" ";y-db90;" ";x;" ";y-db90 print #handle, "flush" 'make the graph lines stick return [DDScommand]'Command DDS, globals required:ddsoutput,masterclock,contwclk,contclear,contfqud base=(ddsoutput*2^32/masterclock) '32 bit frequency code in decimal w1= int(base/2^24) 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 out port,0 'set data of W0 to 0, phase info out control, contwclk 'wclk high out control, contclear 'wclk 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 'goto [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 rfr18=1 'RF charge pump sel, 4 Bits 100ua/bit LSB 0 rfr19=1 'current = (100ua * bit value)+100ua rfr20=1 '800ua = 0111, 100ua to 1600ua rfr21=1 'RF charge pump sel, 4 Bits 100ua/bit MSB 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 IF, 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 'Charge pump control, 100ua x1 +100ua rbit19 = 1 'Charge pump control, 100ua x2 +100ua rbit20 = 1 'Charge pump control, 100ua x4 +100ua rbit21 = 1 'Charge pump control, 100ua x8 +100ua rbit22 = 0 '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 then print #main.spurbutton, "Spur Test is ON":spurcheck=1:wait if spurcheck = 1 then print #main.spurbutton, "Spur Test is OFF":spurcheck=0:wait [finished] close #main 'close out working window close #handle 'close out graph window end ' error messages ' "DDSoutput too high for filter" ' "DDSoutput too low for 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"