API Reference

potentiostat

This module implements the serial interface to the Rodeostat open source Potentiostat.

copyright:
  1. 2017 by IO Rodeo

license:

MIT, see LICENSE.txt for more details.

exception potentiostat.potentiostat.DataDecodeException
class potentiostat.potentiostat.Potentiostat(port, timeout=2.0)

Provides a high level interface for serial communications with the Rodeostat.

Parameters:

port (str) – serial port associated with the Rodeostat, e.g. /dev/ttyACM0, COM1, etc.

Keyword Arguments:

timeout (float) – serial port ready timeout (seconds)

disconnect_all_mux_elect()

Disconnects all electrodes (reference, counter and working) when using the multiplexer expansion hardware.

get_all_curr_range()

Gets a list of all current ranges supported by the device.

Returns:

all available current ranges as str e.g., [‘1uA’, 10uA’, ‘100uA’, ‘1000uA’]

Return type:

list

get_all_elect_connected()

Gets the connected state (True/False) of all the electrodes (referene, counter and working). Only True if all are connected. This feature requires hardware version >= HW0.2

Returns:

connected stat of all electrodes (from device), True/False

Return type:

bool

get_all_volt_range()

Gets a list of the voltage ranges supported by the device.

Returns:

available voltage ranges, e.g., [‘1V’, ‘2V’, ‘5V’, ‘10V’]

Return type:

list

get_auto_connect()

Gets the value of the device’s auto-connect/auto-disconnect setting.

Returns:

autoconnect state (from device), True/False

Return type:

bool

get_ctr_elect_connected()

Gets the connected state (True/False) of the counter electrode. This feature requires hardware version >= HW0.2

Returns:

connection state of counter electrode (from device), True/False

Return type:

bool

get_curr()

Gets an immediate measurement of the working electrode current.

Returns:

working electrode current, units (uA)

Return type:

float

get_curr_range()

Gets the device’s range setting for measuring working electrode current (uA).

Returns:

working electrode current range setting (from device), e.g., ‘10uA’

Return type:

str

get_device_id()

Gets the current value of the device identification number

Returns:

device identification number

Return type:

int

get_enabled_mux_channels()

Get the list of currently enabled multiplexer working electrode channels

Returns:

enabled mux channels (from device).

Return type:

list

get_firmware_version()

Gets the version string for the firmware on the device.

Returns:

firmware version, e.g. ‘FW0.0.8’

Return type:

str

get_hardware_variant()

Returns a string representing the hardware variant.

Returns:

hardware variant, e.g. ‘10V_microAmpV0.2’

Return type:

str

get_hardware_version()

Returns string representing the hardware version.

Returns:

hardware version, e.g., ‘V0.2’

Return type:

str

get_mux_ctr_elect_connected()

Returns the connected state (True or False) of the counter electrode when using the multiplexer expansion hardware.

Returns:

connection state of mux counter electrode (from device), True/False

Return type:

bool

get_mux_enabled()

Get multiplexer expansion hardware enabled state

Returns:

enable state of mux hardware (from device), True/Fasle

Return type:

bool

get_mux_ref_elect_connected()

Gets the connected state (True/False) of the reference electrode when using the multiplexer expansion hardware.

Returns:

connection state of mux reference electrode (from device), True/False

Return type:

bool

get_mux_test_names()

Gets the list of tests which are compatible with the multiplexer expansion hardware

Returns:

tests compatible with multiplexer

Return type:

list

get_mux_wrk_elect_connected()

Returns the connected state (1, 2, 3, 4, 5, 6, 7 or False) of the working electrode when using the multiplexer expansion hardware.

Returns:

connection state of mux working electrode.

Return type:

int/bool

get_param(testname)

Returns the current values of the parameters for the specified voltammetric test.

Parameters:

testname (str) – name of voltammetric test, e.g., ‘cyclic’

Returns:

current values of test parameters

Return type:

dict

get_ref_elect_connected()

Gets the connected state (True/False) of the reference electrode. This feature requires hardware version >= HW0.2

Returns:

connected state of the reference electrode (from device), True/False

Return type:

bool

get_ref_elect_volt_range()

Gets the device’s voltage range setting for the reference electrode analog input.

