Using the Bin Sorting Function to Sort DUTs

Other topics about Sample Programs

Overview

This sample program demonstrates the use of the bin sorting function.

The sample program first configures the bin sorting conditions as shown in the figure below and then performs 50 measurement cycles; each time the instrument completes one measurement cycle, the program retrieves and displays the bin sorting results. Finally, after the instrument has completed the last measurement cycle, the program retrieves and displays the number of DUTs sorted into each bin.

Sample Program in Excel VBA Using VISA-COM

This sample program uses the main module as well as a class module. Insert a class module in the main module with the name Class1.

In the class module, use the program codes from Class Module.

In the main module, use the program codes from Main Module.

Class Module

Private pNominal As Double

Private pLowLim As Double

Private pUpLim As Double

Private pLType As String

Public Property Get Nominal() As Double

    Nominal = pNominal

End Property

Public Property Let Nominal(value As Double)

    pNominal = value

End Property

Public Property Get LowLim() As Double

    LowLim = pLowLim

End Property

Public Property Let LowLim(value As Double)

    pLowLim = value

End Property

Public Property Get UpLim() As Double

    UpLim = pUpLim

End Property

Public Property Let UpLim(value As Double)

    pUpLim = value

End Property

Public Property Get LType() As String

    LType = pLType

End Property

Public Property Let LType(value As String)

    pLType = value

End Property

Main Module

Sub BinSorting()

'Demonstrates the use of the bin sorting function.

'The program first configures the bin sorting condition and then performs

'50 measurement cycles; each time the instrument completes one measurement

'cycle, the program retrieves and displays the bin sorting results. Finally,

'after the instrument has completed the last measurement cycle, the program

