Esempio n. 1
0
def iDeviceCurve(vi1,vi2,vii,vo1,vo2,voi=0.1,ri=1.0,ro=1.0,wt=0.1):

    # Check if SciPy is loaded
    slab.checkSciPy()

    i_range=np.arange(vi1,vi2,vii)
    o_range=np.arange(vo1,vo2,voi)
    plt.figure(facecolor="white")   # White border
    for vi in i_range:
        avo = []
        aio = []
        slab.setVoltage(2,vi)
        slab.wait(wt)
        a0 = slab.readVoltage(1)
        i_in = (vi - a0) / ri
        for vs in o_range:
            slab.setVoltage(1,vs)
            slab.wait(wt)
            a1 = slab.readVoltage(2)
            a2 = slab.readVoltage(3)
            curr = (a1 - a2) / ro
            avo.append(a2)
            aio.append(curr)
        lbl = "{:.6f}".format(i_in) + ' mA'    
        pl.plot(avo,aio,label=lbl)   
    slab.message(1,"Drawing curves")
    pl.legend(loc='upper right')         
    pl.title("Io(Vo) Device Curves as function of Ii")
    pl.xlabel("Output Voltage(V)")
    pl.ylabel("Output Current(mA)")   
    pl.grid()    
    pl.show()   
    pl.close()    
