Example #1
0
def exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2):
    '''
        
    :param Switch: GPIB switch matrix object 
     
    :param CurrentSource: GPIB current source object 
   
    :param card1, card2: Target Cards 1 and 2
    
    :param channel1, channel2: Target Channels 1 and 2
           
    :return: exits sweep cleanly
    
    Called by: 
        
        -Virtually all functions in IV_curve_v3
    '''

    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)

    vf.close_short(Switch, card1, shorts)
    time.sleep(.2)

    vf.open_channel(Switch, card1, channel1)
    vf.open_channel(Switch, card2, channel2)
Example #2
0
def plot_Resistance_Array_live(app, curve, card1, card2, channel1, channel2, max_current,continuity=False,extra_res=0):
    '''
    Plots a sweep from 0 to 3mA and returns the values plotted
    Updates a live plot with current on x axis, voltage on y axis
    
    :param app: pyqtgraph construct
    
    :param curve: pyqtgraph constuct
    
    :param card1, card 2: Target card2
    
    :param channel1, channel2: Target Channels
    
    :param max_Current: max_current before function breaks
    
    :return: I-Values: Arrays of Current Values
    
    :return: V-Values: Array of Voltage Values
    
    :return: R-Values: Array of Resistance Values
        
    :return: Funykgraphs Any Sweeps that had non-linear slopes (Determined by Lin-regress)
   
    Called By:
        
        -Measure_Via_Resistance
        
        -Measure_Device_Resistance
        
        -Resistance Curve
        
        -Measure_Resistor_Arrays
        
    Calls on:
        
        -All Visa Functions
        
    Uses:
        
        -Linregress to determine whether a graph is linear or not
        
        -Looks for a negative slope or an r^2 value below .9
        
    '''
    global go
    go = 1    
    # current initialization variables
    # lower range has less noise
    Irange = 1e-02
    compliance_voltage = 30.
    
    # get GPIB instruments
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()


    vf.intialize_switch_all(Switch)

    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)

    vf.intialize_voltage(Voltmeter, nplc, Vrange)

    vf.close_channel(Switch, card1,channel1) # instead of card, used to be 1
    time.sleep(0.2)

    vf.close_channel(Switch,card2,channel2) # instead of card, used to be 1
    time.sleep(0.2)
    
    vf.turnon_current_yoko(CurrentSource)    
    time.sleep(0.2)

    vf.open_short(Switch, card1, iv.shorts)
        
    time.sleep(.2)

    #Going to use lists to start with for flexibility, even though slower than arrays
    I_values = []
    V_values = []
    R_values = []

    # starting 7/24: voltmeter reads non zero when the current is zero
    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    print('Offset: %s' %offset)
    
    #Sweep Current up
    if continuity:
        step=max_current/10
    else:
        step = max_current / 30
    

    print('\nChannel %d:%d SweepUp Current:'%(channel1,channel2))
    
    
    for I in np.arange(0, max_current, step):
        vf.set_current_fast_yoko(CurrentSource, I)
        
        V = vf.read_voltage_fast(Voltmeter, VDwellTime)
        V=V-I*extra_res
        I_values.append(I)
        # new, for fixing the offset 7/24:
        V_values.append(V-offset)
        if I != 0:
            R_values.append(float(V)/float(I))
        else:
            R_values.append(0.0)
        
        # live plotting
        curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
        app.processEvents()
        print('%e '%I,end=" ")
        
        if go==0: # input passed from GUI
            iv.exitfunc(Switch,CurrentSource,card1,card2,channel1,channel2)
            return 0,0,0,0
    funkygraphs=False
    m,_,r2,_,_=stats.linregress(I_values,V_values)
    r2=r2**2
   
    if m <= 0 or r2<=.9:
        funkygraphs=True
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)

    vf.close_short(Switch, card1, iv.shorts)    
    time.sleep(.2)
    
    vf.open_channel(Switch,card1,channel1)
    vf.open_channel(Switch,card2,channel2)
    return I_values, V_values, R_values, funkygraphs
Example #3
0
def plot_pcm3b(app, curve, card1, card2, channel1, channel2, max_current):
    '''
    Plots a sweep from 0 to 3mA and returns the values plotted
    Updates a live plot with current on x axis, voltage on y axis
    Looks for discontinuity
    '''
    global go
    go = 1    
    # current initialization variables
    # lower range has less noise
    Irange = 1.1e-01
    compliance_voltage = 30.
    
    # get GPIB instruments
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()


    vf.intialize_switch_all(Switch)

    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)
    Vrange=30
    vf.intialize_voltage(Voltmeter, nplc, Vrange)

    vf.close_channel(Switch, card1,channel1) # instead of card, used to be 1
    time.sleep(0.2)

    vf.close_channel(Switch,card2,channel2) # instead of card, used to be 1
    time.sleep(0.2)
    
    vf.turnon_current_yoko(CurrentSource)    
    time.sleep(0.2)

    vf.open_short(Switch, card1, iv.shorts)
        
    time.sleep(.2)
    I_values = []
    V_values = []
    R_values = []
    slope=0
    Imax=0
    # starting 7/24: voltmeter reads non zero when the current is zero
    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    print('Offset: %s' %offset)
    
    #Sweep Current up
    step = max_current / 50

    print('\nChannel %d:%d SweepUp Current:'%(channel1,channel2))
    
    
    for I in np.arange(0, max_current, step):
        vf.set_current_fast_yoko(CurrentSource, I)
        
        V = vf.read_voltage_fast(Voltmeter, VDwellTime)
        I_values.append(I)
        # new, for fixing the offset 7/24:
        V_values.append(V-offset)
        if I != 0:
            R_values.append(float(V)/float(I))
        else:
            R_values.append(0.0)
        
        # live plotting
        curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
        app.processEvents()
        print('%e '%I,end=" ")
        
        if go==0: # input passed from GUI
            iv.exitfunc(Switch,CurrentSource,card1,card2,channel1,channel2)
            return 0,0,0,0
    '''
    Assumes that the slope in the region from 0 to step*6 mA (currently step =2ma so 12ma)
    is the resisitive slope when superconducting... it then looks for strong changes in slope, based off the delta
    so if the slope starts at X but reaches a discontinuity and then becomes less than (1-delta)*x the program will 
    detect it as the Imax point
    '''
    slope=sum(R_values[:5])/6
    delta=.35
    discont=False
    count=8
    while not discont:
        if R_values[count]<slope*(1-delta) or R_values[count]>slope*(1+delta):
            discont=True
            Imax=I_values[count]
        count+=1
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)

    vf.close_short(Switch, card1, iv.shorts)    
    time.sleep(.2)
    
    vf.open_channel(Switch,card1,channel1)
    vf.open_channel(Switch,card2,channel2)
    return I_values, V_values, R_values, Imax,slope
