Instrument management
Use the InstrumentManager()
to start experiments and control your
PalmSens instrument.
For example, to connect:
import pypalmsens as ps
with ps.connect as manager:
method = ps.ChronoAmperometry()
measurement = await manager.measure(method)
or using InstrumentManager()
directly as a context manager:
instruments = discover()
with ps.InstrumentManager(instruments[0]) as manager:
measurement = manager.measure(method)
or managing the instrument connection yourself:
instruments = discover_async()
manager = ps.InstrumentManager(instruments[0])
manager.connect()
...
await manager.disconnect()
For more information, see xref:measuring.adoc
pypalmsens
Classes:
-
InstrumentManager – Instrument manager for PalmSens instruments.
-
InstrumentPool – Manages a set of instrument.
Functions:
InstrumentManager
InstrumentManager(instrument, *, callback=None)
Instrument manager for PalmSens instruments.
Parameters:
-
instrument (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 andindex
,x
,x_unit
,x_type
,y
,y_unit
andy_type
for non-impedimetric techniques.
Functions:
-
is_connected – Return True if an instrument connection exists.
-
connect – Connect to instrument.
-
set_cell – Turn the cell on or off.
-
set_potential – Set the potential of the cell.
-
set_current_range – Set the current range for the cell.
-
read_current – Read the current in µA.
-
read_potential – Read the potential in V.
-
get_instrument_serial – Return instrument serial number.
-
validate_method – Validate method.
-
measure – Start measurement using given method parameters.
-
wait_digital_trigger – Wait for digital trigger.
-
abort – Abort measurement.
-
initialize_multiplexer – Initialize the multiplexer.
-
set_mux8r2_settings – Set the settings for the Mux8R2 multiplexer.
-
set_multiplexer_channel – Sets the multiplexer channel.
-
disconnect – Disconnect from the instrument.
Attributes:
-
callback – This callback is called on every data point.
-
instrument – Instrument to connect to.
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
.
get_instrument_serial
get_instrument_serial()
Return instrument serial number.
Returns:
-
str – Instrument serial.
measure
measure(method)
Start measurement using given method parameters.
Parameters:
-
method (MethodSettings) – Method parameters for measurement
wait_digital_trigger
wait_digital_trigger(wait_for_high)
Wait for digital trigger.
Parameters:
-
wait_for_high – …
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.
InstrumentPool
InstrumentPool(devices_or_managers, *, callback=None)
Manages a set of instrument.
Most calls are run asynchronously in the background, which means that measurements are running in parallel.
This is a thin wrapper around the InstrumentManagerAsync
.
Parameters:
-
devices_or_managers ([link:#pypalmsens._instruments._common.Instrument">Instrument | link:#pypalmsens._instruments.instrument_manager_async.InstrumentManagerAsync]) – List of devices or managers.
-
callback (Callable) – Optional callable to set on instrument managers
Functions:
-
connect – Connect all instrument managers in the pool.
-
disconnect – Disconnect all instrument managers in the pool.
-
is_connected – Return true if all managers in the pool are connected.
-
is_disconnected – Return true if all managers in the pool are disconnected.
-
remove – Close and remove manager from pool.
-
add – Open and add manager to the pool.
-
measure – Concurrently run measurement on all managers in the pool.
Attributes:
-
managers – List of instruments managers in the pool.
remove
remove(manager)
Close and remove manager from pool.
Parameters:
-
manager (InstrumentManagerAsync) – Instance of an instrument manager.
add
add(manager)
Open and add manager to the pool.
Parameters:
-
manager (InstrumentManagerAsync) – Instance of an instrument manager.
measure
measure(method)
Concurrently run measurement on all managers in the pool.
For hardware synchronization, set use_hardware_sync
on the
method. In addition, the pool must contain:
-
channels from a single multi-channel instrument only
-
the first channel of the multi-channel instrument
-
at least two channels
All instruments are prepared and put in a waiting state. The measurements are started via a hardware sync trigger on channel 1.
Parameters:
-
method (MethodSettings) – Method parameters for measurement.
connect
connect(instrument=None)
Connect to instrument and return InstrumentManager.
Parameters:
-
instrument (Instrument) – Connect to this instrument. If not specified, automatically discover and connect to the first instrument.
Returns:
-
manager (InstrumentManager) – Return instance of
InstrumentManager
connected to the given instrument. The connection will be terminated after the context ends.