Interfaces

config pyqmix configuration.
QmixBus Qmix bus interface.
QmixPump Qmix pump interface.
QmixValve Qmix valve interface.
QmixExternalValve An external valve, controlled by Qmix I/O-B.
QmixDigitalIO Qmix IO-B diglital I/O channel.

config

pyqmix configuration.

pyqmix.config.add_pump(index)

Add a new pump to the pyqmix configuration. Overwrites existing entries for a pump with the same index.

Parameters:index (int) – The unique index of the pump. Indexing is zero-based, i.e. index=0 refers to the first pump in the system.
pyqmix.config.delete_config()

Delete the configuration file.

pyqmix.config.get_available_qmix_configs(configs_dir=None)

Create a list of available qmix configurations

Parameters:configs_dir (string or None) – The parent directory containing the Qmix configurations. If None, assume the default directory used by Qmix Elements, i.e., C:/Users/Public/Documents/QmixElements/Projects/default_project/Configurations/.
Returns:Names of available Qmix configurations.
Return type:list of strings
pyqmix.config.read_config()

Read the currently stored pyqmix configuration from disk.

Returns:cfg – The loaded configuration.
Return type:dict
pyqmix.config.remove_pump(index)

Remove a pump and syringe configuration.

Parameters:index (int) – The unique index of the pump.
Raises:KeyError – If the specified pump index could not be found in the configuration file.
pyqmix.config.set_pump_drive_pos_counter(index, value)

Set the pump drive position counter to the specified value.

Parameters:
  • index (int) – The index of the pump. Indexes are zero-based.
  • value (float) – The value to set the drive position counter to.
pyqmix.config.set_pump_flow_unit(index, prefix, volume_unit, time_unit)

Set the flow unit for a certain pump.

The flow unit defines the unit to be used for all flow values passed to API functions or retrieved from API functions.

Parameters:
  • prefix (str) – The prefix of the SI unit: centi, deci, milli, micro.
  • volume_unit (str) – The volume unit identifier: litres.
  • time_unit (str) – The time unit (denominator) of the velocity unit: per_hour, per_minute, per_second.
pyqmix.config.set_pump_name(index, name)

Set the name of a pump, as it will be stored in the configuration file.

Parameters:
  • index (str) – The index of the pump. Indexes are zero-based.
  • index – The desired name of the pump.
pyqmix.config.set_pump_syringe_params(index, inner_diameter_mm, max_piston_stroke_mm)

Set syringe properties.

If you change the syringe in one device, you need to setup the new syringe parameters to get proper conversion of flow rate und volume units.

Parameters:
  • inner_diameter_mm (float) – Inner diameter of the syringe tube in millimetres.
  • max_piston_stroke_mm (float) – The maximum piston stroke defines the maximum position the piston can be moved to before it slips out of the syringe tube. The maximum piston stroke limits the maximum travel range of the syringe pump pusher.
pyqmix.config.set_pump_volume_unit(index, prefix, unit)

Set the pump volume unit.

Parameters:
  • index (int) – The index of the pump. Indexes are zero-based.
  • prefix (str) – The prefix of the SIunit: centi, deci, mircro, milli, unit.
  • unit (str) – The volume unit identifier: litres.
pyqmix.config.set_qmix_config(config_name, configs_dir=None)

Specify a Qmix configuration.

Parameters:
  • config_name (string) – The name of a Qmix configuration. Assumed to be stored at the default directory.
  • configs_dir (string or None) – The parent directory containing the Qmix configurations. If None, we will look for the Qmix configuration in the current directory; if not found, move on to look in the Qmix default directory.
Raises:

ValueError – If the specified configuration could not be found.

pyqmix.config.set_qmix_dll_dir(d)

Specify the location of the directory containing the Qmix SDK DLL files.

Parameters:d (string) – The Qmix SDK DLL directory. Must be an absolute path.

QmixBus

class pyqmix.bus.QmixBus(auto_open=True, auto_start=True)

Bases: object

Qmix bus interface.

This interface establishes a connection with the labbCAN bus used for communication with all attached devices. Accordingly, has to be initialized before any hardware can be accessed.

Parameters:
  • auto_open (bool) – Whether to open the labbCAN bus automatically on object instantiation.
  • auto_start (bool) – Whether to start the CAN bus communication automatically on object instantiation. Since the bus needs to be opened before communication can commence, setting auto_start=True will always open the bus, regardless of the auto_open parameter specified.
close()

Close labbCAN bus.

open()