Example #4
0
def sweep_current_flux(app, curves, current_point, card1, card2, channel1,
                       channel2, I_min, I_max, step, I_minflux, I_maxflux,
                       stepflux, down):
    """
    Inputs are min and max current for sweep, steps, card and channels for switch
    Returns an array with current steps, measured voltages, and calculated resistances
    
    """
    curve_colors = ['b', 'g', 'r', 'c', 'm', 'y', 'k', 'w']

    I_values_all = []  #(Ibias)
    V_values_all = []

    current_x = []
    current_y = []

    ##INITIALIZATION OF HARDWARE##
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    FluxSource = vf.get_current_flux()
    Switch = vf.get_switch()

    vf.intialize_switch_all(Switch)
    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)
    vf.intialize_current_yoko(FluxSource, Fluxrange, compliance_voltage)
    time.sleep(0.2)
    vf.intialize_voltage(Voltmeter, nplc, Vrange)
    vf.close_channel(Switch, card1, channel1)
    time.sleep(0.2)
    vf.close_channel(Switch, card2, channel2)  # instead of card, used to be 1
    time.sleep(0.2)
    vf.turnon_current_yoko(CurrentSource)
    time.sleep(0.2)
    vf.turnon_current_yoko(FluxSource)
    time.sleep(0.2)
    vf.open_short(Switch, card1, shorts)
    time.sleep(0.2)

    time.sleep(0.2)
    curve_counter = 0

    global go
    go = 1
    colorsused = []
    for Iflux in np.arange(I_minflux, I_maxflux, stepflux):
        I_values = []
        V_values = []
        vf.set_current_fast_yoko(FluxSource, Iflux)  #Set the flux current

        #vf.intialize_voltage(Voltmeter, nplc, Vrange)
        offset = vf.read_voltage_fast(Voltmeter, VDwellTime)
        time.sleep(0.2)
        ##CURRENT SWEEPS##
        #Sweep Current up
        print('Starting sweep up with Iflux =', Iflux)
        for I in np.arange(I_min, I_max, step):
            vf.set_current_fast_yoko(CurrentSource, I)
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            V_values.append(V)

            current_x.append(I)
            current_y.append(V)

            curves[curve_counter].setData(
                I_values,
                V_values,
                symbol='o',
                symbolBrush=curve_colors[curve_counter % 8],
                symbolSize=5)

            current_point.setData(current_x,
                                  current_y,
                                  symbol='o',
                                  symbolBrush='r',
                                  symbolSize=7)
            app.processEvents()

            current_x = []
            current_y = []

            if go == 0:  #If the stop button on the GUI is pressed
                exitfunc(Switch, CurrentSource, card1, card2, channel1,
                         channel2)
                vf.set_current_fast_yoko(FluxSource, 0)
                return 0, 0, 0

        if down:
            print('Starting sweep down')
            #Sweep Current down
            for I in np.arange(I_max - step, I_min, -step):
                vf.set_current_fast_yoko(CurrentSource, I)
                V = vf.read_voltage_fast(Voltmeter, VDwellTime)
                I_values.append(I)
                V_values.append(V)

                current_x.append(I)
                current_y.append(V)

                curves[curve_counter].setData(
                    I_values,
                    V_values,
                    symbol='o',
                    symbolBrush=curve_colors[curve_counter % 8],
                    symbolSize=5)
                current_point.setData(current_x,
                                      current_y,
                                      symbol='o',
                                      symbolBrush='r',
                                      symbolSize=7)
                app.processEvents()

                current_x = []
                current_y = []

                if go == 0:  #If the stop button on the GUI is pressed
                    exitfunc(Switch, CurrentSource, card1, card2, channel1,
                             channel2)
                    vf.set_current_fast_yoko(FluxSource, 0)
                    return 0, 0, 0

        V_values = np.array(V_values)
        V_values = V_values - offset

        #SHUT IT DOWN!##
        print('Exited current sweep with Iflux =', Iflux)
        vf.set_current_fast_yoko(CurrentSource, 0)
        time.sleep(.1)
        I_values_all.append(I_values)
        V_values_all.append(V_values)
        colorsused.append(curve_colors[curve_counter % 8])
        curve_counter = curve_counter + 1

    print('Finished all current sweeps')
    #Safe all of the hardware
    vf.set_current_fast_yoko(FluxSource, 0)
    time.sleep(0.2)
    vf.close_short(Switch, card1, shorts)
    time.sleep(0.2)
    if channel1 != 10:
        vf.open_channel(Switch, card1, channel1)
        vf.open_channel(Switch, card2, channel2)

    #Iflux=np.arange(I_minflux, I_maxflux, stepflux)

    return I_values_all, V_values_all, colorsused
