I have a python program running a serial port connected to a teensy board. The program receives three lists from the board: t
, volt
, and curr
once one method is complete. I have three lists that I want to build using these values: t_list
, volt_list
, and curr_list
. The board is connected to a iorodeo potentiostat which can only run 25 cycles per method cycle, so I need to pass the values it gives from t
, volt
, and curr
to t_list
, volt_list
, and curr_list
for x number of method cycles to get around the 25 cycle limit. The problem is that the time list t
restarts at 0.003 seconds each method cycle so I end up with a repeating list of times in the final t_list
. Is there a way to take each new t
and have the python program calculate a new list which starts at the last time and ends with the total time in seconds?
The list t
gives a list of times in seconds with the same length as the curr
and volt
lists. For the script below, the first method returns a list t with a length of 250 starting at 0.003 seconds and ending at 0.75 seconds. It should be the same every method cycle.
Here is the script:
# -*- coding: utf-8 -*-
"""
Created on Sat Sep 18 18:34:59 2021
@author: dallo
"""
from potentiostat import Potentiostat
import sys
import matplotlib.pyplot as plt
from serial import Serial
port = 'COM7'
num_pulse = 25 # Number of pulses (max = 25)
lo_pulse = (10, -1.0)
hi_pulse = (20, -0.1)
num_cycles = 3
dev = Potentiostat(port)
hw_variant = dev.get_hardware_variant()
dev.set_curr_range('1000uA')
dev.set_sample_rate(300)
step_list = []
curr_list = []
volt_list = []
t_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,
}
for i in range(num_cycles):
volt = []
curr = []
dev.set_param(test_name,test_param)
t,volt,curr = dev.run_test(test_name,display='pbar')
curr_list.extend(curr)
volt_list.extend(volt)
t_list.extend(t)
volt_ax = plt.subplot(2,1,1)
plt.plot(t_list,volt_list)
plt.ylabel('potential (V)')
plt.grid('on')
plt.subplot(2,1,2, sharex=volt_ax)
plt.plot(t_list,curr_list)
plt.ylabel('current (uA)')
plt.xlabel('t (sec)')
plt.grid('on')
plt.show()