Initialize labbCAN bus.

Initializes resources for a labbCAN bus instance, opens the bus and scans for connected devices.

start()

Start bus network communication.

Sets all connected devices operational and enables them. Connected devices can be accessed only after this method has been invoked.

stop()

Stop bus network communication.

Stops network communication and closes the labbCAN device. The method should be called before calling qmix.QmixBus.close`().

QmixPump

class pyqmix.pump.QmixPump(index, name='', external_valves=None, restore_drive_pos_counter=False, auto_enable=True)

Bases: object

Qmix pump interface.

Parameters:
  • index (int) – Index of the pump to access. It is related with the config files. First pump has index=0, second has index=1 and so on. Takes precedence over the name parameter.
  • name (str) – The name of the pump.
  • restore_drive_pos_counter (bool) – Whether to restore the pump drive position counter from the pyqmix config file.
  • auto_enable (bool) – Whether to enable (i.e., activate) the pump on object instantiation.
add_external_valve(valve, name)
aspirate(volume, flow_rate, wait_until_done=False, switch_valve_when_done=False)

Aspirate a certain volume with the specified flow rate.

Parameters:
  • volume (float > 0) – The volume to aspirate in physical units.
  • flow_rate (float > 0) – The flow rate to use to aspirate the volume, negative flow rates are invalid.
  • wait_until_done (bool) – Whether to block until done.
  • switch_valve_when_done (bool) – If set to True, it switches valve to dispense position after the aspiration is finished. Implies wait_until_done=True.
Raises:

ValueError – If the specified volume or flow rate are non-positive, or if the fill level at the end of the aspiration procedure would exceed the syringe volume.

Notes

This method switches the valve to aspiration position before the actual aspiration begins.

calibrate(wait_until_done=False)

Executes a reference move for a syringe pump.

Warning

Executing the calibration move with a syringe fitted on the device may cause damage to the syringe.

Parameters:wait_until_done (bool) – Whether to block further program execution until done.
clear_fault_state()

Clear fault condition.

Clears the last fault and resets the device to an error-free state. If qmix.QmixPump.is_in_fault_state indicates that device is in fault state, then this method may resolve this problem. If the device is still in fault state after this method was called, we have to assume that a serious failure occurred.

current_flow_rate

Read the current flow rate.

This does not assess the actual current flow rate. Instead, this method simply returns the cached (desired) flow rate value.

Returns:The current flow rate demand value
Return type:float
disable()

Deactivate the pump drive.

dispense(volume, flow_rate, wait_until_done=False, switch_valve_when_done=False)

Dispense a certain volume with a certain flow rate.

It also switches the valve in position 0 (green led off).

Parameters:
  • volume (float > 0) – The volume to dispense in physical units.
  • flow_rate (float > 0) – The flow rate to use to dispense the volume, negative flow rates are invalid.
  • wait_until_done (bool) – Whether to halt program execution until done.
  • switch_valve_when_done (bool) – If set to True, it switches valve to aspirate position after the dispense is finished. Implies wait_until_done=True.
Raises:

ValueError – If the specified volume or flow rate are non-positive, or if the syringe is currently not sufficiently filled to dispense the desired volume.

Notes

This method switches the valve to dispense position before the actual aspiration begins.

dosed_volume

Get the already dosed volume.

Returns:The already dosed volume
Return type:float
drive_pos_counter

Current drive position counter of the pump.

The position counter gets reset to zero when the pump system is powered off. To avoid having to recalibrate the system (i.e., doing a reference move, which requires removal of the syringes), this function may be used to save the current drive position counter to the configuration file, from where it can be safely restored once the system is powered on again.

Returns:The current value of the drive position counter.
Return type:int
empty(flow_rate, wait_until_done=False, switch_valve_when_done=False)

Empty the syringe.

Parameters:
  • flow_rate (float > 0) – The flow rate to use.
  • wait_until_done (bool) – Whether to halt program execution until done.
  • switch_valve_when_done (bool) – If set to True, it switches valve to dispense position after the aspiration is finished. Implies wait_until_done=True.
Raises:

ValueError – If the specified flow rate is non-positive.

Notes

This is a convenience method that simply passes the specified parameters to :func:~`pyqmix.QmixPump.generate_flow`.

enable()

Enable the pump.

fill(flow_rate, wait_until_done=False, switch_valve_when_done=False)

Fill the syringe.

Parameters:
  • flow_rate (float > 0) – The flow rate to use.
  • wait_until_done (bool) – Whether to halt program execution until done.
  • switch_valve_when_done (bool) – If set to True, it switches valve to dispense position after the aspiration is finished. Implies wait_until_done=True.
Raises:

ValueError – If the specified flow rate is non-positive.

Notes

This is a convenience method that simply passes the specified parameters to :func:~`pyqmix.QmixPump.generate_flow`. Note that flow_rate is multiplied by -1 to ensure the syringe is being filled.

fill_level

Returns the current fill level of the pump.

Notes

This is identical to a call to :func:~`pyqmix.QmixPump.get_fill_level`.

flow_unit

The currently set flow unit.

Returns:A dictionary with the keys prefix, volume_unit, and time_unit.
Return type:OrderedDict
generate_flow(flow_rate, wait_until_done=False, switch_valve_when_done=False)

Generate a continuous flow.

If it aspirates it switches the valve in position 1. 0 if it dispenses.

Parameters:
  • flow_rate (float != 0) – A positive flow rate indicates dispensing and a negative flow rate indicates aspiration.
  • wait_until_done (bool) – Whether to halt program execution until done.
  • switch_valve_when_done (bool) – If set to True, it switches valve to dispense position after the aspiration is finished. Implies wait_until_done=True.
Raises:

ValueError – If a flow rate of zero is specified.

get_fill_level()

Returns the current fill level of the pump.

Returns:The current fill level of the syringe
Return type:float
get_flow_unit()

Return the currently set flow unit.

Returns:A dictionary with the keys prefix, volume_unit, and time_unit.
Return type:OrderedDict
get_syringe_params()

Get the currently set syringe properties.

Returns:Returns a dictionary with the keys inner_diameter_mm and max_piston_stroke_mm.
Return type:OrderedDict
get_volume_unit()

Return the currently set default volume unit.

Returns:A dictionary with the keys prefix and unit.
Return type:OrderedDict
has_valve

Check if the pump has a valve assigned.

Returns:True if a valve is present, False otherwise.
Return type:bool
is_calibration_finished

Check if calibration is finished still ongoing.

Returns:True - Device calibration has finished/was perfomed False - Device is calibrating
Return type:bool
is_enabled

Query if pump drive is enabled.

Only if the pump drive is enabled it is possible to pump fluid.

Returns:1 - Pump drive is enabled, pumping is possible 0 - Pump drive is disabled - pump head is free running
Return type:int
is_in_fault_state

Check if pump is in a fault state.

If the device is in fault state then it is necessary to call qmix.QmixPump.clear_fault_state`(), followed by a call to QmixPump.enable() to enable the pump.