Example #5
0
def sweep_current(app, curve, current_point, ic_curve, plot, card1, card2,
                  channel1, channel2, I_min, I_max, step):
    """
    Inputs are min and max current for sweep, steps, card and channels for switch
    Returns an array with current steps, measured voltages, and calculated resistances
    
    """
    ##VARIABLE DECLARATIONS##
    #Going to use lists to start with for flexibility, even though slower than arrays
    I_values = []
    V_values = []

    current_x = []
    current_y = []

    ##INITIALIZATION OF HARDWARE##
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()

    vf.intialize_switch_all(
        Switch)  #For some reason causes things to break. ADD THIS BACK
    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)
    vf.intialize_voltage(Voltmeter, nplc, Vrange)
    vf.close_channel(Switch, card1, channel1)
    time.sleep(0.2)
    vf.close_channel(Switch, card2, channel2)  # instead of card, used to be 1
    time.sleep(0.2)
    vf.turnon_current_yoko(CurrentSource)
    time.sleep(0.2)
    vf.open_short(Switch, card1, shorts)
    time.sleep(0.2)

    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    global go
    go = 1

    #Sweep Current up
    print('Starting sweep up')
    for I in np.arange(I_min, I_max, step):
        vf.set_current_fast_yoko(CurrentSource, I)
        V = vf.read_voltage_fast(Voltmeter, VDwellTime)
        I_values.append(I)
        V_values.append(V)

        current_x.append(I)
        current_y.append(V)

        curve.setData(I_values,
                      V_values,
                      symbol='o',
                      symbolBrush='w',
                      symbolSize=5)
        current_point.setData(current_x,
                              current_y,
                              symbol='o',
                              symbolBrush='r',
                              symbolSize=7)
        app.processEvents()

        current_x = []
        current_y = []

        if go == 0:  #If the stop button on the GUI is pressed
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0, 0, 0

    print('Starting sweep down')
    #Sweep Current down
    for I in np.arange(I_max - step, I_min, -step):
        vf.set_current_fast_yoko(CurrentSource, I)
        V = vf.read_voltage_fast(Voltmeter, VDwellTime)
        I_values.append(I)
        V_values.append(V)

        current_x.append(I)
        current_y.append(V)

        curve.setData(I_values,
                      V_values,
                      symbol='o',
                      symbolBrush='w',
                      symbolSize=5)
        current_point.setData(current_x,
                              current_y,
                              symbol='o',
                              symbolBrush='r',
                              symbolSize=7)
        app.processEvents()

        current_x = []
        current_y = []

        if go == 0:  #If the stop button on the GUI is pressed
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0, 0, 0

    #SHUT IT DOWN!##
    print("Exited current sweep")
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)
    vf.close_short(Switch, card1, shorts)
    time.sleep(0.2)
    if channel1 != 10:
        vf.open_channel(Switch, card1, channel1)
        vf.open_channel(Switch, card2, channel2)

    V_values = np.array(V_values)
    V_values = V_values - offset
    I_values = np.array(I_values)

    ###########
    #Magical code for finding the 4 Ics
    Ic_values = find_Ic(I_values, V_values)  #Ted needs to FIX this
    # Ic_values = [0,0,0,0]
    ###########

    # setting labels
    for n1 in range(0, len(Ic_values)):
        if n1 < 2:
            type_of_current = "I" + str(n1)
            label = pg.TextItem(text="",
                                color=(0, 0, 0),
                                fill=(0, 255, 255),
                                anchor=(0, -1))
        else:
            type_of_current = "I" + str(n1)
            label = pg.TextItem(text="",
                                color=(0, 0, 0),
                                fill=(0, 255, 255),
                                anchor=(0, 2))

        I_c = type_of_current + ':(' + '{:.2E}'.format(
            Ic_values[n1]) + ',' + '{:.2E}'.format(
                V_values[(np.where(I_values == Ic_values[n1]))[0]][0]) + ')'
        label.setText(I_c)
        label.setPos(Ic_values[n1],
                     V_values[(np.where(I_values == Ic_values[n1]))[0]][0])
        plot.addItem(label)
        ic_curve[n1].setData(
            [Ic_values[n1]],
            [V_values[(np.where(I_values == Ic_values[n1]))[0]][0]],
            symbol='o',
            symbolBrush='c',
            symbolSize=10)
        app.processEvents()

    return I_values, V_values, Ic_values
