from potentiostat import Potentiostat import sys import matplotlib.pyplot as plt port = '/dev/ttyACM0' num_pulse = 25 # Number of pulses (max = 25) lo_pulse = (500, -0.5) # Low pulse, 500ms @ -0.5V hi_pulse = (2000, 0.7) # High pulse, 2000ms @ 0.7V dev = Potentiostat(port) hw_variant = dev.get_hardware_variant() dev.set_curr_range('100uA') dev.set_sample_rate(300) step_list = [] # Add pulses to step list for i in range(num_pulse): step_list.append(lo_pulse) step_list.append(hi_pulse) # Test name and test parameters test_name = 'multiStep' test_param = { 'quietValue': 0.0, 'quietTime': 0, 'step': step_list, }
datafile = 'data.txt' # Name of output data file test_name = 'constant' # Name of test to run - constant volate voltammetery curr_range = '100uA' # Name of current range for test [-10uA, +10uA] sample_rate = 100.0 # Rate (samples/sec) at which to collect samples test_param = { 'quietValue': 0.0, # Output voltage during quiet peroid 'quietTime': 1000, # Duration of quiet period (ms) 'value': 2.5, # Output volatage (V) durring constant voltage test 'duration': 4000, # Duration of constant voltage test (ms) } # Create Device object and set sample rate, current range and test parameters dev = Potentiostat(port) dev.set_sample_rate(sample_rate) dev.set_curr_range(curr_range) dev.set_param(test_name, test_param) # Run cyclic voltammetry test t, volt, curr = dev.run_test(test_name, display='pbar', filename=datafile) # plot results using matplotlib plt.subplot(211) plt.title('Voltage and current vs time') plt.plot(t, volt) plt.ylabel('potential (V)') plt.ylim(0, test_param['value'] * 1.1) plt.grid('on') plt.subplot(212)
}, # Multistep Test Data { 'quietValue': 0.0, 'quietTime': 1000, 'step': [(1000, -0.5), (1000, -0.2), (1000, -0.3), (1000, -0.0), (1000, -0.1), (1000, 0.3), (1000, 0.2), (1000, 0.5)], }, ] cpp = Potentiostat(port) cpp.set_curr_range(curr_range) cpp.set_sample_rate(sample_rate) print(test_name[int_test], test_data[int_test]) cpp.set_param(test_name[int_test], test_data[int_test]) t, volt, curr = cpp.run_test(test_name[int_test], display='pbar') file = open(datafile[int_test], 'w') file.write('Time \n' + str(t) + '\n' + 'Volt \n' + str(volt) + '\n' 'Curr \n' + str(curr) + '\n') plt.figure(1) plt.subplot(211) plt.plot(t, volt) plt.ylabel('potential (V)') plt.grid('on') plt.subplot(212) plt.plot(t, curr)