bicarlsen / easy-biologic Goto Github PK
View Code? Open in Web Editor NEWPython library for communicating with Biologic devices.
License: GNU General Public License v3.0
Python library for communicating with Biologic devices.
License: GNU General Public License v3.0
Hi there,
First of all, I'd like to thank you for writing this library, it makes Biologic potentiostat to be more easily integrated to the project I'm currently working on.
I was wondering whether you have thought about/ in progress writing the PEIS base program?
Thanks for your time, hope to hear from you soon!
Sincerely,
Marcus
Hello,
I didn’t know where I could ask a question, therefore I opened this issue here.
Do you know if it is possible to load .mps files (exported from the EC-Lab, which contain the sequence and parameters of techniques in text form) via the Python API from Biologic or with easy-biologic and then run it. I already have a number of such exported files with techniques and can import them very easily in the EC-Lab via Experiment -> Load Settings. It would be fantastic to have such a feature for the Python API as well. Do you know something about this?
Thanks in advance, Nicolas
Hello
My VSP-300 as the channel number 1 out of order. We removed it to send it for fix.
Unfortunaly the lib use the method "NumberOfChannels" to populate a list at connection, to initialise channels.
Because the channel number 1 is not here (so there are 5 channels) The connection fail.
I wonder if it's possible to give the exect list of active channels in the mysterious XLX file that you tlk about.
In the documentation you talk about :
"+ connect( bin_file, xlx_file ): Connects to the device, loading the bin and xlx file if provided."
wath is the content of this xlx file ?
thnaks
Hello,
I was trying to implement pulse electrodeposition through the CA/CP functions. When I was implementing it, I found the voltages/currents/durations are limited to certain sizes in CA and CP. To be specific, when the length of duration is too large, an error occurs in both cases:
EcError: ERR_GEN_INVALIDPARAMETERS (-4): Invalid function parameters.
Here is the code to replicate the error:
import easy_biologic
import sys
import logging
import time
import numpy as np
from matplotlib import pyplot as plt
bl_potentiostat = easy_biologic.BiologicDevice('USB0')
bl_potentiostat.connect()
params={'voltages':[0.4,0.5,0.6,0.7,0.8],
'durations':[0.1,0.1,0.1,0.1,0.1],
'vs_initial':False,
'time_interval':0.1,
'current_interval': 0.001}
durations = np.tile([0.001,0.002],(100,1)).flatten()
voltages = np.tile([0.1,0.2],(100,1)).flatten()
params['voltages'] = voltages.tolist()
params['durations'] = durations.tolist()
ca = easy_biologic.base_programs.CALimit(device=bl_potentiostat,params = params,channels = [0])
ca.run()
The same error occurs for CP.
We are trying to control a SP-200, but always get the error message:
ERR_GEN_FUNCTIONFAILED (-6): Function failed
when we try to execute prg.run()
.
With prg
as:
prg = ebp.OCV( bl, params_ocv, channels = [0])
but we also tried JV, MMP or CALimit always with the same error message to .run().
More details in the nootebook:
Any idea what the problem could be?
I used python -m easy_biologic.find_devices
in the terminal to find my potentiostat and got "VMP3: USB0" as a result. Using that for bl = ebl.BiologicDevice('VMP3: USB0')
does not work.
The error received is:
EcError: ERR_COMM_CONNECTIONFAILED (-201): Could not establish communication with instrument.
Using only "USB0" returns KeyError: -7
. And apparently, error -7 does not exist in the error list.
The Biologic USB driver is installed and the EC-lab software works fine with USB connection. I'm using the Biologic VMP3B-10 potentiostat.
Do I maybe use the wrong keyword with 'USB0'?
Code:
import easy_biologic as ebl
import easy_biologic.base_programs as blp
bl = ebl.BiologicDevice('USB0')
Full error:
File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_errors.py", line 108, in __init__
( code, message ) = EcError.errors[ value ]
KeyError: -7
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "D:\Python\untitled0.py", line 12, in <module>
bl = ebl.BiologicDevice('USB0')
File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\device.py", line 61, in __init__
self.populate_info()
File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\device.py", line 209, in populate_info
self.connect()
File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\device.py", line 178, in connect
ecl.init_channels(
File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_lib.py", line 864, in init_channels
validate( err )
File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_lib.py", line 1615, in validate
raise EcError( err )
File "C:\ProgramData\Anaconda3\lib\site-packages\easy_biologic\lib\ec_errors.py", line 111, in __init__
raise ValueError( f'Unknown error value {value}.' )
ValueError: Unknown error value -7.`
```
Connection via USB is not possible, whereas connection via LAN works.
Using find_devices.py with USB connection doesn't work and doesn't display a device name or port. With LAN the script shows the IP address.
Not possible to create device by ebl.BiologicDevice('USB0').
Biologic USB driver was installed. EC-lab software detects the USB port, once one installed the driver. With the EC-Lab software it is possible to control the potentiostat via USB (already tried out). Used Biologic's VMP3 potentiostat.
I haven't checked to carefully, but as I remember from EC-lab documentation there is some limit to which techniques that can be implemented (not PEIS with multisine option for example). Do you know if this is the case for adding the GEIS technique (Galvanostatic Electrochemical Impedance Spectroscopy)? If it is possible, I can give it a try to add it.
Hello,
In the run function of CP class, the maximum current is defined as
i_max = max( currents )
while a large amount of the later if statement compares the scale of max_i
, which might be some error during the function definition. It would be good if this can be corrected :)
Hello
I don't understand the
"duration" parameter of a PEIS technique.
It doesn't appears in EC-lab development package doc :
In this doc there is
vs_initial
vs_final
initial_voltage_step
final_voltage_step
duration_step
step_number
record_every_dT
record_every_dI
final_frequency
initial_frequency
sweep
Amplitude_Voltage
Frequency_number
Average_N_times
Correction
Wait_for_steady
Can you explain how this parameter works ?
It seems to be a timeout like, but it's difficult to estimate the duration of this kind of technique.
Thanks
Hello,
I was trying to use CALimit to control the voltage of the potentiostat but found that the maximum length of the collected data is limited to 190. For example, when I ran the following code
import easy_biologic
import sys
import logging
import time
from matplotlib import pyplot as plt
bl_potentiostat = easy_biologic.BiologicDevice('USB0')
print('Potentiostat device connected.')
bl_potentiostat.connect(bin_file="C:\\Users\group\Documents\GitHub\easy-biologic\easy_biologic\techniques-6.01\kernel.bin", xlx_file="C:\\Users\group\Documents\GitHub\easy-biologic\easy_biologic\techniques-6.01\Vmp_ii_0437_a6.xlx")
ca = easy_biologic.base_programs.CALimit(device=bl_potentiostat,
params={'voltages':[0.4,0.5,0.6,0.7,0.8],
'durations':[0.1,0.1,0.1,0.1,0.1],
'vs_initial':False,
'time_interval':0.001,
'current_interval': 0.001},
channels=[0])
print(len(ca.data[0])) # 190
The length of the gathered data is 190. But since I have applied the control for 0.5 seconds with a time_interval of 0.001s, the total data length can be 500. I would really appreciate it if you could give me some information!
Thanks!
I am trying to give your package a go to control a biologic sp300.
As a first attempt, I would like to run an OCV technique.
I can connect to the device at a specific IP address with this:
import easy_biologic as ebl
# create device and connect to it
bl = ebl.BiologicDevice('172.17.9.42')
bl.connect()
If then try and load a technique like this:
params = {
'time': 10,
'time_interval' : 1,
'voltage_interval' : 0.01
}
bl.load_technique(0,'ocv',params)
Then I get the following error:
easy_biologic.lib.ec_errors.EcError: ERR_TECH_INCOMPATIBLEECC (-401): Ecc file not compatible with the channel firmware.
But I don't know what to do about it. Can you make a suggestion? Is the firmware on the device a newer/different version to the ocv.ecc file used by the package? If so how can I use the latest version of ecc
file?
Thanks!
hello,
I try to use the lib with a VSP300.
I installed easy_biologic Version 0.3.2 via pip
And I have an error while performing an exemple PEIS measure
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\site-packages\easy_biologic\base_programs.py", line 1148, in run 'Duration_step': ch_params[ 'duration' ], KeyError: 'duration'
any idea?
This is an additional issue to the problem discussed before. (#6)
When running the CP, we can define the reading of data via either time_interval
or 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.
Hello, I have use this package to try to control my SP-300, but when I run the test code, I have the errors as shown below,
Traceback (most recent call last):
File ~\AppData\Local\Programs\Python\Python312\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
exec(code, globals, locals)
File c:\modulationmicroscope\easy-biologic\tests\ocv.py:23
prg.run()
File c:\modulationmicroscope\easy-biologic\easy_biologic\base_programs.py:668 in run
self._run( 'ocv', params, retrieve_data = retrieve_data )
File c:\modulationmicroscope\easy-biologic\easy_biologic\program.py:514 in _run
asyncio.run( self._retrieve_data( read_interval ) )
File ~\AppData\Local\Programs\Python\Python312\Lib\asyncio\runners.py:190 in run
raise RuntimeError(
RuntimeError: asyncio.run() cannot be called from a running event loop
import logging
import easy_biologic as ebl
import easy_biologic.base_programs as ebp
logging.basicConfig( level = logging.DEBUG )
channels = [ 0 ]
by_channel = False
params = {
'time': 10
}
save_path = 'D:\\EC-lab_test'
if not by_channel:
# file if saving individually
save_path += '.csv'
bl = ebl.BiologicDevice( 'USB0')
# bl.connect()
prg = ebp.OCV( device=bl, params = params, channels= channels)
prg.run()
prg.save_data( save_path, by_channel = by_channel )
I have also run the code below, I got the informations.
print(bl.info)
<easy_biologic.lib.ec_lib.DeviceInfo object at 0x000001BD452BF2D0>
print(bl.kind)
DeviceCodes.KBIO_DEV_SP300
And I have checked the firmware version is 11.4, and the technique files (.dll) version is "techniques-6.04", So I was wondering that do you have any idea about how to fix this problem? I have struggled in this problem for more than one day, and I have no idea how to solve this probelm.
Thanks!
Package is incompatible with python 3.11.4. This is because asyncio does not have a coroutine attribute (was deprecated previously and now removed).
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
Cell In[3], line 3
1 import sys
2 sys.path.insert(0, r'C:\Users\rvv\Github\easy-biologic')
----> 3 import easy_biologic as ebl
4 import easy_biologic.base_programs as blp
7 # create device
File ~\Github\easy-biologic\easy_biologic\__init__.py:8
4 raise OSError( 'easy_biologic can only be used on Windows.' )
6 from ._version import __version__, __version_info__
----> 8 from .device import BiologicDevice
9 from .program import BiologicProgram
10 from .program import ProgramRunner
File ~\Github\easy-biologic\easy_biologic\device.py:12
9 import ctypes as c
10 from collections import namedtuple
---> 12 from .lib.ec_errors import EcError
13 from .lib import ec_find as ecf
14 from .lib import ec_lib as ecl
File ~\Github\easy-biologic\easy_biologic\lib\__init__.py:1
----> 1 from . import data_parser
2 from . import ec_errors
3 from . import ec_find
File ~\Github\easy-biologic\easy_biologic\lib\data_parser.py:30
27 import math
28 from collections import namedtuple
---> 30 from . import ec_lib as ecl
33 # # Parser
36 def parse( data, info, fields = None, device = None ):
File ~\Github\easy-biologic\easy_biologic\lib\ec_lib.py:565
563 for method in methods:
564 async_name = method.__name__ + '_async'
--> 565 globals()[ async_name ] = @asyncio.coroutine( method )
566
567
AttributeError: module 'asyncio' has no attribute 'coroutine'
On the vanilla Python environment, my example.py results in showing this error message.
Please suggest how this problem is fixed.
In CP, the maximum current is obtained according to i_max = max( currents )
, which determines the IRange later. But if the currents are passed as negative values (e.g., to reduce metallic salt in working electrode), the IRange would not be correct.
Maybe measuring the maximum of the absolute values of currents can be the solution. Something like:
currents = [abs(current) for current in currents]
i_max = max( currents )
I discover an issue
that occurs when you install the library for all users (using pip in a admin command line) .
Lanching a measure I get :
File "C:\Program Files\Python39\lib\site-packages\easy_biologic\program.py", line 482, in _run
self.device.load_technique(
File "C:\Program Files\Python39\lib\site-packages\easy_biologic\device.py", line 298, in load_technique
ecl.load_technique(
File "C:\Program Files\Python39\lib\site-packages\easy_biologic\lib\ec_lib.py", line 1024, in load_technique
validate( err )
File "C:\Program Files\Python39\lib\site-packages\easy_biologic\lib\ec_lib.py", line 1615, in validate
raise EcError( err )
easy_biologic.lib.ec_errors.EcError: ERR_TECH_ECCFILECORRUPTED (-402): ECC file corrupted.
Hi, I am testing the program to run a VSP-300 potentiostat. This is a class SP-300 potentiostat, but due to it being identified as a type: KBIO_DEV_VSP300, it will be identified as a VMP3 system (i.e., not KBIO-DEV_VSP300) when loading the *.ecc files in the base_programs.py. This should thus be the *4.ecc files and not *.ecc. Is there a way to override this so the correct identification/class occurs?
Relevant code: line 425:
"self._data_fields = (
dp.SP300_Fields.OCV
if self.device.kind is ecl.DeviceCodes.KBIO_DEV_SP300 else
dp.VMP3_Fields.OCV
)"
For multi channels' connection, I need to use floating mode instead of ground mode. How can I switch the mode?
Hello
I whant to set both Electrode connection to STANDARD and channel 6 hardware configuration to FLOATING, and I'm not sure to understand the syntax.
Is the following is good ?
import easy_biologic as ebl
bl = ebl.BiologicDevice( '192.168.1.2' )
bl.set_channel_configuration(5,FLOATING,STANDARD)
thanks
The unit of the rate in args is defined as mV/s [Default: 10]. When call the run function, this following value is past:
'Scan_Rate': [ ch_params[ 'rate' ]* 10e-3 ]* 5,
Since 10e-3 = 0.01 in python, does it scale the scan rate correctly? One of my colleagues found it was not consistent.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.