Example #6
0
def sweep_current_live_Rn(app, curve, number_of_sweeps, I_min, V_max, step, card1, card2, channel1, channel2,dev):
    """
      
    :param app, curve: (both pyqtgraph constructs)
    
    :param number_of_sweeps: number of sweeps to complete
    
    :param I_min: current sweep start
   
    :param I_maxcurrent: sweep stop
    
    :param step: increment
   
    :param card1, card 2: Target Cards
   
    :param channel1,channel 2: Target Channels
   
    :param dev: Target device
   
    
    :return: I,V,R arrays
    
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    
    Called By:
      -Get Rn Imax 
      
      -Get Rn Imax and save
    
    Calls On:
        
        All Visa Functions
        
    FINDS LINEAR SLOPE:
    First checks for hitting Vmax
    Next checks for expected length based on size of JJ
    then looks for 4 collinear point (using stats.linregress) 
    then looks at most recent sets of points
    if all still linear will exit
    
    """
    # current initialization variabels 
    Irange = 200e-03
    compliance_voltage = 5.
    current_limit = 30e-03 # This is highest possible current in A. Shouldn't get this high
    
    # get GPIB instruments
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()
    

    vf.intialize_switch_all(Switch)

    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)

    vf.intialize_voltage(Voltmeter, nplc, Vrange)

    vf.close_channel(Switch, card1,channel1)
    time.sleep(.2)

    vf.close_channel(Switch,card2,channel2)
    time.sleep(.2)

    vf.turnon_current_yoko(CurrentSource)
    time.sleep(.2)

    vf.open_short(Switch, card1, shorts)

    #Going to use lists to start with for flexibility, even though slower than arrays
    I_values = []
    V_values = []
    R_values = []


    global go
    go = 1
    
    slopevalue=None
    slope_index=None
    printstatement=True
    for n in range(0, number_of_sweeps):
        #Sweep Current up
        print('\nChannel %d:%d SweepUp Current:'%(channel1,channel2))
        V=0
        prev_slope=[]
        #measure of how close the previous and current slopes need to be to break
        sigma=.05
        #how soon to start checking for RN
        alpha=100
        expected_length=int(30 + alpha * dev.JJ_radius_nom)
        print("Expected length: ",expected_length)
        for I in np.arange(I_min, current_limit, step):
            vf.set_current_fast_yoko(CurrentSource, I)
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            print('%e '%I,end=" ")
            V_values.append(V)
            if I==0:
                R_values.append(0.0)
            else:
                R_values.append(float(V)/float(I))
          
            if V >= V_max:
                print("V_max reached")
                break
            #MOST OF THIS WIL GO IF WE SWITCH TO NON REAL TIME
            #Check for negative to positive first r derivative
            if len(I_values)>expected_length:
                #first check for inflection points
                first_deriv=[]
                second_deriv=[]
                first_deriv=np.gradient(V_values)
                second_deriv=np.gradient(first_deriv)
                if np.mean(second_deriv[-6:-3]) <= 0 and np.mean(second_deriv[-3:]) >= 0:
                    if printstatement:
                        print("Break due to inflection")
                        printstatement=False
                    if slopevalue is None:
                        slopevalue=np.mean(R_values[-3:-1])
                    if slope_index is None:
                        slope_index=len(I_values)
                #next check for jumps due to thermal 
                jumptuner=3
                if np.diff(V_values)[-1]>=jumptuner * np.mean(np.diff(V_values)[-4:-1]):
                    if printstatement:
                        print("Break due to thermal jump")
                        printstatement=False
                    if slopevalue is None:
                        slopevalue=np.mean(R_values[-3:-1])
                    if slope_index is None:
                        slope_index=len(I_values)
                
                
            curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
            app.processEvents()
            
            if go == 0:
                print("Exiting")
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)
    vf.close_short(Switch, card1, shorts)
    vf.open_channel(Switch,card1,channel1)
    vf.open_channel(Switch,card2,channel2)
    print(slopevalue)
    return I_values, V_values, R_values, slopevalue, slope_index
Example #7
0
def sweep_current_vphi(app, curve, current_point, card1, card2, channel1,
                       channel2, I_minflux, I_maxflux, Iflux_step, Ibias_min,
                       Ibias_max, Ibias_step):
    """
    Inputs are min and max current for sweep for flux of the SQUIDs, step
    Returns an array with current steps, measured voltages, and calculated resistances
    *********NOTE: This will have to be modified if the second current source is wired through the switch matrix
    """
    ##VARIABLE DECLARATIONS##
    #Going to use lists to start with for flexibility, even though slower than arrays
    I_values = []
    V_values = []

    current_x = []
    current_y = []

    ##INITIALIZATION OF HARDWARE##
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    FluxSource = vf.get_current_flux()
    Switch = vf.get_switch()

    vf.intialize_switch_all(Switch)
    vf.intialize_current_yoko(
        CurrentSource, Irange, compliance_voltage
    )  #50 mA instead of 10 mA because we want a larger range for periodicity tests
    time.sleep(0.2)
    vf.intialize_current_yoko(FluxSource, 50e-03, compliance_voltage)
    time.sleep(0.2)
    vf.intialize_voltage(Voltmeter, nplc, Vrange)
    vf.close_channel(Switch, card1, channel1)
    time.sleep(0.2)
    vf.close_channel(Switch, card2, channel2)  # instead of card, used to be 1
    time.sleep(0.2)
    vf.turnon_current_yoko(CurrentSource)
    time.sleep(0.2)
    vf.turnon_current_yoko(FluxSource)
    time.sleep(0.2)
    vf.open_short(Switch, card1, shorts)
    time.sleep(0.2)

    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    global go
    go = 1

    for Ibias in np.arange(Ibias_min, Ibias_max, Ibias_step):
        vf.set_current_fast_yoko(CurrentSource, Ibias)

        I = []
        V = []
        ##CURRENT SWEEPS##
        #Sweep Current up
        print('Starting sweep with Ibias = %f' % Ibias)
        for Iflux in np.arange(I_minflux, I_maxflux, Iflux_step):
            vf.set_current_fast_yoko(FluxSource, Iflux)
            Vread = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I.append(Iflux)
            V.append(Vread)

            current_x.append(Iflux)
            current_y.append(Vread)

            curve.setData(I, V, symbol='o', symbolBrush='w', symbolSize=5)
            current_point.setData(current_x,
                                  current_y,
                                  symbol='o',
                                  symbolBrush='r',
                                  symbolSize=7)
            app.processEvents()

            current_x = []
            current_y = []

            if go == 0:  #If the stop button on the GUI is pressed
                exitfunc(Switch, CurrentSource, card1, card2, channel1,
                         channel2)
                vf.set_current_fast_yoko(FluxSource, 0)
                return 0, 0, 0

        vf.set_current_fast_yoko(CurrentSource, 0)
        vf.set_current_fast_yoko(FluxSource, 0)

        I = np.array(I)
        V = np.array(V)
        I_values.append(I)
        V_values.append(V - offset)

        if go == 0:  #If the stop button on the GUI is pressed
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            vf.set_current_fast_yoko(FluxSource, 0)
            return 0, 0, 0

    print("Exited current sweep")
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)
    vf.set_current_fast_yoko(FluxSource, 0)
    time.sleep(.2)
    vf.close_short(Switch, card1, shorts)
    time.sleep(0.2)
    if channel1 != 10:
        vf.open_channel(Switch, card1, channel1)
        vf.open_channel(Switch, card2, channel2)
    x = I
    y = np.full(np.shape(I), np.mean(V))
    current_point.setData(x, y, symbol='o', symbolBrush='g', symbolSize=7)
    return find_period(I_values, V_values)
