Friday, January 31, 2014

Spectrum Analyzer Based Phase Noise/Jitter Measurement with Golden PLL in Excel


Demo of the GUI
Today is a big day to all Chinese in the world, the Lunar Chinese New Year, and I’d like to wish all a lucky, happy, healthy and wealthy year of horse ahead!
It’s a time for many Chinese to party and eat to the heart’s content with good excuses to avoid feeling guilty and at the same time make the resolution for the whole new year. More than often, we tend to wait for a “proper” time for the real action to follow for reasons such as “busy to clear things on hand first”, “need to wait for a good chunk of time” and in the end, the chances are "the right time" never comes. But sometimes, if we chose to “slot it in” and “start it now”, we could be amazed at how easy it can be done (relative to what we had thought) and how much we can achieve with small steps a time. The excel sheet to be described can do a lot of things for an engineer who are interested in phase noise and/or jitter measurement. More importantly, the concept can be extended and applied to integrate test and measurement automation with automatic report generation (data post processing and visualization) in Excel. However, it get started only as a simple worksheet to calculate the RMS RJ value from the user supplied phase noise data which took less than 5 minutes to create. It is then fairly easily expanded into what it is now with the capabilities to:
  1. Take in phase noise in “frequency-phase noise” data pairs and calculate the RMS RJ value. This is the spectrum analyzer based clock source random jitter measurement method described in FC-MJSQ and can be used to study the characteristics of different kinds of clock sources.
  2. Pass the phase noise data through PLL and calculate the PLL filtered RMS RJ value. It can be used to study the PLL characteristics and its jitter shaping effect on clock sources.
  3. Pass the phase noise data through PLL first and then a golden PLL. It can be used for transmitter compliance test.
  4. One-button click to perform phase noise measurement from the clock source directly if spectrum analyzer is connected to the host PC through GPIB. This will automate the phase noise raw data acquisition into the Excel instead of manually cut/paste.
  5. One-button click to perform screen capture of the spectrum analyzer for documentation and reporting purposes.
Here is the step-by-step guide on how to make this Excel sheet:

To achieve capability 1:
Cut/paste or import from text-based files such as “*.txt” or “*.csv” for the raw phase noise data into the Excel sheet column A and B and key in the trapezoidal integration equation in column C (start from C3) as shown in Figure 2. You can drag the equation that is filled into C3 all the way down to fill in the column C with the same equation.
Figure 2: trapezoidal integration equation
The summation of column C is the SSB noise power and the RMS phase noise Phi (in unit of radius) is the square root of twice the SSB power, in Excel, Phi = SQRT(2*SUM(C:C)).

To achieve capability 2:
You can calculate the transfer function of your PLL and put the data into column D in dB, the phase noise output through the PLL is simply the addition of raw phase noise and the PLL transfer function in dB and is presented in column E as shown in Figure 3. As an example, the second order PLL transfer function for PCIe described in [1] is used with a 3dB loop bandwidth of 15MHz and a damping factor of 0.54.

Figure 3: TX PLL transfer function
The trapezoidal integration equation is used in column F to calculate the SSB noise power after the raw data goes through the PCIe PLL.
Figure 4: SSB noise power at the TX PLL output

To achieve capability 3:
Use the same method and integration equation as before to implement the first type golden PLL defined in [2]. The completed input is shown in Figure 5 as below.
Figure 5: first type golden PLL transfer function
The SSB noise power for the raw phase noise, the output from (TX) PLL and the output from the golden PLL are calculated and presented in K2 to M2 as shown in Figure 6.
Figure 6: SSB noise power calculation
To make the phase noise/jitter results more presentable, a new sheet is used as GUI with the layout shown in Figure 7, where the phase jitter in second is dependent on the carrier frequency.
Figure 7: calculated phase noise output
At this point, you can also plot all the transfer functions as shown in Figure 8 and the phase noise as shown in Figure 9.
Figure 8: transfer function plots

Figure 9: phase noise plots
To achieve capability 4:
I had thought that this feature could take some time to figure out on how to implement. However, a quick search brings me to the Agilent website, where a very good article is presented on exactly the same topic “Controlling instruments with Excel and the bundled Visual Basic forApplications”.
Of course, I certainly don’t want to hard code the GPIB port and address for the spectrum analyzer. Thus, the input interface as in Figure 10 is provided. Instead of using the cell values directly, the named ranges are used so that when the “GUI” is reformatted, there is no need to change the codes because of the shifting of the cell positions.
Figure 10: named ranges for GPIB interface information
Put a command button onto the Excel sheet and “assign Macros” Button1_Click() as shown below will automate the phase noise data downloading into the Excel.

