bicarlsen / easy-biologic

Python library for communicating with Biologic devices.
GNU General Public License v3.0
18 stars 11 forks source link

Strange behaviour in recording data #10

Closed chemyibinjiang closed 2 years ago

chemyibinjiang commented 2 years ago

This is an additional issue to the problem discussed before. (https://github.com/bicarlsen/easy-biologic/issues/6) When running the CP, we can define the reading of data via either time_intervalor voltage_interval. In the case where voltage_interval is large (e.g., set as 1), the read-out purely depends on time_interval and by setting data_interval in the _run function to be a small value (e.g., set as 0.0001), it works fine. However, if the voltage_interval is decreased to the default value (0.001), it can not record the complete data. The same problem exists for CA, when current_interval is small.

# Intialization
import easy_biologic
import sys
import logging
import time 
from matplotlib import pyplot as plt
from time import time

bl_potentiostat = easy_biologic.BiologicDevice('USB0')
print('Potentiostat device connected.')
bl_potentiostat.connect()
# define params
params = {'currents': [1e-05, 2e-05],'durations': [0.001, 0.001], 'vs_initial': False,'time_interval': 0.0002, 'N_Cycles': 80000,'voltage_interval': 1}
cp = easy_biologic.base_programs.CP(bl_potentiostat,params = params, channels = [0])
cp.run()
print(len(cp.data[0])) #840001
print(cp.data[0][-1]) # CP_Datum(time=161.28000570461154, voltage=1.8486301898956299, current=2.0009510990348645e-05, power=3.699018610180691e-05, cycle=79999)

If the params are changed to params = {'currents': [1e-05, 2e-05],'durations': [0.001, 0.001], 'vs_initial': False,'time_interval': 0.0002, 'N_Cycles': 80000,'voltage_interval': 0.001}, by running the program, the data become:

print(len(cp.data[0])) #1049370
print(cp.data[0][-1]) # CP_Datum(time=155.2342134907667, voltage=1.8418974876403809, current=9.98685572994873e-06, power=1.8394764478419506e-05, cycle=77001)

In both cases, the control time of potentialstat is the same and normal.

bicarlsen commented 2 years ago

The time_interval and voltage_interval both define the maximum change the respective values can take before the Biologic records data, and a mesurement is taken whenever one of the thresholds is exceeded. So, when you set the voltage_interval to be small many more readings will be taken as that threshold is surpassed more often. Thus, you should also set the data_interval in the _run function to be small in this case so data is read out more quickly and the memory of the Biologic is not filled.