Example #8
0
def tempandresrun(app,curve,current_point,card1,card2,channel1,channel2):
    '''
    Written by Nathan
    Inputs:
    :param app, curve: (both pyqtgraph constructs)
    
    :param current_point: pyqtgraph contruct used to plot current point
       
    :param card1, card2: Target Cards 1 and 2
   
    :param channel1,channel 2: Target Channels
     
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    '''
    global go
    go = 1
    currentlevel=0.1e-3 #We will constantly output 250 uA
    Irange = 1e-02
    compliance_voltage = 2.
    
    #Initialize voltmeter, current source, and switch matrix
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()
    vf.intialize_switch_all(Switch)
    
    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)
    vf.intialize_voltage(Voltmeter, nplc, Vrange)
    vf.close_channel(Switch, card1, channel1) # instead of card, used to be 1
    time.sleep(0.2)
    vf.close_channel(Switch, card2, channel2) # instead of card, used to be 1
    time.sleep(0.2)
    vf.turnon_current_yoko(CurrentSource)    
    time.sleep(0.2)    
    vf.open_short(Switch, card1, shorts)    
    time.sleep(.2)
    
    lake = vf.getLake()
    
    T_values =[]
    R_values =[] 
    
    # current point array
    current_x = []
    current_y = []

    stillrunning = True

    offset = float(vf.read_voltage_fast(Voltmeter, VDwellTime))
    vf.set_current_fast_yoko(CurrentSource,currentlevel) #Set the current source to one constant value initially
    print("Temperature sweep up on channels %d and %d"%(channel1,channel2))    
   
    #manual control
    while stillrunning: 
        try:
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            R = (float(V)-offset)/float(currentlevel)   
            T = vf.getTempK(lake)
            R_values.append(R)
            T_values.append(T)
            current_x.append(T)
            current_y.append(R)               
            #empty=False
            curve.setData(T_values,R_values,symbol='o',symbolBrush='w',symbolSize=5)   
            current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
            app.processEvents()
            
            current_x = []
            current_y = []
            
            
            if go == 0: #Asynchronous safe exit
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                vf.closeLake(lake)
                Tc=findTc(R_values,T_values)
                return R_values,T_values,Tc
                stillrunning=False
  
        except KeyboardInterrupt:
                print("\nExiting...\n")
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                stillrunning=False
      
    #Put the voltmeter, switch matrix, and current source back in safe configurations
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)
    vf.close_short(Switch, card1, shorts)
    time.sleep(.2)
    if channel1 != 10:
        vf.open_channel(Switch,card1,channel1)
        vf.open_channel(Switch,card2,channel2)
        
    vf.closeLake(lake)
    
    Tc=findTc(R_values,T_values)
    return R_values,T_values,Tc
Example #9
0
def turn_current_off():
    CurrentSource = vf.get_current()
    vf.set_current_fast_yoko(CurrentSource, 0)
Example #10
0
def sweep_current_live(app, curve, current_point, number_of_sweeps, I_min, I_max, step, card1, card2, channel1, channel2,extra_res=0):

    """
    Inputs:
    :param app, curve: (both pyqtgraph constructs)
    
    :param current_point: pyqtgraph contruct used to plot current point
   
    :param number_of_sweeps: number of sweeps to complete
    
    :param I_min: current sweep start
   
    :param I_maxcurrent: sweep stop
    
    :param step: increment
   
    :param card1, card2: Target Cards 1 and 2
   
    :param channel1,channel 2: Target Channels
   
    :return: I,V,R arrays
    
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    
    Called By:
        
      -Measure_Resistance
      
      -Automate_channel_IV_live
    
    Calls On:
        
        All Visa Functions
         
    """
    # current initialization variables
    # lower range has less noise
    Irange = 1e-02
    compliance_voltage = 2.
    
    # get GPIB instruments
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()

    # Initialize the switch matrix
    vf.intialize_switch_all(Switch)
    
    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)

    vf.intialize_voltage(Voltmeter, nplc, Vrange)

    
    vf.close_channel(Switch, card1, channel1) # instead of card, used to be 1
    time.sleep(0.2)

    vf.close_channel(Switch, card2, channel2) # instead of card, used to be 1
    time.sleep(0.2)
    
    vf.turnon_current_yoko(CurrentSource)    
    time.sleep(0.2)    
    vf.open_short(Switch, card1, shorts)    
    
    time.sleep(.2)

    # Going to use lists to start with for flexibility, even though slower than arrays
    I_values = []
    V_values = []
    R_values = []

    # current point array
    current_x = []
    current_y = []
    
    # voltmeter reads non zero when the current is zero
    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    print('Offset: %s' %offset)
    
    global go
    go = 1
    #Sweep Current up
    for n in range(0, number_of_sweeps):
        print('\nChannel %d:%d SweepUp Current:'%(channel1,channel2))
        for I in np.arange(I_min, I_max, step):
            try:
                vf.set_current_fast_yoko(CurrentSource, I)
                
                V = vf.read_voltage_fast(Voltmeter, VDwellTime)
                V=V-extra_res*I
                I_values.append(I)
                # For fixing the offset
                V_values.append(V-offset)
                
                # put current point in an array to plot in a different color
                current_x.append(I)
                current_y.append(V-offset)
                #R_Offset accounts for the addition of series resistors to select devices 
                r_offset=0
                
                #Dev_Resistors- Dictionary- key:device with resistor, value-resitance 
                #Dev_resistors={}
                
                
                #check for devices with resistors
                #if device in Dev_resistors:
                #    r_offset = Dev-resistors[device]
                #else:
                #   r_offset=0
                
                if I != 0:
                    R_values.append(float(V)/float(I)-r_offset)
                else:
                    R_values.append(0.0)
                
                
                # live plotting
                curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
                current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
                app.processEvents()
                
                # empty the current point array
                current_x = []
                current_y = []
                
                # input from GUI
                if go == 0:
                    exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                    return 0,0,0
                
