Example #1
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 #2
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 #3
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