These example programs use the SetAllSegments_Method and GetAllSegments Method to do the following:
Creates a 2-dimensional array (7 x 10) 7 data elements that define each segment x 10 segments
Uploads the data to the VNA
Downloads a segment table from the VNA
This program does not make sweep type = segment or show the segment table.
The comments indicate the order in which the segment elements are specified: Index 0 - segment state, Index 4 is IFBW, and so forth.
See Other COM Example Programs
This VBScript (*.vbs) program can be run as a macro in the VNA. To do this, copy the following code into a text editor file such as Notepad and save on the VNA hard drive as *.vbs. Learn how to setup and run the macro.
' Create the application instance, and preset the application |
Option Explicit Dim app Set app = CreateObject("AgilentPNA835x.Application") Dim chan Set chan = app.ActiveChannel chan.sweeptype = 4 Dim segs Set segs = chan.Segments Dim win Set win = app.NAWindows(1) win.ShowTable 2 Dim segData segData = segs.GetAllSegments ' Get lower bound and upper bound on the data values per each segment Dim segDataLB, segDataUB segDataLB = LBound(segData,1) segDataUB = UBound(segData,1) ' Get lower bound and upper bound corresponding to how many segments Dim segArrayLB, segArrayUB segArrayLB = LBound(segData,2) segArrayUB = UBound(segData,2) ' If the VB LBound and UBound functions didn't generate an error ' before reaching this point, that implies a valid two-dimensional ' array was returned into 'segData'. WScript.Echo "Number of segments = " & segArrayUB - segArrayLB + 1 WScript.Echo "Number of data values per segment = " & segDataUB - segDataLB + 1 Dim index index = segDataLB Dim segInfStr segInfStr = "Segment 1: state = " & segData(index, segArrayLB) index = index + 1 segInfStr = segInfStr & ", num points = " & segData(index, segArrayLB) index = index + 1 segInfStr = segInfStr & ", start freq = " & segData(index, segArrayLB) index = index + 1 segInfStr = segInfStr & ", stop freq = " & segData(index, segArrayLB) index = index + 1 segInfStr = segInfStr & ", IFBW = " & segData(index, segArrayLB) index = index + 1 segInfStr = segInfStr & ", dwell time = " & segData(index, segArrayLB) ' In case of a measurement receiver VNA like N5264B ' which has no source ports, chan.SourcePortNames will ' return an empty variant (no array) Dim srcPortNames srcPortNames = chan.SourcePortNames Dim srcPortNamesLB, srcPortNamesUB srcPortNamesUB = -1 On Error Resume Next srcPortNamesLB = LBound(srcPortNames) srcPortNamesUB = UBound(srcPortNames) On Error GoTo 0 If (srcPortNamesUB >= 0) And ((srcPortNamesUB - srcPortNamesLB + 1) <> (segDataUB - index)) Then WScript.Echo "Mismatch in number of source port names!" End If Dim j For j = index + 1 To segDataUB segInfStr = segInfStr & ", " & srcPortNames(j - (index + 1) + srcPortNamesLB) & " power = " & segData(j, segArrayLB) Next WScript.Echo segInfStr |