#                print('%e '%I,end=" ")
            
            # handle keyboard event    
            except KeyboardInterrupt:
                print("\nExiting...\n")
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0

        #Sweep Current down
        print('\nChannel %d:%d SweepDown Current:'%(channel1,channel2))
        for I in np.arange(I_max-step, I_min, -step):
            try:
                vf.set_current_fast_yoko(CurrentSource, I)
                V = vf.read_voltage_fast(Voltmeter, VDwellTime)
                V=V-extra_res*I
                I_values.append(I)
                V_values.append(V-offset)
                
                current_x.append(I)
                current_y.append(V-offset)
                
                if I != 0:
                    R_values.append(float(V)/float(I))
                else:
                    R_values.append(0.0)
                    
                # live plotting 
                curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
                current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
                app.processEvents()
                
                current_x = []
                current_y = []
                
                if go ==0:
                    exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                    return 0,0,0
                
#                print('%e'%I,end=" ")
                
            except KeyboardInterrupt:
                print("\nExiting...\n")
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0
        
        # clear out the different colored current point
        current_point.setData([],[])

    # turn it off and be ready to switch channels
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)

    vf.close_short(Switch, card1, shorts)
    time.sleep(.2)

    # open channels that were just measured
    # 10 is always sort, is this necessary
    if channel1 != 10:
        vf.open_channel(Switch,card1,channel1)
        vf.open_channel(Switch,card2,channel2)


    return I_values, V_values, R_values
Example #11
0
def constantruntemp(app,curve1,curve2,card1,card2,channel1,channel2,target,tempSetpoint,PID,manual):
    '''
    Inputs:
    :param app, curve: (both pyqtgraph constructs)
    
    :param current_point: pyqtgraph contruct used to plot current point
       
    :param card1, card2: Target Cards 1 and 2
   
    :param channel1,channel 2: Target Channels
     
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    '''
    global go
    go = 1
    currentlevel=1e-4
    Irange = 1e-02
    compliance_voltage = 2.
    
    #Initialize all hardware
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()
    vf.intialize_switch_all(Switch)
    
    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)
    vf.intialize_voltage(Voltmeter, nplc, Vrange)
    vf.close_channel(Switch, card1, channel1) # instead of card, used to be 1
    time.sleep(0.2)
    vf.close_channel(Switch, card2, channel2) # instead of card, used to be 1
    time.sleep(0.2)
    vf.turnon_current_yoko(CurrentSource)    
    time.sleep(0.2)    
    vf.open_short(Switch, card1, shorts)    
    time.sleep(.2)
    
    #Initialize temperature controller
    lake=vf.getLake()
    vf.setManualOutput(lake,manual)
    vf.setTempSetpoint(lake,tempSetpoint)
    vf.setPID(lake,float(PID[0]), float(PID[1]), float(PID[2]))
    
    
    timevals=[]
    R_values = []
    T_values = []
 
    # voltmeter reads non zero when the current is zero
    #offset = vf.read_voltage_fast(Voltmeter, VDwellTime)
   
    stillrunning=True
    passage=0
    count=0
    #testing=True
    start_time=time.time()
    vf.set_current_fast_yoko(CurrentSource,currentlevel) #Set the current initially
    
    while stillrunning: # and abs(T_values[-1] - float(target)) > 0.5:
        try:
            count = count + 1
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            #if count % 10 == 5:
             #   print(V)
            T = vf.getTempK(lake)
            #r_offset=0
            passage=time.time()-start_time

            if currentlevel != 0:
                R_values.append(float(V)/float(currentlevel))#-r_offset)
                timevals.append(passage)  
                T_values.append(T)
            else:
                R_values.append(0.0)
                timevals.append(passage)
                T_values.append(T)
              

           # if len(R_values)%10==0:
              #  print("Time is %f, Resistance is %f" %(timevals[-1],R_values[-1]))
            curve1.setData(timevals,R_values, symbol='o', symbolBrush='w', symbolSize=5)
            curve2.setData(timevals,T_values, symbol='o', symbolBrush='g', symbolSize=5)            
            app.processEvents()
            
            if go == 0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                vf.safe_temp_controller(lake)
                stillrunning=False
  
        except KeyboardInterrupt:
                print("\nExiting...\n")
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                vf.safe_temp_controller(lake)
                stillrunning=False

    
    #Put the current/voltage sources in a safe configuration    
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)
    vf.close_short(Switch, card1, shorts)
    time.sleep(.2)

    if channel1 != 10:
        vf.open_channel(Switch,card1,channel1)
        vf.open_channel(Switch,card2,channel2)
        
    vf.safe_temp_controller(lake)
    
    return R_values, T_values