'retrieves and displays the number of DUT's sorted into each bin.

    Dim Params As Class1

    Dim Stat As String

    Dim Ls As String

    Dim Q As String

    Dim Bin_res As Integer

    Dim binResult() As Double

    Dim LimMode As String

    Dim Max_cond As Integer

    Dim Max_bin As Integer

    Dim Nominal As Double

    Dim Ogbin As Integer

    Dim Result() As Double

    Dim instStat As Double

    Dim instResult As Double

    Dim Bin() As String

    Dim FirstRow As Integer

    Dim i As Integer

    Dim J As Integer

    Dim K As Integer

    Dim J_I As Integer

    Dim Cond_reg As Double

    Dim ioMgr As VisaComLib.ResourceManager

    Dim age4982x As New VisaComLib.FormattedIO488

    'Sets the GPIB address

    Set ioMgr = New VisaComLib.ResourceManager

    Set age4982x = New VisaComLib.FormattedIO488

    Set age4982x.IO = ioMgr.Open("GPIB0::17::INSTR")

    age4982x.IO.Timeout = 30000

    'Store the highest sorting condition number into Max_cond

    'variable and the highest bin number into the Max_bin variable

    Max_cond = 2

    Max_bin = 3

    'Store the highest good bin number, which serves as the boundary

    'between the good and bad bins, into the Ogbin variable

    Ogbin = 2

    

    'Store the settings for sorting conditions 1 and 2 that apply to

    'all bins into the corresponding arrays: PointNo contains the

    'measurement points; Para contains the selected measurement

    'parameters; LimMode containts the modes of boundary definition;

    'Nominal contains the reference values

    Nominal = 0.0000000558

    

    Set Params11 = New Class1

    Params11.LowLim = -1#

    Params11.UpLim = 1#

    Params11.LType = "IN"

    

    Set Params12 = New Class1

    Params12.LowLim = 100#

    Params12.UpLim = 1000000000#

    Params12.LType = "IN"

    

    Set Params21 = New Class1

    Params21.LowLim = -1#

    Params21.UpLim = 1#

    Params21.LType = "IN"

    

    Set Params22 = New Class1

    Params22.LowLim = 100#

    Params22.UpLim = 1000000000#

    Params22.LType = "OUT"

    Set Params31 = New Class1

    Params31.LowLim = -1#

    Params31.UpLim = 1#

    Params31.LType = "OUT"

    

    Set Params32 = New Class1

    Params32.LowLim = 100#

    Params32.UpLim = 1000000000#

    Params32.LType = "IN"

    ' Measurement Condition Setting

    'Configure the instrument to perform single-point measurement at the

    'specific measurement point (point 1) defined in active table

    age4982x.WriteString ":SOUR:LIST:TABL 1"

    age4982x.WriteString ":SOUR:LIST:STAT OFF"

    age4982x.WriteString ":SOUR:LIST:POIN 1"

    age4982x.WriteString ":CALC:PAR1:FORM LS"

    age4982x.WriteString ":CALC:PAR2:FORM Q"

    age4982x.WriteString ":DISP:TEXT1:CALC1 ON"

    age4982x.WriteString ":DISP:TEXT1:CALC2 ON"

    age4982x.WriteString ":DISP:TEXT1:CALC3 OFF"

    age4982x.WriteString ":DISP:TEXT1:CALC4 OFF"

    age4982x.WriteString ":DISP:TEXT1:CALC11 OFF"

    age4982x.WriteString ":DISP:TEXT1:CALC12 OFF"

    age4982x.WriteString ":SOUR:LIST:RDC OFF"       'Turns off the Rdc measurement function

    

    ' Bin Sort Setup Table Setting

    'Reset the bin sorting setup table and turns ON the bin sorting function

    age4982x.WriteString ":CALC:COMP:CLE"

    age4982x.WriteString ":CALC:COMP ON"

    

    'Iterate the following steps for each of the sorting conditions 1 through

    'Meas_cond

    For i = 1 To Max_cond

        'Sets the point number to 1, measurement parameter to Params, limit mode to Params.LimMod

        Select Case i

        Case 1

            age4982x.WriteString ":CALC:COMP:COND1:SNUM 1"

            age4982x.WriteString ":CALC:COMP:COND1:PAR LS"

            age4982x.WriteString ":CALC:COMP:COND1:MODE PCNT"

            LimMode = "LS"

        Case Else

            age4982x.WriteString ":CALC:COMP:COND2:SNUM 1"

            age4982x.WriteString ":CALC:COMP:COND2:PAR Q"

            age4982x.WriteString ":CALC:COMP:COND2:MODE ABS"

            LimMode = "Q"

        End Select

         

        'Sets the reference value to Nominal. Note that these statements are skipped if the

        'boundary is defined in absolute mode

        If LimMode = "LS" Then

        age4982x.WriteString ":CALC:COMP:COND" & i & ":NOM " & Nominal

        End If

        

        'Enables the bin and sets the BIN range mode to Params.LType

        'Sets the lower and upper limits of the bin range to Params.LowLim and Params.UpLim

        'respectively. Note that these statements are skipped if the bin range is defined

        'in the ALL mode

        For J = 1 To Max_bin

        J_I = J & i

            age4982x.WriteString ":CALC:COMP:BIN" & J & " ON"

            Select Case J_I

            Case 11

                age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LTYP " & Params11.LType

                If Params11.LType <> "ALL" Then

                    age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LIM " & Params11.LowLim & "," & Params11.UpLim

                End If

            Case 12

                age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LTYP " & Params12.LType

                If Params12.LType <> "ALL" Then

                    age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LIM " & Params12.LowLim & "," & Params12.UpLim

                End If

            Case 21

                age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LTYP " & Params21.LType

                If Params21.LType <> "ALL" Then

                    age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LIM " & Params21.LowLim & "," & Params21.UpLim

                End If

            Case 22

                age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LTYP " & Params22.LType

                If Params22.LType <> "ALL" Then

                    age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LIM " & Params22.LowLim & "," & Params22.UpLim

                End If

            Case 31

                age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LTYP " & Params31.LType

                If Params31.LType <> "ALL" Then

                    age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LIM " & Params31.LowLim & "," & Params31.UpLim

                End If

            Case 32

                age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LTYP " & Params32.LType

                If Params32.LType <> "ALL" Then

                    age4982x.WriteString ":CALC:COMP:BIN" & J & ":COND" & i & ":LIM " & Params32.LowLim & "," & Params32.UpLim

                End If

            End Select

        Next J

    Next i

    

    'Assign all bins with their numbers greater than Ogbin as good bins

    'and turns on the bin count function

    age4982x.WriteString ":CALC:COMP:OGB " & Ogbin

    age4982x.WriteString ":CALC:COMP:COUN ON"

    

    ' Measurement

    'Sets the data transfer format to ASCII

    age4982x.WriteString ":FORM ASC"

    'After measurement is stopped (the trigger system is stopped), the

    'program sets the trigger source to GPIB/LAN trigger and turns on the

    'continuous activation of the trigger system

    age4982x.WriteString ":ABOR"

    age4982x.WriteString ":TRIG:SOUR BUS"

    age4982x.WriteString ":INIT:CONT ON"

    'Clear the bin counter value

    age4982x.WriteString ":CALC:COMP:COUN:CLE"

    

    'Loops through the following steps 50 times

    FirstRow = 15

    

    Cells(FirstRow, 1) = "Status"

    Cells(FirstRow, 2) = "Ls"

    Cells(FirstRow, 3) = "Q"

    Cells(FirstRow, 4) = "BIN"

    For i = 1 To 50

    'Triggers the instrument after the trigger system is put into trigger wait state

    Do

        age4982x.WriteString ":STAT:OPER:COND?"

        Cond_reg = age4982x.ReadNumber

    Loop Until Cond_reg <> 0

    

    age4982x.WriteString "*TRG"

    'Retrieves the measurement results

    Result() = age4982x.ReadList(ASCIIType_R8, ",")

    

    Stat = Result(0)

    Ls = Result(1)

    Q = Result(2)

    

    age4982x.WriteString ":CALC:COMP:DATA:BIN?"

    Bin_res = age4982x.ReadNumber

     

    Cells(FirstRow + 1, 1) = Stat

    Cells(FirstRow + 1, 2) = Ls

    Cells(FirstRow + 1, 3) = Q

    Cells(FirstRow + 1, 4) = Bin_res

    

    FirstRow = FirstRow + 1

    

    Next i

            

    FirstRow = 15

    

    Cells(FirstRow, 8) = "BIN"

    Cells(FirstRow, 9) = "Results"

    'Retrieves and displays the bin count

    age4982x.WriteString ":CALC:COMP:DATA:BCOU?"

    binResult() = age4982x.ReadList(ASCIIType_R8, ",")

    Dim nums As Integer

    

    For K = 0 To 13

        If K <> 13 Then

            Cells(FirstRow + 1, 8) = K + 1

            Cells(FirstRow + 1, 9) = binResult(K)

        Else

            Cells(FirstRow + 2, 8) = "Out of good bins"

            Cells(FirstRow + 2, 9) = binResult(K)

            'MsgBox "Out of good bins: " & binResult(K), vbOKOnly

        End If

        

    FirstRow = FirstRow + 1

    

    Next K

    

End Sub