import matplotlib.pyplot as plt import numpy as np from utils.pico_utils import open_pico, configure_channel, configure_sampling, getData ps = open_pico() configure_channel(ps, 'A') configure_channel(ps, 'B') ps.setSimpleTrigger('A', 1.0, 'Falling', timeout_ms=100, enabled=True) (sampling_interval, nSamples, maxSamples) = configure_sampling(ps, 1) dataA = getData(ps, nSamples, channel='A') dataB = getData(ps, nSamples, channel='B') ps.stop() ps.close() dataTimeAxis = np.arange(nSamples) * sampling_interval # Uncomment following for call to .show() to not block # plt.ion() fig, ax = plt.subplots() ax.plot(dataTimeAxis, dataA, label="A") ax.plot(dataTimeAxis, dataB, label="B") # ax.grid(True, which='major') ax.set_title("Picoscope 2000 waveforms") ax.set_ylabel("Voltage (V)") ax.set_xlabel("Time (ms)") ax.legend() plt.show()
step_size = int(def_input('Step size', default=2)) # set expected frequency of Arduino frequency = 490 pwm_vals = np.arange(0, 255, step_size) # voltages = np.linspace(0.05, 5, num=100) data_dir = def_input('Data directory', default='data/pwm/') name_root = def_input('Filename root', default='pwm') fout = open(data_dir + name_root + '.tsv', 'w') wvout = open('%swaveforms/%s_wv.csv' % (data_dir, name_root), 'w') fout.write('expected V\tf_A (Hz)\tV_A\tsigma_V_A\tf_B (Hz)\tV_B\tsigma_V_B\n') # fire up the scope ps = open_pico() configure_channel(ps, 'A') ps.setSimpleTrigger('A', 1.0, 'Falling', timeout_ms=100, enabled=True) (sampling_interval, nSamples, maxSamples) = configure_sampling(ps, 1.0/frequency, multiplicity=mult) # set up the plot plt.ion() fig, [ax, ax1] = plt.subplots(nrows=2, ncols=1, figsize=(12,9)) set_as_time(ax, fontsize=fontsize) set_as_freq(ax1, fontsize=fontsize) ax.set_ylim(top=7, bottom=-2) ax1.set_xlim(left=-4*frequency, right=4*frequency) ax1.set_ylim(top=1e4, bottom=-10) # make default plots t = np.linspace(0, sampling_interval*nSamples, num=nSamples)