Esempio n. 1
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. 2
0
def distortion(v1, v2, freq, show=True):
    points = int(slab.maxSFfresponse / freq)
    if points > 100:
        points = 100
    if points < 50:
        raise slab.SlabEx("Frequency too high")

    cycles = 10
    slab.waveCosine(v1, v2, points)
    slab.setWaveFrequency(freq)
    slab.tranStore(cycles * points)
    t, s = slab.singleWaveResponse()
    if show:
        slab.plot11(t, s, "Time plot", "time(s)", "ADC1(V)")
    c, f = ftransform(s, t)
    if show:
        ac.plotFreq(f, c)

    # THD
    base = np.abs(c[cycles])
    tot = 0
    for i in range(2, 7):
        tot = tot + np.abs(c[i * cycles]) * np.abs(c[i * cycles])
    tot = np.sqrt(tot)
    print("tot: " + str(tot))
    thd = 100.0 * tot / base

    # THD+N
    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
Esempio n. 3
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. 4
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. 5
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. 6
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. 7
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. 8
0
import slab_meas as meas
slab.setWaveFrequency(100)
slab.tranStore(500,1)
v = slab.waveResponse()
p = meas.period(v[1],v[0])
if not compare(p,0.01):
    raise slab.SlabEx("period measurement fails")
print('  period measurement pass')    
    
# FFT module test
print('FFT module test')
import slab_fft as fft
slab.tranStore(5000,1)
v = slab.waveResponse()
g,f=fft.ftransform(v[1],v[0])
slab.plot11(f,ac.dB(np.absolute(g)),"Frequency plot for 100 Hz tone","Frequency (Hz)","dB")
    
print()
print('All tests passed')
print()




   





Esempio n. 9
0
# Set prefix to locate calibrations
slab.setFilePrefix("../")

# Open serial communication
slab.connect()

# Increase accuracy
slab.setDCreadings(50)

# V Device curve
print "Performing measurements..."
#x,y1,y2,y3,y4 = slab.dcSweep(1,0.6,1.6,0.05)
x, y1, y2, y3, y4 = slab.dcSweep(1, 1.0, 3.0, 0.1)

# Set DACs to zero
slab.zero()

# Post processing low current
#Ib = (x - y1)/100.0   # In mA
#Ic = (3.3 - y2)/1.0   # In mA
Ib = (x - y1) / 6.8  # In mA
Ic = (3.3 - y2) / 0.047  # In mA
beta = Ic / Ib

# Plot
print "Plotting"
slab.plot11(Ic, beta, "Beta vs Ic", "Ic (mA)", "Beta")

# Close serial communication
slab.disconnect()
Esempio n. 10
0
# Locate slab in the parent folder
import sys
sys.path.append('..')
sys.path.append('.')

import slab

# Set prefix to locate calibrations
slab.setFilePrefix("../")

# (A) Sin plot

x = np.arange(0, 361, 1)
y = np.sin(np.pi * x / 180)

slab.plot11(x, y, "Sin plot", "Angle (deg)", "Sin(Angle)")

# (B) Sin,Cos plot

x = np.arange(0, 361, 1)
y1 = np.sin(np.pi * x / 180)
y2 = np.cos(np.pi * x / 180)

slab.plot1n(x, [y1, y2], "Sin and Cos plot", "Angle (deg)", "Sin,Cos(Angle)",
            ["Sin", "Cos"])

# (C) Sin,Cos plot
#     Different ranges and resolutions

x1 = np.arange(0, 721, 1)
y1 = np.sin(np.pi * x1 / 180)