Пример #1
0
else:
    pl.plot(xrange,a3,label="ADC3(DAC3)")  
pl.plot(xrange,a4,label="ADC4(DAC1)") 

pl.legend(loc='lower right')         
pl.title("ADC(DAC) Test Curves")
pl.xlabel("DAC Ratiometric value")
pl.ylabel("ADC Ratiometric value")   
pl.grid()    
pl.show()    
 
 
 
sl.setSampleTime(0.002)
print "Sample time set to 2ms"
sl.setTransientStorage(200,1)
print "Transient storage set to 200 points"
sl.setVoltage(1,1.0)

print
print "[ ] Commands R, S and Y checked in next curve if:"
print "         Voltage is about 1V"
print "         Maximum time is 0.4s"
print "         Resolution is 2ms"
print

sl.tranAsyncPlot() 

print "For the next test you need to take and put ADC1 cable"
print "during the transient triggered test"
print "Sometimes you should connect it to GND and Vdd in sequence"
Пример #2
0
def sineGainAll(v1, v2, freq, npre=5, maxfs=-1):
    #global adc_delay

    # Check if SciPy is loaded
    slab.checkSciPy()

    # No sat warning yet
    satWarn = False

    # Load defaults
    if maxfs == -1:
        maxfs = slab.maxSFfresponse
    # Checks
    if not slab.opened:
        raise slab.SlabEx("Not connected to board")
    if v1 > v2:
        raise slab.SlabEx("Minimum value must be below maximum value")
    if maxfs > 1 / slab.min_sample:
        raise slab.SlabEx("Too high max sample frequency")
    if freq > maxfs / 4.0:
        raise slab.SlabEx("Frequency too high")

    # This command is silent
    prev_verbose = slab.setVerbose(0)

    # Create wave
    if maxfs > 200 * freq:
        npoints = 200
        nsamples = 200
    else:
        npoints = int(maxfs / freq)
        nsamples = int(200 / npoints) * npoints
        npre = int(npre * npoints / nsamples)

    # Create test wave
    amplitude = (v2 - v1) / 2.0
    slab.waveSine(v1, v2, npoints)
    st = slab.setWaveFrequency(freq)

    # Setup measurement
    slab.setTransientStorage(nsamples, 1)

    # Measure all channels
    list = []
    for channel in range(1, nadcs + 1):
        time, out = slab.singleWaveResponse(channel, npre, tinit=0.0)

        # Check peak values
        vmax = slab.highPeak(out)
        vmin = slab.lowPeak(out)
        if (vmax / slab.vref) > SAT_HIGH or (vmin / slab.vref) < SAT_LOW:
            satWarn = True

        # Find best fit
        angles = np.array(range(0, nsamples)) * 2.0 * np.pi / npoints
        # Initial guess
        mean0 = np.mean(out)
        amp0 = (vmax - vmin) / 2.0
        phase0 = 0
        # Function to optimize
        optimize_func = lambda x: x[0] * np.sin(angles + x[1]) + x[2] - out
        # Perform optimization
        amp, phase, mean = leastsq(optimize_func, [amp0, phase0, mean0])[0]

        # Warn if needed
        if satWarn:
            slab.warn("Saturated reading at ADC " + str(channel))

        # Gain to reported
        gain = amp * np.cos(phase) / amplitude + 1j * amp * np.sin(
            phase) / amplitude

        # Add to list
        list.append(gain)

    # Restore verbose level
    slab.setVerbose(prev_verbose)

    # Return the list
    return list
Пример #3
0
fc = 72 Hz
'''

# Locate slab in the parent folder
import sys
sys.path.append('..')
sys.path.append('.')

import slab

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

# Open serial communication
slab.connect()

# Set storage requirements
slab.setTransientStorage(100, 2)

# Set wave
slab.waveSine(1.0, 2.0, 100)

# Set frequency
slab.setWaveFrequency(72.3)

# Measure
slab.wavePlot(10)

# Close serial communication
slab.disconnect()
Пример #4
0
sys.path.append('..')
sys.path.append('.')

import slab

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

# Open serial communication
slab.connect()

# Set sample time to 100us
slab.setSampleTime(0.0001)

# Set storage requirements
slab.setTransientStorage(200, 1)

# (A) Creates and measures a square wave
slab.waveSquare(1.0, 2.0, 100)
slab.wavePlot()

# (B) Creates and measures a triangle wave
slab.waveTriangle(1.0, 2.0, 100)
slab.wavePlot()

# (C) Creates and measures a sawtooth wave
slab.waveSawtooth(1.0, 2.0, 100)
slab.wavePlot()

# (D) Creates and measures a sine wave
slab.waveSine(1.0, 2.0, 100)