Instrument management (async)

The InstrumentManagerAsync() class and supporting functions use asyncio to provide a high-performance concurrent interface for instrument control.

These api for these functions and classes remain largely the same as the sequential versions.

The main difference is that these are async enabled. This means you have to use the await/async expressions to manage the event loop.

For example, to connect:

import pypalmsens

async with await pypalmsens.connect_async() as manager:
        method = pypalmsens.ChronoAmperometry()
        measurement = await manager.measure(method)

or using InstrumentManagerAsync() directly as a context manager:

instruments = await discover_async()

async with pypalmsens.InstrumentManagerAsync(instruments[0]) as manager:
    measurement = await manager.measure(method)

or managing the instrument connection yourself:

instruments = await discover_async()

manager = pypalmsens.InstrumentManagerAsync(instruments[0])
await manager.connect()
...
await manager.disconnect()

For more information, see xref:api/measuring.adoc

pypalmsens

Classes:

Functions:

InstrumentManagerAsync

InstrumentManagerAsync(instrument, *, callback=None)

Asynchronous instrument manager for PalmSens instruments.

Parameters:

  • instrument – Instrument to connect to, use discover() to find connected instruments.

  • callback (link:#typing.Optional[link:#pypalmsens._instruments._common.Callback]) – If specified, call this function on every new set of data points. New data points are batched, and contain all points since the last time it was called. Each point is a dictionary containing frequency, z_re, z_im for impedimetric techniques and index, x, x_unit, x_type, y, y_unit and y_type for non-impedimetric techniques.

Functions:

Attributes:

  • callback – This callback is called on every data point.

  • instrument – Instrument to connect to.

callback

callback = callback

This callback is called on every data point.

instrument

instrument = instrument

Instrument to connect to.

is_connected

is_connected()

Return True if an instrument connection exists.

connect

connect()

Connect to instrument.

set_cell

set_cell(cell_on)

Turn the cell on or off.

Parameters:

  • cell_on (bool) – If true, turn on the cell

set_potential

set_potential(potential)

Set the potential of the cell.

Parameters:

  • potential (float) – Potential in V

set_current_range

set_current_range(current_range)

Set the current range for the cell.

Parameters:

  • current_range (CURRENT_RANGE) – Set the current range, use pypalmsens.settings.CURRENT_RANGE.

read_current

read_current()

Read the current in µA.

Returns:

  • float – Current in µA.”

read_potential

read_potential()

Read the potential in V.

Returns:

  • float – Potential in V.

get_instrument_serial

get_instrument_serial()

Return instrument serial number.

Returns:

  • str – Instrument serial.

validate_method

validate_method(psmethod)

Validate method.

measure

measure(method, hardware_sync_initiated_event=None)

Start measurement using given method parameters.

Parameters:

  • method (MethodSettings) – Method parameters for measurement

  • hardware_sync_initiated_event – …

initiate_hardware_sync_follower_channel

initiate_hardware_sync_follower_channel(method)

Initiate hardware sync follower channel.

Parameters:

wait_digital_trigger

wait_digital_trigger(wait_for_high)

Wait for digital trigger.

Parameters:

  • wait_for_high – …

abort

abort()

Abort measurement.

initialize_multiplexer

initialize_multiplexer(mux_model)

Initialize the multiplexer.

Parameters:

  • mux_model (int) – The model of the multiplexer. 0 = 8 channel, 1 = 16 channel, 2 = 32 channel.

Returns:

  • int – Number of available multiplexes channels

set_mux8r2_settings

set_mux8r2_settings(connect_sense_to_working_electrode=False, combine_reference_and_counter_electrodes=False, use_channel_1_reference_and_counter_electrodes=False, set_unselected_channel_working_electrode=0)

Set the settings for the Mux8R2 multiplexer.

Parameters:

  • connect_sense_to_working_electrode (bool) – Connect the sense electrode to the working electrode. Default is False.

  • combine_reference_and_counter_electrodes (bool) – Combine the reference and counter electrodes. Default is False.

  • use_channel_1_reference_and_counter_electrodes (bool) – Use channel 1 reference and counter electrodes for all working electrodes. Default is False.

  • set_unselected_channel_working_electrode (int) – Set the unselected channel working electrode to disconnected/floating (0), ground (1), or standby potential (2). Default is 0.

set_multiplexer_channel

set_multiplexer_channel(channel)

Sets the multiplexer channel.

Parameters:

  • channel (int) – Index of the channel to set.

disconnect

disconnect()

Disconnect from the instrument.

connect_async

connect_async(instrument=None)

Connect to instrument and return InstrumentManagerAsync.

Parameters:

  • instrument (Instrument) – Connect to this instrument. If not specified, automatically discover and connect to the first instrument.

Returns:

  • manager (InstrumentManagerAsync) – Return instance of InstrumentManagerAsync connected to the given instrument. The connection will be terminated after the context ends.

discover_async

discover_async(ftdi=False, usbcdc=True, bluetooth=False, serial=True)

Discover instruments.

Parameters:

  • ftdi (bool) – If True, discover ftdi devices

  • usbcdc (bool) – If True, discover usbcdc devices (Windows only)

  • bluetooth (bool) – If True, discover bluetooth devices (Windows only)