예제 #1
0
# Set the current wavelength to 800nm, wait for the motor to stop rotating, and then turn it off to tamp down the noise.

device.motorEnable = True
device.wavelength = startWavelength
device.waitForMotor()
times = np.linspace(0, modulationPeriodsPerMeasurement / fModulation,
                    samplesPerMeasurement)  # ms

for wavelength in wavelengthsToMeasure:
    device.motorEnable = True  # Enable the motor for movement
    device.wavelength = wavelength
    device.waitForMotor()
    device.motorEnable = False
    data = device.Measure()
    voltages = twosToVoltage(data)
    syncPulseLocations = twosToInteger(device.getSyncData())
    maximaSampleLocations = np.array(syncPulseLocations +
                                     voltageMaximaDelaySamples,
                                     dtype=np.int)[0:-3]
    minimaSampleLocations = np.array(syncPulseLocations +
                                     voltageMinimaDelaySamples,
                                     dtype=np.int)[0:-3]
    maxima = voltages[maximaSampleLocations]
    minima = voltages[minimaSampleLocations]
    Vpps = maxima - minima
    averageVpp = np.mean(Vpps)
    current = averageVpp / TIAResistance * 1e9 / 2  # current in nA, need the 2 because we have gain now.
    currents = np.append(currents, current)
    print(f'l: {wavelength}nm: {current:.2f}nApp')
예제 #2
0
samplingFrequency = 125 # 125kHz is the actual measured sampling rate, correct within 1Hz.
samplingPeriod = 1 / samplingFrequency
averaged = False
window = 'hann' # hann or boxcar

signalAmplitudeVpp = 0.05 # Volts
signalFrequency = 1 # kHz

device = SCPIDevice()
device.Configure(desiredMeasurements)

startSystemTime = time.perf_counter()
rawData = device.Measure()
endSystemTime = time.perf_counter()
deltaSystemTime = endSystemTime - startSystemTime
voltages = twosToVoltage(rawData)
dcOffset = np.mean(voltages)

# Set up our hanning / boxcar window
if window == 'hann':
    energyCorrectionFactor = 1.633156
    windowData = energyCorrectionFactor * scipy.signal.windows.hann(desiredMeasurements)

elif window == 'boxcar':
    energyCorrectionFactor = 1
    windowData = np.ones(desiredMeasurements)

voltagesFFTPowerOneSidedVrms = 4*np.square(np.abs(np.fft.fft((voltages-dcOffset)*windowData)))[0:halfDesiredMeasurements]
frequencies = np.arange(0, samplingFrequency/2, samplingFrequency/2/halfDesiredMeasurements)

theoreticalData = np.sin(2*np.pi*signalFrequency)
totalTransimpedance = 2 * TIAResistance
currents = np.array([])

# Set the current wavelength to 800nm, wait for the motor to stop rotating, and then turn it off to tamp down the noise.

device.motorEnable = True
device.wavelength = startWavelength
device.waitForMotor()

for wavelength in wavelengthsToMeasure:
    device.motorEnable = True  # Enable the motor for movement
    device.wavelength = wavelength
    device.waitForMotor()
    device.motorEnable = False
    data = device.Measure()
    voltages = correctionFactor * twosToVoltage(data)
    voltagePowerSpectrum = np.square(
        np.abs(np.fft.fft(voltages / len(voltages))))
    # Multiply by 2 to convert to single-sided spectrum
    voltageSignalPower = voltagePowerSpectrum[signalBin] * 2
    # Multiply by 2 to convert from RMS power into amplitude
    voltageSignalAmplitude = np.sqrt(voltageSignalPower * 2)
    # Multiply by 2 to convert to uApp instead of uA amplitude
    currentSignalAmplitudeuApp = voltageSignalAmplitude / totalTransimpedance * 2
    currentSignalAmplitudenApp = currentSignalAmplitudeuApp * 1e3

    currents = np.append(currents, currentSignalAmplitudenApp)
    print(f'{wavelength} nm: {currentSignalAmplitudenApp:.2f}')

device.motorEnable = True
device.wavelength = startWavelength  # set our device back to the original wavelength