Esempio n. 2
0
def transferCurveII(v1,v2,vi=0.1,r1=1.0,r2=1.0,wt=0.1,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy()

    # Perform a DC Sweep
    x,y1,y2,y3,y4 = slab.dcSweep(1,v1,v2,vi,wt)
    # Set DAC to zero
    slab.writeChannel(1,0.0)  
    # Calculate current
    cin  = (x-y1) / r1
    cout = (slab.vdd - y2) / r2
    # Show curve
    slab.message(1,"Drawing curve")
    plt.figure(facecolor="white")   # White border
    pl.plot(cin,cout)
    pl.xlabel("Input (mA)")
    pl.ylabel("Output (mA)")
    pl.title("DC I(I) Transfer Curve")
    pl.grid()
    pl.show()   
    pl.close()
    
    if slab.plotReturnData or returnData:
        return cin,cout 
Esempio n. 3
0
def freqResponse(v1, v2, fvector, channel=1, npre=5, maxfs=-1):
    gvector = []
    for f in fvector:
        slab.message(1, "Measuring at " + str(f) + " Hz")
        gain = sineGain(v1, v2, f, channel, npre, maxfs)
        gvector.append(gain)
    if slab.scipy:
        return np.array(gvector)
    else:
        return gvector
Esempio n. 4
0
def curveVI(v1,v2,vi=0.1,r=1.0,wt=0.1,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy() 

    # Perform a DC sweep
    x,y1,y2,y3,y4 = slab.dcSweep(1,v1,v2,vi,wt)
    # Set DAC 1 to zero
    slab.writeChannel(1,0.0)
    # Plot result
    slab.message(1,"Drawing curve")
    vd = y2
    id = (y1 - y2) / r
    slab.plot11(vd,id,"V-I plot","Voltage (V)","Current (mA)")     
    
    if slab.plotReturnData or returnData:
        return vd,id
Esempio n. 5
0
def freqResponseAll(v1, v2, fvector, npre=5, maxfs=-1):
    glist = []
    for i in range(0, nadcs):
        glist.append([])
    for f in fvector:
        slab.message(1, "Measuring at " + str(f) + " Hz")
        gains = sineGainAll(v1, v2, f, npre, maxfs)
        for i in range(0, nadcs):
            glist[i].append(gains[i])

    if slab.scipy:
        rlist = []
        for g in glist:
            rlist.append(np.array(g))
        return rlist
    else:
        return glist
Esempio n. 6
0
def curveVV(v1,v2,vi=0.1,wt=0.1,adc2=False,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy() 

    # Perform a DC sweep
    x,y1,y2,y3,y4 = slab.dcSweep(1,v1,v2,vi,wt)
    
    # Check ADC2 option
    if adc2:
        x = y2
    
    # Plot result
    slab.message(1,"Drawing curve")
    slab.plot11(x,y1,"V(V) Plot","Input (V)","Output(V)")
    
    if slab.plotReturnData or returnData:
        return x,y1
Esempio n. 7
0
def curveVIbridge(v1max,v2max,vi=0.1,vmin=0.0,r=1.0,wt=0.1,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy() 

    # Perform first DC sweep
    slab.message(1,"Positive curve")
    slab.setVoltage(2,vmin)                                 # Set DAC 2 to vmin
    xf,y1f,y2f,y3f,y4f = slab.dcSweep(1,vmin,v1max,vi,wt)   # Sweep DAC 1

    # Perform second DC sweep
    slab.message(1,"Negative curve")
    slab.setVoltage(1,vmin)                                 # Set DAC 1 to vmin
    xr,y1r,y2r,y3r,y4r = slab.dcSweep(2,vmin,v2max,vi,wt)   # Sweep DAC 2
    
    # Set DACs to vmin
    slab.setVoltage(1,vmin)
    slab.setVoltage(2,vmin)
    
    # Join the curves
    vd=[]
    id=[]
    lenr=len(xr)
    for i in range(0,lenr):
        pos = lenr - i - 1
        vd.append(y2r[pos]-y3r[pos])
        id.append((y1r[pos]-y2r[pos])/r)
    for i in range(0,len(xf)):
        vd.append(y2f[i]-y3f[i])
        id.append((y1f[i]-y2f[i])/r)
    
    plt.figure(facecolor="white")   # White border
    pl.plot(vd,id)      
    pl.xlabel("Voltage (V)")
    pl.ylabel("Current (mA)")
    pl.title("V-I plot in bridge mode")
    pl.grid()
    pl.show() 
    pl.close()
    
    if slab.plotReturnData or returnData:
        return vd,id        
Esempio n. 8
0
def curveVVref(v1,v2,vi=0.1,wt=0.1,adc3=False,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy()

    # Perform a DC sweep
    x,y1,y2,y3,y4 = slab.dcSweep(1,v1,v2,vi,wt)
    
    # Check ADC3 option
    if adc3:
        x = y3
    
    # Plot result
    slab.message(1,"Drawing curve")
    vi = x - y2
    vo = y1 - y2
    slab.plot11(vi,vo,"V(V) Plot with reference","Input (V)","Output(V)") 
    
    if slab.plotReturnData or returnData:
        return vi,vo
Esempio n. 9
0
def curveVIref(v1,v2,vi=0.1,r=1.0,vr=-1,wt=0.1,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy() 

    # Perform a DC sweep
    x,y1,y2,y3,y4 = slab.dcSweep(1,v1,v2,vi,wt)
    # Set DAC 1 to Vdd/2
    slab.setVoltage(1,slab.vdd/2)
    # Plot result
    req =  r / 2
    if vr < 0:
        vr = slab.vdd / 2
    vd = y1 - y2
    id = (y2 - vr)/req
    slab.message(1,"Drawing curve")
    slab.plot11(vd,id,"V-I plot with reference","Voltage (V)","Current (mA)") 
    
    if slab.plotReturnData or returnData:
        return vd,id
Esempio n. 10
0
def hystVVcurve(v1,v2,vi=0.1,wt=0.1,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy()

    # Perform DC sweeps
    xf,y1f,y2f,y3f,y4f = slab.dcSweep(1,v1,v2,vi,wt)
    xr,y1r,y2r,y3r,y4r = slab.dcSweep(1,v2,v1,-vi,wt)
    # Plot result
    slab.message(1,"Drawing curves")
    plt.figure(facecolor="white")     # White border
    pl.plot(xf,y1f,label="Forward");
    pl.plot(xr,y1r,label="Back");
    pl.legend(loc='lower right')         
    pl.title("V(V) Hysteresis Curve")
    pl.xlabel("Input Voltage(V)")
    pl.ylabel("Output Voltage(V)")   
    pl.grid()    
    pl.show()   
    pl.close()

    if slab.plotReturnData or returnData:
        return xf,y1f,xr,y1r   
Esempio n. 11
0
def ioCurve():
    slab.message(1, "Input between DAC1+ADC1 and GND")
    slab.message(1, "Output between ADC2 and GND")

    # Perform a DC sweep
    x, y1, y2, y3, y4 = slab.dcSweep(1, 0.0, 3.0, 0.1)

    # Plot result
    slab.message(1, "Drawing curve")
    slab.plot11(y1, y2, "V(V) Plot", "Input (V)", "Output(V)")
Esempio n. 12
0
def curveVVbridge(vp,vn,vi=0.1,vmin=0.0,wt=0.1,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy() 

    # Perform the positive DC sweep
    slab.message(1,"Positive curve")
    slab.setVoltage(2,vmin)
    xp,y1p,y2p,y3p,y4p = slab.dcSweep(1,vmin,vp,vi,wt)
    # Perform the negative DC sweep
    slab.message(1,"Negative curve")
    slab.setVoltage(1,vmin)
    xn,y1n,y2n,y3n,y4n = slab.dcSweep(2,vmin,vn,vi,wt)
    
    # Join all measurements
    x=[]
    y=[]
    
    ln = len(xn)
    for i in range(0,ln):
        pos = ln-i-1
        xvalue = y1n[pos]-y2n[pos]
        yvalue = y3n[pos]-y4n[pos]
        x.append(xvalue)
        y.append(yvalue)
        
    lp = len(xp)    
    for i in range(0,lp):
        xvalue = y1p[i]-y2p[i]
        yvalue = y3p[i]-y4p[i]
        x.append(xvalue)
        y.append(yvalue) 
        
    x = np.array(x)
    y = np.array(y)    
    
    # Plot result
    slab.message(1,"Drawing curve")
    slab.plot11(x,y,"V(V) Bridge Plot","Input (V)","Output (V)")
    
    if slab.plotReturnData or returnData:
        return x,y 
Esempio n. 13
0
def curveVIbridgeOld(v1max,v2max,vi=0.1,r=1.0,wt=0.1,returnData=False):

    # Check if SciPy is loaded
    slab.checkSciPy() 

    # Perform first DC sweep
    slab.message(1,"Forward curve")
    slab.setVoltage(2,0.0)                            # Set DAC 2 to 0.0
    x,y1,y2,y3,y4 = slab.dcSweep(1,0.0,v1max,vi,wt)   # Sweep DAC 1

    # First plot
    vd = y2 - y3
    id = (y1 - y2)/r
    plt.figure(facecolor="white")   # White border
    pl.plot(vd,id)

    # Perform second DC sweep
    slab.message(1,"Backward curve")
    slab.setVoltage(1,0.0)                            # Set DAC 1 to 0.0
    x,y1,y2,y3,y4 = slab.dcSweep(2,0.0,v2max,vi,wt)   # Sweep DAC 2
    
    # Set DACs to zero
    slab.writeChannel(1,0.0)
    slab.writeChannel(2,0.0)
    
    # Second plot
    slab.message(1,"Drawing curve")
    vd = y2 - y3
    id = (y1 - y2)/r
    pl.plot(vd,id)
    
    pl.xlabel("Voltage (V)")
    pl.ylabel("Current (mA)")
    pl.title("V-I plot in bridge mode")
    pl.grid()
    pl.show() 
    pl.close()
    
    if slab.plotReturnData or returnData:
        return vd,id
Esempio n. 14
0
def liveVoltage():
    slab.message(1, "User CTRL+C to exit")
    slab.dcLive()
Esempio n. 15
0
def zero():
    slab.zero()
    slab.message(1, "DACs set to zero")
Esempio n. 16
0
def bridgeCurve():
    slab.message(1, "Input between DAC1+ADC1 and DAC2+ADC2")
    slab.message(1, "Output between ADC3 and ADC4")
    dc.curveVVbridge(3.1, 3.1, 0.1, 0.1)
Esempio n. 17
0
    rms_total = std(s)
    rms_signal = base / np.sqrt(2.0)
    rms_no_signal = np.sqrt(rms_total * rms_total - rms_signal * rms_signal)
    thdn = 100.0 * rms_no_signal / rms_signal

    # Harmonic Distortion 2nd
    h2 = dB(np.abs(c[2 * cycles]) / base)

    # Harmonic Distortion 3rd
    h3 = dB(np.abs(c[3 * cycles]) / base)

    if show:
        print()
        print("THD   : " + str(thd) + " %")
        print("THD+N : " + str(thdn) + " %")
        print("Harmonic distortion 2nd : " + str(h2) + " dBc")
        print("Harmonic distortion 3rd : " + str(h3) + " dBc")
        print()

    return thd, thdn, h2, h3


################## CODE EXECUTED AT IMPORT ####################

# Show version information upon load
slab.message(1, "SLab FFT Submodule")
slab.message(
    1, "Version " + str(version_major) + "." + str(version_minor) + " (" +
    version_date + ")")
slab.message(1, "")
Esempio n. 18
0

'''
@bridgeCurve@
bridgeCurve()
Draws an input to output dc curve in bridge mode
Input is between DAC 1 and DAC 2 with a +/-3V range
and read between ADC 1 and ADC 2
Output is read between ADC 3 and 4
Included in slab_ez.py
'''


def bridgeCurve():
    slab.message(1, "Input between DAC1+ADC1 and DAC2+ADC2")
    slab.message(1, "Output between ADC3 and ADC4")
    dc.curveVVbridge(3.1, 3.1, 0.1, 0.1)


################## CODE EXECUTED AT IMPORT ####################

# Show version information upon load
slab.message(1, "SLab EZ Submodule")
slab.message(
    1, "Version " + str(version_major) + "." + str(version_minor) + " (" +
    version_date + ")")
slab.message(1, "")
slab.message(1, "Connecting with the board")
slab.message(1, "")
slab.connect()