Returns:1 - Pump is in fault state 0 - Pump is not in fault state
Return type:int
is_pumping

Check if device is currently stopped or dosing.

Returns:True if pumping, False otherwise.
Return type:bool
max_flow_rate

Maximum flow rate for the current dosing unit configuration.

The maximum flow rate depends on the mechanical configuration of the dosing unit (gear) and on the syringe configuration. If larger syringes are used then larger flow rates are realizable.

Returns:The maximum flow rate in configured SI unit
Return type:float
n_pumps

The number of dosing units.

Returns:Number of detected pump devices
Return type:int
name
remove_external_valve(name)
save_drive_pos_counter()

Save the current drive position counter to the configuration file.

set_fill_level(level, flow_rate, wait_until_done=False, switch_valve_when_done=False)

Pumps fluid with the given flow rate until the requested fill level is reached.

Depending on the requested fill level given in level parameter this function may cause aspiration or dispension of fluid. If it aspirates it switches the valve in position 1. 0 if it dispenses.

Parameters:
  • level (float => 0) – The requested fill level. A level of 0 indicates a completely empty syringe.
  • flow_rate (float > 0) – The flow rate to use for pumping.
  • wait_until_done (bool) – Whether to halt program execution until done.
  • switch_valve_when_done (bool) – If set to True, it switches valve to dispense position after the aspiration is finished. Implies wait_until_done=True.
Raises:

ValueError – If specified target fill level is negative, or if flow rate is non-positive.

set_flow_unit(prefix='milli', volume_unit='litres', time_unit='per_second')

Set the flow unit for a certain pump.

The flow unit defines the unit to be used for all flow values passed to API functions or retrieved from API functions.

Parameters:
  • prefix (str) – The prefix of the SI unit: centi, deci, milli, micro.
  • volume_unit (str) – The volume unit identifier: litres.
  • time_unit (str) – The time unit (denominator) of the velocity unit: per_hour, per_minute, per_second.