Sub Button1_Click()
    
    Dim ioMgr As VisaComLib.ResourceManager
    Dim instrument As VisaComLib.FormattedIO488
    Dim idn As String
    Dim lpl() As String
    Dim freq() As Double
    Dim dBc() As Double
    Dim rowStart As Integer
    Dim iLastRow As Long
    Dim lpln As Integer
   
    Set ioMgr = New VisaComLib.ResourceManager
    Set instrument = New VisaComLib.FormattedIO488
    Set instrument.IO = ioMgr.Open(Sheets("MainGUI").Range("gpib_port").Value & "::" &   Sheets("MainGUI").Range("gpib_addr").Value) ‘ this is the same as below line
    'Set instrument.IO = ioMgr.Open("GPIB0::03")
    instrument.IO.Timeout = 10000

    lpln = CInt(Sheets("MainGUI").Range("C11").Value) ‘ provide the option to chose the trace
    instrument.WriteString ":FETC:LPL" & lpln & "?"
    lpl = instrument.ReadList(VisaComLib.IEEEASCIIType.ASCIIType_BSTR, ",")
    instrument.IO.Timeout = 5000
   
    rowStart = 2
    For i = (LBound(lpl)) To (UBound(lpl) - 1) Step 2
        ReDim Preserve freq(0 To i / 2)
        ReDim Preserve dBc(0 To i / 2)
        freq(i / 2) = lpl(i)
        dBc(i / 2) = lpl(i + 1)
    Next i
   
   Sheets("LPLData").Range("A" & rowStart & ":A" & (UBound(dBc) + rowStart)).Value = Application.Transpose(freq)
   Sheets("LPLData").Range("B" & rowStart & ":B" & (UBound(dBc) + rowStart)).Value = Application.Transpose(dBc)
   
    'clear the old f-PN contents
    rowStart = UBound(dBc) + rowStart + 1
    iLastRow = Sheets("LPLData").Cells(Rows.Count, "a").End(xlUp).Row
    Sheets("LPLData").Range("A" & rowStart & ":" & "Z" & iLastRow).Clear
    Call TFCalc  ‘ calculate the transfer function
    Call updatePlots  ‘ update the plots

End Sub

To achieve capability 5:
It’s just one more command button with a little bit more coding. You can look into the codes under Button2_Click() if you are interested.
Of course, it’s handy to add in some more features such as the start/stop frequency so that you have the option to change the frequency span for the phase noise measurement. The option to choose which trace to download: raw data trace or the smoothed data trace. And the flexibility of changing the 3dB cut off frequency of the golden PLL.
By now, we are almost done. As all the raw data are organized into one sheet named “LPLData” and the input/output GUI into another sheet named “MainGUI”, automatically download the phase noise raw data doesn’t pose any issue as it has been taken care of by the Macros. However, manually cut/paste the data from external sources into the Excel sheet may risk overwriting the equations inside the cells, thus corrupting the excel sheet. To avoid this situation, instead of input the equations manually into the Excel sheet, the transfer function calculation and the trapezoidal integration equations have been packed into Macros, making this process fully automated. In addition, an extra Excel sheet named as “PNData” is used for external phase noise data manual input as shown in Figure 12.
Figure 12: phase noise manual input interface

A typical procedure for manually input the phase noise data is outlined in the following:
  1. Navigate to sheet “PNData”, click on “Delete PN Data” to clear old data points.
  2. Copy the external data and paste them into column A and B from row 2 onwards.
  3. Navigate to sheet “MainGUI” and click “Manual PN Data”.  All the calculations will be done automatically with results updated instantly.
The sample code used for PCIe PLL transfer function calculation is given as below:
Function HdB(f3db As Double, zeta As Double, f) As Double
    Dim i As Integer
    Dim n As Double
    Dim d As Double
    Dim w As Double
    Dim w2 As Double
    Dim wn As Double
    Dim H As Double
    w = 2 * Application.WorksheetFunction.Pi() * f 'omega
    w3 = 2 * Application.WorksheetFunction.Pi() * f3db  'omega 2
    wn = w3 / Sqr(1 + 2 * zeta ^ 2 + Sqr((1 + 2 * zeta ^ 2) ^ 2 + 1)) 'omega n
    n = wn * Sqr(wn ^ 2 + 4 * w ^ 2 * zeta ^ 2) 'numorator
    d = Sqr((wn ^ 2 - w ^ 2) ^ 2 + (2 * w * wn * zeta) ^ 2) 'denominator
    H = 20 * Application.WorksheetFunction.Log10(n / d)
    HdB = H
End Function

The finished GUI is shown in Figure 13.
Figure 13: finished GUI

References:
1. PCI ExpressTM Jitter Modeling Revision 1.0RD
2. Fiber Channel - Methodologies for Jitter and Signal Quality Specification - MJSQ