The example programs show how to create basic Vector Signal Analyzer measurement setups. The following are provided:
This VBScript program can be run as a macro in the VNA. To do this, copy the code into a text editor file such as Notepad and save on the VNA hard drive as VSA.vbs. Learn how to setup and run the macro.
See the Vector Signal Analyzer commands.
See Other SCPI Example Programs
' Demonstration of basic one channel Vector Signal Analyzer measurement setup. set app = createobject("Agilentpna835x.application") app.visible = true set p = app.scpistringparser sub main Dim curVal '----------------------------------------------------------------- 'Preset VNA and switch to VSA Link p.parse("SYST:FPR") p.parse("*OPC?") p.parse("CALC1:CUST:def 'trace1_1', 'Vector Signal Analyzer','A'") p.parse("*OPC?") p.parse("DISP:WIND1:STAT ON") p.parse("*OPC?") p.parse("DISP:WIND1:TRACe1:FEED 'trace1_1'") p.parse("*OPC?") '----------------------------------------------------------------- '----------------------------------------------------------------- 'Start up (if there's no Glacier instance running) and connect to Glacier p.parse("SENS1:VSA:CONN 1") p.parse("*OPC") call CheckESR '----------------------------------------------------------------- '----------------------------------------------------------------- 'Load a VNA state file. 'Once the state file is recalled,VNA automatically starts a new measurement cycle, during which the 'corresponding Glacier's state file will be recalled and Glacier wrapper's instance will be set up. 'After the data 'being sent to Glacier for the first time, we reckon that the recalling process is done. 'But "*OPC?" is apparently not sufficient to tell the user that information, therefore '":CALC:VSA:REC:DONE?" has been introduced for doing so. '":CALC:VSA:REC:DONE?" is mandatory. p.parse("MMEM:LOAD '1ChanWLAN.csa'") call CheckRecall '----------------------------------------------------------------- 'Clear and reset the data descriptors of the data that the users would like to query out from Glacier. p.parse("CALCulate:VSA:DATA:RES") p.parse("CALC:VSA:DATA:TABL:DEFine 'SmmaryData',4,'EVM'") 'Trace D EVM p.parse("CALC:VSA:DATA:VECT:DEFine 'Spectrum',2") 'Trace B Spectrum Y Data p.parse("CALC:VSA:DATA:MARK:DEFine 'Marker1',1,1,'X'") 'Trace A Marker 1 XData p.parse("CALC:VSA:DATA:MARK:DEFine 'Marker2',2,2,'Y'") 'Trace B Marker 2 Y 'curVal = p.parse("CALC:VSA:DATA:CAT?") 'curVal = trimCrLf(curVal) 'msgbox(curVal) '----------------------------------------------------------------- 'Start a single sweep. Data is only retrieved from Glacier when both VNA and Glacier work in singe mode. 'Checking ESR is madatory. p.parse("SENS1:SWE:MODE SING") curVal = p.parse("*OPC") call checkesr '----------------------------------------------------------------- 'Query out the data curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker1'") curVal = trimCrLf(curVal) msgbox(curval) curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker2'") curVal = trimCrLf(curVal) msgbox(curval) curVal = p.parse("CALC:VSA:DATA:VECT? 'Spectrum'") curVal = trimCrLf(curVal) msgbox(curval) curVal = p.parse("CALC:VSA:DATA:TABL? 'SmmaryData'") curVal = trimCrLf(curVal) msgbox(curval) '----------------------------------------------------------------- 'Another sweep and query out the data p.parse("SENS1:SWE:MODE SING") curVal = p.parse("*OPC") call checkesr curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker2'") curVal = trimCrLf(curVal) 'msgbox(curval) curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker1'") curVal = trimCrLf(curVal) 'msgbox(curval) curVal = p.parse("CALC:VSA:DATA:VECT? 'Spectrum'") curVal = trimCrLf(curVal) 'msgbox(curval) curVal = p.parse("CALC:VSA:DATA:TABL? 'SmmaryData'") curVal = trimCrLf(curVal) 'msgbox(curval) end sub
Function trimCrLf(src) srcNull = VarType(src) If srcNull = vbNull Then trimCrLf = "" Else src = Trim(src) lenSrc = Len(src) If lenSrc <= 0 Then trimCrLf = "" ElseIf lenSrc = 1 Then trimCrLf = trim1Char(src) ElseIf lenSrc = 2 Then trimCrLf = trim2Chars(src) Else leftSrc = Left(src, lenSrc - 2) rightSrc = Right(src, 2) trimCrLf = leftSrc& trim2Chars(rightSrc) End If End If End Function Function trim1Char(src) If src = vbCr Or src = vbLf Then trim1Char = "" Else trim1Char = src End If End Function Function trim2Chars(src) If src = vbCrLf Then trim2Chars = "" Else last1Char = Right(src, 1) If last1Char = vbCr Or last1Char = vbLf Then trim2Chars = Left(src, 1) Else trim2Chars = src End If End If End Function sub CheckESR Do strReply = p.parse("*ESR?") esrByte = CByte(strReply) Loop While (esrByte And 1) = 0 end sub sub CheckRecall Do strReply = p.parse(":CALC:VSA:REC:DONE?") val= CBool(strReply) Loop While val <> True end sub |
' Demonstration of basic two channel Vector Signal Analyzer measurement setup. set app = createobject("Agilentpna835x.application") app.visible = true set p = app.scpistringparser sub main Dim curVal '----------------------------------------------------------------- 'Preset VNA and switch to VSA Link p.parse("SYST:FPR") p.parse("CALC1:CUST:def 'trace1_1', 'Vector Signal Analyzer','A'") p.parse("DISP:WIND1:STAT ON") curVal = trimCrLf(curVal) p.parse("DISP:WIND1:TRACe1:FEED 'trace1_1'") '----------------------------------------------------------------- 'Start up (if there's no Glacier instance running) and connect to Glacier p.parse("SENS1:VSA:CONN 1") p.parse("*OPC") call checkesr '----------------------------------------------------------------- 'Load a VNA state file. 'Once the state file is recalled,VNA automatically starts a new measurement cycle, during which the 'corresponding Glacier's state file will be recalled and Glacier wrapper's instance will be set up. 'After the data 'being sent to Glacier for the first time, we reckon that the recalling process is done. 'But "*OPC?" is apparently not sufficient to tell the user that information, therefore '":CALC:VSA:REC:DONE?" has been introduced for doing so. '":CALC:VSA:REC:DONE?" is mandatory. p.parse("MMEM:LOAD '2channels.csa'") call checkrecall 'p.parse("SYST:CHAN:SING:COMB 1,6") 'curVal = p.parse("*OPC") 'call checkesr '----------------------------------------------------------------- 'Clear and reset the data descriptors of the data that the users would like to query out from Glacier. p.parse("CALC:VSA:DATA:RES") p.parse("CALC:VSA:DATA:VECT:DEFine 'Spectrum1',1") p.parse("CALC:VSA:DATA:VECT:DEFine 'Spectrum2',3") p.parse("CALC:VSA:DATA:MARK:DEFine 'Marker1',1,1,'Y'") p.parse("CALC:VSA:DATA:MARK:DEFine 'Marker2',3,1,'X'") '----------------------------------------------------------------- 'Start a single sweep. Data is only retrieved from Glacier when both VNA and Glacier work in singe mode. 'Checking ESR is madatory. p.parse("SYST:CHAN:SING:COMB 1,6") curVal = p.parse("*OPC") call checkesr '----------------------------------------------------------------- 'Query out the data curVal = trimCrLf(curVal) curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker1'") curVal = trimCrLf(curVal) msgbox(curval) curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker2'") curVal = trimCrLf(curVal) msgbox(curval) curVal = p.parse("CALC:VSA:DATA:VECT? 'Spectrum1'") curVal = trimCrLf(curVal) msgbox(curval) curVal = p.parse("CALC:VSA:DATA:VECT? 'Spectrum2'") curVal = trimCrLf(curVal) msgbox(curval) '----------------------------------------------------------------- 'Another sweep and query out the data p.parse("SYST:CHAN:SING:COMB 1,6") curVal = p.parse("*OPC") call checkesr curVal = trimCrLf(curVal) curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker1'") curVal = trimCrLf(curVal) curVal = p.parse("CALC:VSA:DATA:MARK? 'Marker2'") curVal = trimCrLf(curVal) curVal = p.parse("CALC:VSA:DATA:VECT? 'Spectrum1'") curVal = trimCrLf(curVal) curVal = p.parse("CALC:VSA:DATA:VECT? 'Spectrum2'") curVal = trimCrLf(curVal) end sub
Function trimCrLf(src) srcNull = VarType(src) If srcNull = vbNull Then trimCrLf = "" Else src = Trim(src) lenSrc = Len(src) If lenSrc <= 0 Then trimCrLf = "" ElseIf lenSrc = 1 Then trimCrLf = trim1Char(src) ElseIf lenSrc = 2 Then trimCrLf = trim2Chars(src) Else leftSrc = Left(src, lenSrc - 2) rightSrc = Right(src, 2) trimCrLf = leftSrc& trim2Chars(rightSrc) End If End If End Function Function trim1Char(src) If src = vbCr Or src = vbLf Then trim1Char = "" Else trim1Char = src End If End Function Function trim2Chars(src) If src = vbCrLf Then trim2Chars = "" Else last1Char = Right(src, 1) If last1Char = vbCr Or last1Char = vbLf Then trim2Chars = Left(src, 1) Else trim2Chars = src End If End If End Function sub CheckESR Do strReply = p.parse("*ESR?") esrByte = CByte(strReply) Loop While (esrByte And 1) = 0 end sub sub CheckRecall Do strReply = p.parse(":CALC:VSA:REC:DONE?") val= CBool(strReply) Loop While val <> True end sub |