Returns:

reference electrode voltage range returnd by device

Return type:

str

get_ref_volt()

Gets an immediate measurement of the potential between the working and reference electrode.

Returns:

potential between working and reference electrode, units (V)

Return type:

float

get_sample_period()

Gets the current value for the sample period (ms). The sample period is the time between samples.

Returns:

sample period (from device), units (ms)

Return type:

int

get_sample_rate()

Gets the measurement sample period (Hz). Note, the sample rate is 1/sample_period.

Returns:

sample rate (from device), unit (Hz)

Return type:

float

get_test_done_time(test, timeunit='ms')

Gets the time in seconds required to complete the specified test including any quietTime, etc.

Parameters:

test (str) – test name, e.g., ‘cyclic’

Keyword Arguments:

timeunit (str) – units to use for time, ‘ms’ (default) or ‘s’

Returns:

time required for test, int if timeunit==’ms’, float if timeunit==’s’

Return type:

int/float

get_test_names()

Gets the list of the names of all tests which can be performed by the device with the current firmware.

Returns:

names of all available tests.

Return type:

list

get_volt()

Returns the output voltage setting, i.e, the potential between the working and reference electrode.

Returns:

output voltage setting, units (V)

Return type:

float

get_volt_range()

Gets the current value for the output voltage range (V).

Returns:

voltage range (from device)

Return type:

dict

get_wrk_elect_connected()

Gets the connected state (True/False) of the working electrode. This feature requires hardware version >= HW0.2

Returns:

connection state of working electrode (from device), True/False

Return type:

bool

run_test(testname, param=None, filename=None, on_data=None, display='pbar', timeunit='s', max_decode_err=0)

Runs the test with specified test name and returns the time, voltage and current data.

Parameters:

testname (str) – name of test to run, e.g., ‘cyclic’, ‘constant’, linearSweep’

Keyword Arguments:
  • param (dict) – parameter settings for test, the default is None in which case the current values are used.

  • filename (str) – name of output file for saving data

  • on_data (function) – callback function called on arrival of new data from the device. This function takes four arguments: chan, t, volt, and curr.

  • display (str) – output display mode, display==’pbar’ show a progressbar, display==’data’ shows a text stream and display==’’ shows nothing

  • timeunit (str) – units for time values, if timeunit==’s’ then time values are in seconds otherwise if timeunit==’ms’ then time values are is milliseconds.

  • max_decode_err (int) – maximum number of allowed json decode errors during streaming before an exception (DataDecodeException) is rasied. If max_decode_err=0 (default) then no decode errors are allowed. If max_decode_err=None (default) then exceptions will not be triggered and decode errors will pass silently.

Returns:

data acquired during test.

When the multiplexer is disabled a tuple (t,volt,curr) of lists is returned containing the measurement times (s), voltages (V) and currents (uA) respectively

When the multiplexer is enabled run_test returns a dictionary containing the measured data for each channel. The keys of the dictionary returned are the enabled channel numbers and the values are dictionaries with the time, voltage and current measurments for that channel, keyed by ‘t’, ‘v’, and ‘i’ respectively.

Return type:

tuple/dict

send_cmd(cmd_dict, rsp=True)

Sends a command to the device. Low-level method - command is specified using command dictionary.

Parameters:

cmd_dict (dict) – commands to be sent to the device, e.g., {‘command’: ‘getVersion’}

Returns:

JSON response message from device converted to a dictionary.

For example, the response to {‘command’: ‘getVersion’} might be {‘success’: True, ‘response’: {‘command’: ‘getVersion’, ‘version’: ‘FW0.0.8’}}

Return type:

dict

set_all_elect_connected(value)

Sets the connected state (True/False) of all the electrodes (referene, counter and working). This feature requires hardware version >= HW0.2

Parameters:

value (bool) – desired connection state of all electrodes.

Returns:

connection state of all electrodes (from device), True/False

Return type:

bool

set_auto_connect(value)

Set auto-connect/auto-disconnect feature. If auto-connect is set to True then the ref, ctr and wrk electrodes will be automatically connected at the beginning of each test and automatically disconnected at the end of each test.

Parameters:

value (bool) – desired value for autoconnect, True/False