Example #12
0
def constantrun(app,curve,card1,card2,channel1,channel2):
    '''
    Inputs:
    :param app, curve: (both pyqtgraph constructs)
    
    :param current_point: pyqtgraph contruct used to plot current point
       
    :param card1, card2: Target Cards 1 and 2
   
    :param channel1,channel 2: Target Channels
     
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    '''
    global go
    go = 1
    currentlevel=1e-3
    Irange = 1e-02
    compliance_voltage = 2.
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()
    vf.intialize_switch_all(Switch)
    
    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)

    vf.intialize_voltage(Voltmeter, nplc, Vrange)

    
    vf.close_channel(Switch, card1, channel1) # instead of card, used to be 1
    time.sleep(0.2)

    vf.close_channel(Switch, card2, channel2) # instead of card, used to be 1
    time.sleep(0.2)
    
    vf.turnon_current_yoko(CurrentSource)    
    time.sleep(0.2)    
    vf.open_short(Switch, card1, shorts)    
    
    time.sleep(.2)
    
     # Going to use lists to start with for flexibility, even though slower than arrays
    timevals=[0]
    R_values = [0]

    # current point array
 
    # voltmeter reads non zero when the current is zero
    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    print('Offset: %s' %offset)
    
   
    stillrunning=True
    passage=0
    count=0
    testing=True
    start_time=time.time()
    while stillrunning and passage<600:
        #print('\nChannel %d:%d Constant Current:'%(channel1,channel2))
        
        
        try:
           # current=currentlevel+np.random.normal(0,1e-3)
            current=currentlevel
            vf.set_current_fast_yoko(CurrentSource,current)
            
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            r_offset=0
            passage=time.time()-start_time
            if testing:
                count+=1
                if count%10==0:
                    print(passage)
            if current != 0:
                R_values.append(float(V)/float(current)-r_offset)
                timevals.append(passage)    
            else:
                R_values.append(0.0)
                timevals.append(passage)
              

           # if len(R_values)%10==0:
              #  print("Time is %f, Resistance is %f" %(timevals[-1],R_values[-1]))
            curve.setData(timevals,R_values, symbol='o', symbolBrush='w', symbolSize=5)            
            app.processEvents()
            
           
                
            if go == 0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                stillrunning=False
  
        except KeyboardInterrupt:
                print("\nExiting...\n")
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                stillrunning=False

    # turn it off and be ready to switch channels
    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)

    vf.close_short(Switch, card1, shorts)
    time.sleep(.2)

    # open channels that were just measured
    # 10 is always sort, is this necessary
    if channel1 != 10:
        vf.open_channel(Switch,card1,channel1)
        vf.open_channel(Switch,card2,channel2)
Example #13
0
def sweep_current_live_GUI(app,plot, curves, number_of_sweeps, I_min, I_max, step, card1, card2, channel1, channel2,save,chip,device):
    """
     Automates the sweep_current_live function for the older GUI
    
    :param app, curve: (both pyqtgraph constructs)
  
    :param number_of_sweeps: number of sweeps to complete
    
    :param I_min, I_max: Respective max and min current values
    
    :param step: step size
    
    :param card1, card2: Target Cards 1 and 2
    
    :param channel1, channel2: Target Channels 1 and 2
    
    :return: I,V,R arrays
    
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    
    Called By:
        
        -Get Rn Imax 
      
        -Get Rn Imax and save
    
    Calls On:
        
        -sweep_current_live_variable_points
        
        -sweep_current_live
    
    """
    # current initialization variables
    # lower range has less noise

    Irange = 1.3e-01
    compliance_voltage = 10.

    # get GPIB instruments
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()

    # different init. for squids vs. pcm

    vf.intialize_switch_all(Switch)



    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)

    vf.intialize_voltage(Voltmeter, nplc, Vrange)


    vf.close_channel(Switch, card1,channel1) # instead of card, used to be 1
    time.sleep(0.2)

    vf.close_channel(Switch,card2,channel2) # instead of card, used to be 1
    time.sleep(0.2)

    vf.turnon_current_yoko(CurrentSource)
    time.sleep(0.2)

    vf.open_short(Switch, card1, shorts)

    time.sleep(.2)

    #Going to use lists to start with for flexibility, even though slower than arrays
    # starting 7/24: voltmeter reads non zero when the current is zero
    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)

    print('Offset: %s' %offset)

    global go
    go = 1
    #Sweep Current up
    for n in range(0, number_of_sweeps):
        I_values = []
        V_values = []
        R_values = []

        if n%2==0:
            color = 'w'
        else:
            color = 'b'
        if n>1:
            curves[n-2].setData([],[])

        print('\nChannel %d:%d SweepUp Current:'%(channel1,channel2))
        
        
        for I in np.arange(I_min, I_max, step):
            vf.set_current_fast_yoko(CurrentSource, I)

            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            # new, for fixing the offset 7/24:
            V_values.append(V-offset)
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curves[n].setData(I_values,V_values, symbol='o', pen = color,symbolBrush=color, symbolSize=7)
            app.processEvents()
            if go == 0:
                break
            print('%e '%I,end=" ")

        #Sweep Current down
        print('\nChannel %d:%d SweepDown Current:'%(channel1,channel2))
        for I in np.arange(I_max-step, I_min, -step):
            vf.set_current_fast_yoko(CurrentSource, I)
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            V_values.append(V-offset)
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curves[n].setData(I_values,V_values, symbol='o', pen=color,symbolBrush=color, symbolSize=7)
            app.processEvents()
            if go ==0:
                break
            print('%e'%I,end=" ")


    vf.set_current_fast_yoko(CurrentSource, 0)
    time.sleep(.2)

    vf.close_short(Switch, card1, shorts)
    time.sleep(.2)


    vf.open_channel(Switch,card1,channel1)
    vf.open_channel(Switch,card1,channel2)
    
    if save:
        
        current_time = time.strftime("_%Y-%m-%d_%H-%M-%S_IVGUI")
        dirname = ("E:/Users/volt.686QVACTEST/National Institute of Standards and Technology (NIST)/SEG - SFQ_Circuits/")
        import measure_Ic as ic
        folder = dirname+ str(chip.name)+current_time
        name=ic.create_name(chip.name,device)
        filename=folder+name
        ic.create_dir(filename)
        print(filename)
        save_data_live(I_values, V_values, R_values,(folder+name+"_sweep.dat"))
        
        from pyqtgraph import exporters
        exporter = exporters.ImageExporter(plot.scene())
        try:
            exporter.export(filename+"_sweep.png") # export the graph
        except:
            print("Oh no wrapped object was deleted!!!!!")
    
    try:
        return I_values, V_values, R_values
    except:
        return 0,0,0
