def speed_test(host, n_pts=1000): time_array = np.zeros(n_pts) client = connect(host, name="oscillo") driver = Oscillo(client) driver.set_averaging(False) t0 = time.time() t_prev = t0 for i in range(n_pts): if cmd == "get_adc": driver.get_adc() elif cmd == "get_num_average": driver.get_num_average(0) t = time.time() time_array[i] = t - t_prev print host, i, time_array[i] t_prev = t print "{} us".format(1e6 * np.median(time_array)) # assert(np.median(time_array) < 0.003) return time_array
def speed_test(host, n_pts=1000): time_array = np.zeros(n_pts) client = load_instrument(host, instrument='oscillo') driver = Oscillo(client) driver.set_averaging(False) t0 = time.time() t_prev = t0 for i in range(n_pts): if cmd == 'get_adc': driver.get_adc() elif cmd == 'get_num_average': driver.get_num_average() t = time.time() time_array[i] = t - t_prev print host, i, time_array[i] t_prev = t print np.median(time_array) plt.plot(time_array) driver.close()
plt.ylim([-2*np.pi, 2*np.pi]) plt.ion() plt.show() phase_previous_pos = 0 phase_previous_neg = 0 temperature = 20 # degrees Celsius data = np.zeros((1000,2)) + temperature # Hanning FFT Window window = 0.5 * (1-np.cos(2 * np.pi * np.arange(4095) / 4095)) with open('temperature.csv','w') as f: for i in range(5000): driver.get_adc() # Separate positive and negative slopes in the triangle waveform adc_pos = driver.adc[0,0:4095] adc_neg = driver.adc[0,4096:8191] fft_pos = np.fft.fft(adc_pos * window) fft_neg = np.fft.fft(adc_neg * window) phase_adc_pos = np.angle(fft_pos) phase_adc_neg = np.angle(fft_neg) # The phase of the frequency modulation phase_pos = phase_adc_pos[6] phase_neg = phase_adc_pos[6]
# Enable laser driver.start_laser() # Set laser current current = 30 # mA driver.set_laser_current(current) # Modulation on DAC amp_mod = 0.2 freq_mod = 1e6 driver.dac[1, :] = amp_mod*np.sin(2 * np.pi * freq_mod * driver.sampling.t) driver.set_dac() # Signal on ADC driver.get_adc() signal = driver.adc[0, :] # Plot plt.plot(driver.sampling.t, signal) plt.show() # Plot psd_signal = np.abs(np.fft.fft(signal)) ** 2 plt.semilogy(1e-6 * np.fft.fftshift(driver.sampling.f_fft), np.fft.fftshift(psd_signal)) plt.xlabel('Frequency (MHz)') plt.show() # Disable laser driver.stop_laser()