Returns:

autoconnect state (from device), True/False

Return type:

bool

set_ctr_elect_connected(value)

Sets the connected state (True/False) of the counter electrode. This feature requires hardware version >= HW0.2

Parameters:

value (bool) – desired connection state for counter electrode, True/False

Returns:

connected state of counter electrode (from device), True/False

Return type:

bool

set_curr_range(curr_range)

Sets the range setting for measuring working electrode (uA).

Parameters:

curr_range (str) – the desired workign electrode current range setting, e.g., ‘10uA’

Returns:

working electrode current range setting (from device), e.g. ‘10uA’

Return type:

str

set_device_id(device_id)

Sets the current value of the device identification number.

Parameters:

device_id (int) – desired value for device identification number

Returns:

device identification number (from device).

Return type:

int

set_enabled_mux_channels(channels)

Enables the specified subset of multiplexer working electrode channels

Parameters:

channels (list) – list of mux channels to enable, e.g., [1,2,5]

Returns:

enabled mux channels (from device).

Return type:

list

set_mux_ctr_elect_connected(value)

Sets the connected state (True or False) of the counter electrode when using the multiplexer expansion hardware.

Parameters:

value (bool) – desired connection state for mux counter electrode, True/Fasle

Returns:

connection state of mux counter electrode (from device), True/False

Return type:

bool

set_mux_enabled(value)

Enable/Disables the multiplexer expansion hardware

Parameters:

value (bool) – desired enable state of mux hardware, True/False

Returns:

enable state of mux hardware (from device), True/Fasle

Return type:

bool

set_mux_ref_elect_connected(value)

Sets the connected state (True/False) of the reference electrode when using the multiplexer expansion hardware.

Parameters:

value (bool) – desired connection for mux reference electrode, True/False

Returns:

connection state of mux reference electrode (from device), True/False

Return type:

bool

set_mux_wrk_elect_connected(value)

Sets the connected state (1, 2, 3, 4, 5, 6, 7 or False) of the working electrode when using the multiplexer expansion hardware.

Parameters:

value (int/bool) – desired connection state for mux working electrode.

Returns:

connection state of mux working electrode.

Return type:

int/bool

set_param(testname, param)

Sets the parameters for the specified voltammetric test.

Parameters:
  • testname (str) – name of voltammetric test

  • param (dict) – desired test parameters

Returns:

test parameters for testname (from device)

Return type:

dict

set_ref_elect_connected(value)

Sets the connected state (True/False) of the reference electrode. This feature requires hardware version >= HW0.2

Parameters:

value (bool) – desired connected state of reference electrode

Returns:

connected state of the reference electrode (from device), True/False

Return type:

bool

set_ref_elect_volt_range(volt_range)

Sets the voltage range for the reference electrode analog input.

Parameters:

volt_range (str) – desired voltage range, e.g., ‘5V’

Returns:

reference electrode voltage range returnd by device

Return type:

str

set_sample_period(sample_period)

Sets the sample period (ms) used for measurements. The sample period is the time between samples.

Parameters:

sample_period (int) – desired sample period, units (ms)

Returns:

sample period (from device), units (ms)

Return type:

int

set_sample_rate(sample_rate)

Sets the measurement sample rate (Hz). Note, this is an alternative way to set the sample period.

Parameters:

sample_rate (float) – desired sample rate, units (Hz)

Returns:

sample rate (from device), unit (Hz)

Return type:

float

set_volt(volt)

Sets the output voltage setting, i.e., the potential between the working and reference electrode.

Parameters:

volt (float) – output voltage setting, units (V)

Returns:

output voltage setting, units (V)

Return type:

float

set_volt_range(volt_range)

Sets the output voltage range (V)- used when setting output voltage manually.

Parameters:

volt_range (str) – desired output voltage range, e.g., ‘1V’

Returns:

voltage range (from device)

Return type:

dict

set_wrk_elect_connected(value)

Sets the connected state (True/False) of the working electrode. This feature requires hardware version >= HW0.2

Parameters:

value (bool) – desired connection state for working electrode, True/False

Returns:

connection state of working electrode (from device), True/False

Return type:

bool

stop_test(rsp=True)

Stops (any) currently running tests.