;Spurious Measurement GUI ;Test Instrument: Anritsu Cell Master MT8212E ;USB Mac Address: USB0::0x0B5B::0xFFF9::1511024_265_26 ;Obtained from RUN\NI-Visa Interactive Control ;Creator: Dan Tran ;DateCreated: 03/2/2018 #include #include #include #include #include #include #include #include ;==Test Preparation MsgBox(0,"Spurious Test Preparation", "Ensure DC Blocks are attached as shown in figure 6 to protect all equipment from DC damage." & @CRLF & @CRLF & "Ensure SG max RMS power is 0dBm to protect the potential RF power damage to the Krato converter RF Input (0dBm max)." & @CRLF & @CRLF & "Turn Signal Generator (SG) RF outputs to OFF." & @CRLF & @CRLF & "On Krato’s front panel or rear management port, configure IP addresses and subnet mask as shown in figure 1." & @CRLF & @CRLF & "Configure the PC static IP address to the same management port subnet and subnet mask.") MsgBox(0,"Krato AD Converter 1 Setup", "Log into Krato converter (1) via its management port and configure it with the following settings." & @CRLF & @CRLF & "<<< Control - RF Input >>>" & @CRLF & "Stream BW: 15 MHz" & @CRLF & "Stream Offset: 0 MHz" & @CRLF & "Center freq.: 65.75 MHz" & @CRLF & "A/D Bits: 12 Bits" & @CRLF & "System BW: 40 MHz" & @CRLF & "Gain Mode: Manual" & @CRLF & "Manual Gain: X dB so RF OUT Pwr. = RF IN Pwr." & @CRLF & "Destination IP: Refer to Figure 1" & @CRLF & "Max Packet Size: 1500 bytes by default" & @CRLF & "Min Delay: Normal, no red flash" & @CRLF & "Packet Protection: Check (FEC enables)" & @CRLF & @CRLF & "<<< Control - RF Output >>>" & @CRLF & "Data Source: LocalPackets" & @CRLF & "Output Enable: Uncheck" & @CRLF & @CRLF & "Save Configuration as: Krato Test Config") MsgBox(0,"Krato AD Converter 2 Setup", "Log into Krato converter (2) via its management port and configure it with the following settings." & @CRLF & @CRLF & "<<< Control - RF Input >>>" & @CRLF & "Output Enable: Uncheck" & @CRLF & @CRLF & "<<< Control - RF Output >>>" & @CRLF & "Data Source: Network" & @CRLF & "Programmed Buffer: 80 msec" & @CRLF & "Use Local Reference: Check" & @CRLF & "Manual Override: Uncheck" & @CRLF & "Attenuation: 0 dB" & @CRLF & "Spectral Inversion: Uncheck" & @CRLF & "Output Enable: Check" & @CRLF & @CRLF & "Save Configuration as: Krato Test Config") ;==Input Test Parameters Input_Test_Parameters() Func Input_Test_Parameters() ;Create a GUI with various controls. Local $hGUI = GUICreate("Spur Test Input Parameters", 350, 175) ;Create a combobox control. Local $idTestFreqInc = GUICtrlCreateCombo ("Select Test Freq Increment", 75, 25, 200, 25) Local $idSGAdd = GUICtrlCreateCombo ("Select SG GPIB Address", 75, 75, 200, 25) Local $idConfirm = GUICtrlCreateButton("Confirm", 125, 125, 150, 25) ;Add additional items to the comboboxes. GUICtrlSetData($idTestFreqInc, "01 kHz|02 kHz|04 kHz|05 kHz|10 kHz|20 kHz|25 kHz|50 kHz|100 kHz|2.5 MHz|5.0 MHz", "Select Test Freq Increment") GUICtrlSetData($idSGAdd, "1|2|3|4|5", "Select SG GPIB Address") ;Display the GUI. Beep (500, 500) GUISetState(@SW_SHOWNORMAL, $hGUI) Local $sComboRead = "" ;Loop until the user exits. While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $idConfirm If GUICtrlRead($idTestFreqInc) = "Select Test Freq Increment" Or GUICtrlRead($idSGAdd) = "Select SG GPIB Address" Then Beep (500, 500) ; Do nothing when not all selections are selected. Else ExitLoop EndIf Case $idTestFreqInc $sComboRead = GUICtrlRead($idTestFreqInc) Select Case $sComboRead = "01 kHz" Global $TestFreqInc = 0.001 Case $sComboRead = "02 kHz" Global $TestFreqInc = 0.002 Case $sComboRead = "04 kHz" Global $TestFreqInc = 0.004 Case $sComboRead = "05 kHz" Global $TestFreqInc = 0.005 Case $sComboRead = "10 kHz" Global $TestFreqInc = 0.010 Case $sComboRead = "20 kHz" Global $TestFreqInc = 0.020 Case $sComboRead = "25 kHz" Global $TestFreqInc = 0.025 Case $sComboRead = "50 kHz" Global $TestFreqInc = 0.050 Case $sComboRead = "100 kHz" Global $TestFreqInc = 0.100 Case $sComboRead = "2.5 MHz" Global $TestFreqInc = 2.500 Case $sComboRead = "5.0 MHz" Global $TestFreqInc = 5.000 EndSelect Case $idSGAdd Global $SGAdd = GUICtrlRead($idSGAdd) EndSwitch WEnd ; Delete the previous GUI and all controls. GUIDelete($hGUI) EndFunc ;==Instrument Addresses Initialization Global $SAMacAdd = "USB0::0x0B5B::0xFFF9::1511024_265_26" Global $SGGpibAdd = "GPIB::" & $SGAdd & "::0" MsgBox(0, "GPIB Address", "Set GPIB@ for SG = " & $SGAdd) ;==Wait For SA Function Func WaitForSA() Do $SweepStatus = Number(_viExecCommand($SAMacAdd, "STAT:OPER?", 1000)) ; Seek for SA sweep completion string 256 and converts it into number 256 Until ($SweepStatus = 256) EndFunc ;==SG Reset Beep(1000, 500) ; SG auto Reset prompt. $SG_Reset = MsgBox(1, "Agilent E4433B", "SG Reset?") If $SG_Reset = 2 Then Exit EndIf _viExecCommand($SGGpibAdd, "*RST", 1000) ; SG Reset Sleep(2000) ;==SA Reset and Preliminary Setup Beep(1000, 500) ; SA manual Master Reset prompt. MsgBox(0, "SA MT8212E", "Begin of ALL Test, manually Master Reset the SA." & @CRLF & @CRLF & "Master reset will Errase all Internal user files !!!" & @CRLF & @CRLF & "Press Shift + 8, System Options, Reset, Master Reset, Enter." & @CRLF & @CRLF & "Wait for SA to reboot (<60 Sec)." & @CRLF & @CRLF & "Press Menu and select Spectrum Analyzer.") Beep(1000, 500) ; SA auto Preset prompt. $SA_Preset = MsgBox(1, "SA MT8212E", "SA Preset?") If $SA_Preset = 2 Then Exit EndIf _viExecCommand($SAMacAdd, "SYST:PRES", 1000) ; SA Preset WaitForSA() _viExecCommand($SAMacAdd, "FREQ:CENT 65.75 MHz", 1000) ; Set SA CF WaitForSA() _viExecCommand($SAMacAdd, "FREQ:SPAN 15 MHz", 1000) ; Set SA SPAN WaitForSA() _viExecCommand($SAMacAdd, "DISP:WIND:TRAC:Y:SCAL:RLEV 0 dBm", 1000) ; SA reference level WaitForSA() _viExecCommand($SAMacAdd, "DISP:WIND:TRAC:Y:SCAL:PDIV 10 dB", 1000) ; SA dB per division WaitForSA() _viExecCommand($SAMacAdd, "CALC:MARK1:MODE POS", 1000) ; SA Marker 1 activated WaitForSA() MsgBox(0,"","SA Setup Ends") ;==Begin Test Timer $hTimer = TimerInit() ;==SG Setup, SA Setup, and Measure spurious _viExecCommand($SGGpibAdd, "OUTP:MOD:STATE OFF", 1000) ; Set SG modulation to OFF For $CF = 60 To 70 Step 10 _viExecCommand($SGGpibAdd, "FREQ " & $CF & " MHz", 1000) ; Set SG CF Sleep (1000) $SGPwr = -15 _viExecCommand($SGGpibAdd, "POW:AMPL " & $SGPwr & " dBm", 1000) ; Set SG initial power level Sleep (1000) _viExecCommand($SGGpibAdd, "OUTP:STATE ON", 1000) ; Set SG RF output to ON Sleep(1000) _viExecCommand($SAMacAdd, "INIT:IMM", 1000) ; Initiate 1 sweep for SA WaitForSA() ;Calibrate SG RF output power to -6dBm _viExecCommand($SAMacAdd, "CALC:MARK1:MAX", 1000) ; Set SA marker at peak power WaitForSA() $SAPeakPwr = Number(_viExecCommand($SAMacAdd, "CALC:MARK1:Y?", 1000)) ; Aquires Y value string and converts it into a number WaitForSA() MsgBox(0,"","SAPeakPwr: " & $SAPeakPwr & "dBm") While Abs(-6 - $SAPeakPwr) > 0.1 ; Adjust SG Tx RF power level if SA peak power is > 0.1dB difference from -6dBm Select Case (-6 - $SAPeakPwr) > 1.00 $SGPwr = $SGPwr + 1.00 Case (-6 - $SAPeakPwr) > 0.50 $SGPwr = $SGPwr + 0.50 Case (-6 - $SAPeakPwr) > 0.10 $SGPwr = $SGPwr + 0.10 Case (-6 - $SAPeakPwr) > 0.05 $SGPwr = $SGPwr + 0.05 Case (-6 - $SAPeakPwr) > 0.01 $SGPwr = $SGPwr + 0.01 Case (-6 - $SAPeakPwr) < -1.00 $SGPwr = $SGPwr - 1.00 Case (-6 - $SAPeakPwr) < -0.50 $SGPwr = $SGPwr - 0.50 Case (-6 - $SAPeakPwr) < -0.10 $SGPwr = $SGPwr - 0.10 Case (-6 - $SAPeakPwr) < -0.05 $SGPwr = $SGPwr - 0.05 Case (-6 - $SAPeakPwr) < -0.01 $SGPwr = $SGPwr - 0.01 EndSelect _viExecCommand($SGGpibAdd, "POW:AMPL " & $SGPwr & " dBm", 1000) ; Adjust SG Tx RF power level Sleep(1000) MsgBox(0,"","SGPwr: " & $SGPwr & "dBm") _viExecCommand($SAMacAdd, "INIT:IMM", 1000) ; Initiate 1 sweep for SA WaitForSA() _viExecCommand($SAMacAdd, "CALC:MARK1:MAX", 1000) ; Seek for SA peak power WaitForSA() $SAPeakPwr = Number(_viExecCommand($SAMacAdd, "CALC:MARK1:Y?", 1000)) ; Aquires Y value string and converts it into a number WaitForSA() MsgBox(0,"","SAPeakPwr: " & $SAPeakPwr & "dBm") WEnd _viExecCommand($SAMacAdd, "TRACe1:WRIT:STAT ON", 1000) ; Return SA Trace1 back on Write WaitForSA() MsgBox(0,"","SG Setup Ends") ;Seek and Measure Spurious Select ; Test carrier frequency initialization Case $CF = 60 ; Frequency span is 2.5MHz with center frequency at 60MHz $TestFreqStart = 60 - 1.25 $TestFreqStop = 60 + 1.25 Case $CF = 70 ; Frequency span is 5.0MHz with center frequency at 70MHz $TestFreqStart = 70 - 2.5 $TestFreqStop = 70 + 2.5 EndSelect MsgBox(0,"","TestFreqStart: " & $TestFreqStart) MsgBox(0,"","TestFreqStop: " & $TestFreqStop) Global $CF60MaxSpurPwr = -120 ; Initialize max spur power to -80dBm Global $CF70MaxSpurPwr = -120 ; Initialize max spur power to -80dBm Global $CF60MaxSpurFreq = 58.50 ; Initialize max spur frequency to 58.50MHz Global $CF70MaxSpurFreq = 67.25 ; Initialize max spur frequency to 67.25MHz Global $CF60MaxSpurTestFreq = 58.50 ; Initialize max spur test frequency to 58.50MHz Global $CF70MaxSpurTestFreq = 67.25 ; Initialize max spur test frequency to 67.25MHz Global $TestFreq = 0 For $TestFreq = $TestFreqStart To $TestFreqStop Step $TestFreqInc ; Stepping the test carrier frequency with the chosen frequency increment _viExecCommand($SGGpibAdd, "FREQ " & $TestFreq & " MHz", 1000) ; Set SG test carrier frequency Sleep(1000) MsgBox(0,"","TestFreq: " & $TestFreq) ScanForSpur(58.50, 61.50) ; Start spurious scan from 58.50MHz to 61.50MHz in the 60MHz band ScanForSpur(67.25, 72.75) ; Start spurious scan from 67.25MHz to 72.75MHz in the 70MHz band Next ; Spurious scanner function Func ScanForSpur($SpurFreqStart, $SpurFreqStop) _viExecCommand($SAMacAdd, "CALC:MARK1:X " & $SpurFreqStart & " MHz" , 1000) ; Set spur search marker at the begining of the 60MHz band WaitForSA() Do _viExecCommand($SAMacAdd, "CALCulate:MARKer:MAX:RIGH", 1000) ; Search for the next right peak power WaitForSA() _viExecCommand($SAMacAdd, "TRACe1:OPER MAXH", 1000) ; Max hold SA Trace1 for 5 seconds Sleep(5000) Local $SpurPwr = Number(_viExecCommand($SAMacAdd, "CALC:MARK1:Y?", 1000)) ; Aquires Y value string and converts it into a number WaitForSA() Local $SpurFreq = Number(_viExecCommand($SAMacAdd, "CALC:MARK1:X?", 1000)) ; Aquires X value string and converts it into a number WaitForSA() $SpurFreq = $SpurFreq / 1000000 ; Records SA marker1 frequency in MHz If ($SpurPwr < -10) And ($SpurFreq <= $SpurFreqStop) Then ; Ignore test carrier at -6dBm peak and spur beyond 61.25MHz as 60MHz inband spurious Select Case $CF = 60 If $SpurPwr > $CF60MaxSpurPwr Then $CF60MaxSpurPwr = $SpurPwr ; Save spur peak power as max spur power $CF60MaxSpurFreq = $SpurFreq ; Acquires marker1 frequency $CF60MaxSpurTestFreq = $TestFreq ; Record the test frequency EndIf Case $CF = 70 If $SpurPwr > $CF70MaxSpurPwr Then $CF70MaxSpurPwr = $SpurPwr ; Save spur peak power as max spur power $CF70MaxSpurFreq = $SpurFreq ; Acquires marker1 frequency $CF70MaxSpurTestFreq = $TestFreq ; Record the test frequency EndIf EndSelect EndIf _viExecCommand($SAMacAdd, "TRACe1:OPER NORM", 1000) ; Turn SA operation back to normal WaitForSA() Until $SpurFreq > $SpurFreqStop EndFunc MsgBox(0,"","Measure spur ends") ;Record Spurious _viExecCommand($SAMacAdd, "TRACe1:OPER NORM", 1000) ; Turn SA operation back to normal WaitForSA() Select ; Prepare SA screen capture Case $CF = 60 _viExecCommand($SGGpibAdd, "FREQ " & $CF60MaxSpurTestFreq & " MHz", 1000) ; Set SG frequency to Max spurious test frequency Sleep(1000) _viExecCommand($SAMacAdd, "TRACe1:OPER MAXH", 1000) ; Max hold SA Trace1 for 5 seconds Sleep(5000) _viExecCommand($SAMacAdd, "CALC:MARK1:X " & $CF60MaxSpurFreq & " MHz" , 1000) ; Set SA marker1 frequency to max spurious carrier frequency WaitForSA() $Filename = "Worst_Spurious_CF60MHz_SPAN2.5MHz" Case $CF = 70 _viExecCommand($SGGpibAdd, "FREQ " & $CF70MaxSpurTestFreq & " MHz", 1000) ; Set SG frequency to Max spurious test frequency Sleep(1000) _viExecCommand($SAMacAdd, "TRACe1:OPER MAXH", 1000) ; Max hold SA Trace1 for 5 seconds Sleep(5000) _viExecCommand($SAMacAdd, "CALC:MARK1:X " & $CF70MaxSpurFreq & " MHz" , 1000) ; Set SA marker1 frequency to max spurious carrier frequency WaitForSA() $Filename = "Worst_Spurious_at_CF70MHz_SPAN5.0MHz" EndSelect MsgBox(0,"","Prepare SA screen capture ends") ; Save SA screen capture into USB storage $FilenameQuote = StringFormat("%s%s%s", Chr(34), $Filename, Chr(34)); Add double quotations to the Filename _viExecCommand($SAMacAdd, ":MMEM:MSIS:DEST USB", 1000) ; Select Destination USB storage, Internal is the Source storage WaitForSA() _viExecCommand($SAMacAdd, ":MMEM:STOR:JPEG " & $FilenameQuote, 1000) ; Select JPEG image format and filename WaitForSA() _viExecCommand($SAMacAdd, ":MMEM:MSIS:COPY", 1000) ; Store the screen capture to the internal storage, and copy all from the internal storage out to the Destination USB WaitForSA() Next MsgBox(0,"","Save into USB ends") ;==Test Conclusion _viExecCommand($SGGpibAdd, "OUTP:STATE OFF", 1000) ; SG RF output to OFF WaitForSA() _viExecCommand($SAMacAdd, "TRACe1:OPER NORM", 1000) ; Turn trace back to normal operation WaitForSA() ;==End Test Timer $fDiff_ms = TimerDiff($hTimer) ; In millisecond $fDiff_Min = Round($fDiff_ms/1000/60, 2) Beep(1000, 500) MsgBox($MB_SYSTEMMODAL, "", "Test Time: " & $fDiff_Min & " Minutes")