bicarlsen / easy-biologic

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

Easy Biologic

A library allowing easy control over BioLogic devices. High and low level control over Biologic devices are available. Low level control is included in the lib subpackage, while high level control is available in the main module.

Install with python -m pip install easy-biologic

High Level API

There are two high level API modules containing three classes, and two convenience modules.

Biologic Device

Represents an instance of a Biologic Device.

Methods

Properties

Biologic Program

Abstract Class Represents a program to be run on a device.

Methods

Properties

Program Runner

Represents a program to be run on a device channel.

Methods

Properties

Base Programs

Contains basic implementations of BiologicPrograms.

OCV

Params

CA

Params
Methods

CALimit

Params
Methods

PEIS

Params

GEIS

Performs a Galvanostatic Electrochemical Impedance Spectroscopy

Params

CV

Performs a CV scan.

Params

MPP_Tracking

Performs MPP tracking.

Params

MPP

Runs MPP tracking, finding the initial Vmpp by first measuring Voc, then performing a CV scan from 0 to Voc.

Params

MPP Cycles

Runs multiple MPP cycles, performing Voc and CV scans at the beginning of each.

Params

Find Devices

A convenience script for finding connected devices.

Use

From a terminal run python -m easy_biologic.find_devices.

Low Level API

The low level API gives direct control of the Biologic device using the provided DLL libraries. The subpackage contains five modules.

EC Lib

Contains methods converting the BL_* DLL functions for use, enumeration classes to encapsulate program and device states, and C Structures for sending and receiving data from th device.

Methods

Enum Classes

Structures

Constants

Data Parser

Parses data received from a technique and contains technique fields for different device types.

Methods

Classes

EC Find

Implements the BL Find DLL.

Methods

All BL Find DLL functions are implemented under the same name.

Technique Fields

Parameter types for techniques. (Not all techniques are implemented.)

Classes

EC Errors

Implements EC errors.

Classes

Example

A basic example running an MPP program on channels 0 - 7 for 10 minutes.

import easy_biologic as ebl
import easy_biologic.base_programs as blp

# create device
bl = ebl.BiologicDevice( '192.168.1.2' )

# create mpp program
params = {
    'run_time': 10* 60      
}

mpp = blp.MPP(
    bl,
    params,     
    channels = [ 0, 1, 2, 3, 4, 5, 6 ]        
)

# run program
mpp.run( 'data' )

Following is an example running a CV scan for three cycles at a scan rate of 50 mV/s in channel 0. The experiment begins at 0.5 V and forward scans to -0.25 V, then scans backward to 0.8 V. In the final cycles, it scans to 1.0 V and finish the experiment.

import easy_biologic as ebl
import easy_biologic.base_programs as blp        

bl = ebl.BiologicDevice( '192.168.1.2' )

save_path = '/save_path/CV.csv'

params = {
    'start': 0.5,
    'end': -0.25,
    'E2': 0.8,
    'Ef': 1.0,
    'rate': 0.05,  
    'step': 0.001,    
    'N_Cycles': 2,
    'begin_measuring_I': 0.5,
    'End_measuring_I': 1.0,
}  

CV = blp.CV(
    bl,
    params,     
    channels = [0]   #channel is to be claimed.
)     

#run program and save data into csv file.
CV.run( 'data' )
CV.save_data(save_path)

Following is an example that run the OCV and use the OCV as the voltage in PEIS test.

import easy_biologic as ebl
import easy_biologic.base_programs as blp        

bl = ebl.BiologicDevice( '192.168.1.2' )

save_path_ocv = '/save_path/OCV.csv'

# Run OCP test
params_ocv = {
    'time': 2,
    'time_interval': 1,
}

ocv = blp.OCV(
    bl,
    params_ocv,
    channels=[0]
    )

ocv.run('data')
ocv.save_data(save_path_ocv)

voc = {
    ch: [datum.voltage for datum in data]
    for ch, data in ocv.data.items()
}

voc = {
    ch: sum(ch_voc) / len(ch_voc)
    for ch, ch_voc in voc.items()
}

# Run PEIS test
save_path_peis = '/save_path/PEIS.csv'

params_peis = {
    'voltage': list(voc.values())[0],
    'final_frequency': 1000,  # frequency unit: Hertz
    'initial_frequency': 1000000,  # frequency unit: Hertz
    'amplitude_voltage': 0.1,  # voltage unit: Volt
    'frequency_number': 60,
    'duration': 0,  # time unit: second
    'repeat': 10,
    'wait': 0.1
}

peis = blp.PEIS(
    bl,
    params_peis,
    channels=[0]
)

peis.run('data')
peis.save_data(save_path_peis)