set_syringe_params(inner_diameter_mm=32.5735, max_piston_stroke_mm=60)

Set syringe properties.

If you change the syringe in one device, you need to setup the new syringe parameters to get proper conversion of flow rate und volume units.

Parameters:
  • inner_diameter_mm (float) – Inner diameter of the syringe tube in millimetres.
  • max_piston_stroke_mm (float) – The maximum piston stroke defines the maximum position the piston can be moved to before it slips out of the syringe tube. The maximum piston stroke limits the maximum travel range of the syringe pump pusher.
set_syringe_params_by_type(syringe_type='50 mL glass')

Convenience method to set syringe parameters based on syringe type.

Parameters:syringe_type (string) – Any of 25 mL glass and 50 mL glass.

Notes

This method simply looks up pre-defined syringe parameters (inner diameter and max. piston stroke), and passes these parameters to :func:~`pyqmix.QmixPump.set_syringe_params`.

set_volume_unit(prefix='milli', unit='litres')

Set the default volume unit.

All parameters of subsequent dosing method calls are given in this new unit.

Parameters:
  • prefix (str) – The prefix of the SIunit: centi, deci, mircro, milli, unit.
  • unit (str) – The volume unit identifier: litres.
stop()

Immediately stop pumping.

stop_all_pumps()

Immediately stop all pumps.

syringe_params

The currently set syringe properties.

Returns:Returns a dictionary with the keys inner_diameter_mm and max_piston_stroke_mm.
Return type:OrderedDict
valve_handle

Returns the valve handle of the pump valve.

Returns:Handle to valve device, or 0 if no valve is associated
Return type:int
volume_max
volume_unit

The currently set default volume unit.

Returns:A dictionary with the keys prefix and unit.
Return type:OrderedDict

QmixValve

class pyqmix.valve.QmixValve(index=None, name='', handle=None)

Bases: object

Qmix valve interface.

Parameters:
  • index (int, or None) – Index of the valve to initialize. Takes precedence over the name and handle parameters.
  • name (str) – The name of the valve to initialize. Will be ignored if index is not None. Takes precedence over the handle parameter.
  • handle (Qmix valve handle, or None) – A Qmix valve device handle, as returned by :func:~`pyqmix.QmixPump.valve_handle`.
number_of_positions

Return the number of valve positions.

Each valve has a number of available valve positions. A switching valve has two positions.

Returns:>0 Number of valve positions
Return type:int
position

The current logical valve position.

Each valve position is identified by a logical valve position identifier from 0 to number of valve positions - 1. This function returns the logical valve position identifier for the current valve position.

Returns:>=0 current valve position index.
Return type:int
switch_position(position=None)

Switch the valve to a certain logical valve position.

Parameters:position (int, or None) – Switch the valve to the specified position. If None and a valve with two possible positions is connected, switch from the current position to the other one.

QmixExternalValve

class pyqmix.valve.QmixExternalValve(index=None, name='')

Bases: pyqmix.valve.QmixValve

An external valve, controlled by Qmix I/O-B.

Parameters:
  • index (int, or None) – Index of the DIO channel to istantiate. Takes precedence over the name parameter.
  • name (str) – The name of the DIO channel to initialize. Will be ignored if index is not None.
number_of_positions

Return the number of valve positions.

Each valve has a number of available valve positions. A switching valve has two positions.

Returns:>0 Number of valve positions
Return type:int
position

The current logical valve position.

Each valve position is identified by a logical valve position identifier from 0 to number of valve positions - 1. This function returns the logical valve position identifier for the current valve position.

Returns:>=0 current valve position index.
Return type:int
switch_position(position=None)

Switch the valve to a certain logical valve position.

Parameters:position (int, or None) – Switch the valve to the specified position. If None and a valve with two possible positions is connected, switch from the current position to the other one.

QmixDigitalIO

class pyqmix.dio.QmixDigitalIO(index=None, name='')

Bases: object

Qmix IO-B diglital I/O channel.

Parameters:
  • index (int) – Index of the DIO channel. It is related with the config files. First channel has index=0, second has index=1 and so on. Takes precedence over the name parameter.
  • name (str) – The name of the DIO channel to initialize. Will be ignored if index is not None.
is_output_on

Current state of a digital output channel.

Returns:1 Channel is ON 0 Channel is OFF
Return type:int
write(state)

Swicth digital output channel on/off.

Parameters:state (int) – State to set 0 = switch off, 1 = switch on.