Setting Up and make a Phase Noise Measurement

This example program makes a Phase Noise measurement. The trace 1 shows a phase noise. The trace 2 shows an allan deviation.

This VBScript program can be run as a macro in the analyzer. To do this, copy the code into a text editor file such as Notepad and save on the analyzer SSD as PN_Setup.vbs. Learn how to setup and run the macro.

 

See Also

See Other SCPI Example Programs

'

'  Phase Noise - basic measurement

'

Dim app

Dim scpi

Dim NoP

Dim data_x1

Dim data_y1

Dim data_x2

Dim data_y2

Dim strTemp

Dim objFSO

Dim objFile

'

' Create / Get the SSA application.

Set app = CreateObject("AgilentPNA835x.Application")

Set scpi = app.ScpiStringParser

scpi.parse "SYST:FPR"

' Set the trigger source at Manual.

scpi.parse "TRIG:SOUR MAN"

'

' Create a Phase Noise channel and parameters

scpi.parse "DISP:WIND1 ON"

scpi.parse "DISP:WIND2 ON"

scpi.parse "CALC:MEAS1:DEF 'PN:Phase Noise'"

scpi.parse "DISP:MEAS1:FEED 1"

scpi.parse "CALC:MEAS2:DEF 'ADEV:Phase Noise'"

scpi.parse "DISP:MEAS2:FEED 2"

'

' Set Carrier frequency to 3 GHz

scpi.parse "SENS:PN:SWE:CARR:FREQ 3.0e9"

' Set Start/Stop Offset to 1 kHz and 10 MHz

scpi.parse "SENS:FREQ:STAR 1e3"

scpi.parse "SENS:FREQ:STOP 10e6"

' Set RBW Ratio to 5 %

scpi.parse "SENS:PN:BWID:RES:RAT 5"

' Set Cross Correlation factor to 10

scpi.parse "SENS:PN:CORR:COUNt 10"

' Set measurement port at RF input 1

scpi.parse "SENS:PN:PORT 1"

'

' Make a trigger

scpi.parse "INIT:IMM"

StrTemp= scpi.parse("*OPC?")

'

' Get the number of points

NoP = scpi.parse(":SENS1:SWE:POIN?")

' Get the data for X axis and phase noise result

StrTemp = scpi.parse(":CALC1:MEAS1:DATA:X?")

data_x1 = Split(StrTemp, ",")

StrTemp = scpi.parse(":CALC1:MEAS1:DATA:FDAT?")

data_y1 = Split(StrTemp, ",")

' Get the data for X axis and ADEV result

StrTemp = scpi.parse(":CALC1:MEAS2:DATA:X?")

data_x2 = Split(StrTemp, ",")

StrTemp = scpi.parse(":CALC1:MEAS2:DATA:FDAT?")

data_y2 = Split(StrTemp, ",")

'

' Saving the result into a file

Set objFSO = WScript.CreateObject("Scripting.FileSystemObject")

If Err.Number = 0 Then

    Set objFile = objFSO.OpenTextFile("Result.csv", 2, True)

    If Err.Number = 0 Then

       ' Output Phase Noise result into the file.

       objFile.Writeline("Number of Data:"&NoP)

       objFile.Writeline("PN")

       For i = 0 To NoP-1

          objFile.Writeline(data_x1(i)&", "&data_y1(i))

       Next

       ' Output ADEV result into the file.

       objFile.Writeline("ADEV")

       ' The number of data in Allan Valiance is returned :SENS1:SWE:POIN?

       ' However, the actual number of measurement data is fewer than the number from :SENS1:SWE:POIN?

       ' The last value will be filled in the remaining data points.

       i=0

       do

          objFile.Writeline(data_x2(i)&", "&data_y2(i))

          i=i+1

       Loop until data_x2(i)=data_x2(i-1) ' Store the data until the same value appears.

       

       objFile.Close

    Else

        WScript.Echo "File Open Error: " & Err.Description

    End If

Else

    WScript.Echo "Error: " & Err.Description

End If

Set objFile = Nothing

Set objFSO = Nothing