Example #14
0
def sweep_current_live_variable_points(app, curve, current_point, number_of_sweeps, I_min, I_max, step, card1, card2, channel1, channel2, optionalic=0,extra_res=0):
    """
    This plot will be very dense in points around the estimated ic
    
    :param app, curve: (both pyqtgraph constructs)
    
    :param number_of_sweeps: number of sweeps to complete
    
    :param current_point: pyqtgraph contruct used to plot current point
    
    :param I_min: current sweep start
   
    :param I_maxcurrent: sweep stop
    
    :param step: increment
   
    :param card1, card2: Target Cards
   
    :param channel1, channel2: Target Channels
   
    :param dev: Target device
   
    
    :return: I,V,R arrays
    
    :Graphs: Updates a live plot with current on x axis, voltage on y axis
    
    Called By:
      -Get Rn Imax 
      
      -Get Rn Imax and save
    
    Calls On:
        
        All Visa Functions


    """
    # current initialization variables
    # lower range has less noise
    Irange = 1e-03
    compliance_voltage = 2.
    
    # get GPIB instruments
    Voltmeter = vf.get_voltage()
    CurrentSource = vf.get_current()
    Switch = vf.get_switch()

    vf.intialize_switch_all(Switch)
    
    vf.intialize_current_yoko(CurrentSource, Irange, compliance_voltage)
    time.sleep(0.2)

    vf.intialize_voltage(Voltmeter, nplc, Vrange)

    vf.close_channel(Switch, card1,channel1) # instead of card, used to be 1
    time.sleep(0.2)

    vf.close_channel(Switch,card2,channel2) # instead of card, used to be 1
    time.sleep(0.2)
    
    vf.turnon_current_yoko(CurrentSource)    
    time.sleep(0.2)

    vf.open_short(Switch, card1, shorts)
    
    time.sleep(.2)

    #Going to use lists to start with for flexibility, even though slower than arrays
    I_values = []
    V_values = []
    R_values = []
    
    # array to hold current point
    current_x = []
    current_y = []
    

    # offset
    offset = vf.read_voltage_fast(Voltmeter, VDwellTime)
    
    global go
    go = 1
    
    if optionalic !=0:
        estimated_Ic = optionalic
    else:
    # ** location for hard-coded estimated Ic ** 
        estimated_Ic = 200e-6

    # set up the ranges
    range1 = estimated_Ic * 0.8
    range2 = estimated_Ic * 1.2
    range3 = estimated_Ic * 3.7
    
    # different density of points
    step_less_points = (range1)/50
    step_alot_points = (range2-range1)/400
    
    # start with lower density points
    for I in np.arange(0, range1, step_less_points):
        try:
            vf.set_current_fast_yoko(CurrentSource, I)

            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            V=V-extra_res*I
            I_values.append(I)
            # for fixing the offset
            V_values.append(V-offset)
            
            # current point
            current_x.append(I)
            current_y.append(V-offset)
            
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
            current_point.setData(current_x, current_y, symbol='o', symbolBrush ='r', symbolSize=7)
            app.processEvents()
            
            current_x = []
            current_y = []
            
            if go == 0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)    
                return 0,0,0
    
        except KeyboardInterrupt:
            print("\nExiting...\n")
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0,0,0

    # step with alot of points
    for I in np.arange(range1, range2, step_alot_points):
        try:
            vf.set_current_fast_yoko(CurrentSource, I)

            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
    
            # for fixing the offset
            V_values.append(V-offset)
            
            # current point
            current_x.append(I)
            current_y.append(V-offset)
            
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
            current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
            app.processEvents()
            
            current_x = []
            current_y = []
            
            if go == 0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0
            
        except KeyboardInterrupt:
            print("\nExiting...\n")
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0,0,0

    # Less points for rest of sweep
    for I in np.arange(range2, range3, step_less_points):
        try:
            vf.set_current_fast_yoko(CurrentSource, I)

            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)

            # for fixing the offset:
            V_values.append(V-offset)
            
            current_x.append(I)
            current_y.append(V-offset)
            
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
            current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
            app.processEvents()
            
            current_x = []
            current_y = []
            
            if go == 0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0
    
        except KeyboardInterrupt:
            print("\nExiting...\n")
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0,0,0


    #Sweep Current down less points
    for I in np.arange(range3-step_less_points, range2, -step_less_points):
        try:
            vf.set_current_fast_yoko(CurrentSource, I)
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            V_values.append(V-offset)
            
            current_x.append(I)
            current_y.append(V-offset)
            
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
            current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
            app.processEvents()
            
            current_x = []
            current_y = []
            
            if go ==0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0

        except KeyboardInterrupt:
            print("\nExiting...\n")
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0,0,0

    # Sweep down with alot of points around the estimated Ic
    for I in np.arange(range2-step_alot_points, range1, -step_alot_points):
        try:
            vf.set_current_fast_yoko(CurrentSource, I)
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            V_values.append(V-offset)
            
            current_x.append(I)
            current_y.append(V-offset)
            
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
            current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
            app.processEvents()
            
            current_x = []
            current_y = []
            
            if go ==0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0

        except KeyboardInterrupt:
            print("\nExiting...\n")
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0,0,0
    

    # final sweep with less points
    for I in np.arange(range1-step_less_points, 0, -step_less_points):
        try:
            vf.set_current_fast_yoko(CurrentSource, I)
            V = vf.read_voltage_fast(Voltmeter, VDwellTime)
            I_values.append(I)
            V_values.append(V-offset)
            
            current_x.append(I)
            current_y.append(V-offset)
            
            if I != 0:
                R_values.append(float(V)/float(I))
            else:
                R_values.append(0.0)

            # live plotting
            curve.setData(I_values,V_values, symbol='o', symbolBrush='w', symbolSize=5)
            current_point.setData(current_x, current_y, symbol='o', symbolBrush='r', symbolSize=7)
            app.processEvents()
            
            current_x = []
            current_y = []
            
            if go ==0:
                exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
                return 0,0,0
    
        except KeyboardInterrupt:
            print("\nExiting...\n")
            exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
            return 0,0,0

    # turn it all off, ready for next
    exitfunc(Switch, CurrentSource, card1, card2, channel1, channel2)
    return I_values, V_values, R_values