Driver

This library is designed to handle multiple Cavro Centris syringe pumps connected to one computer. However, there is really no way to identify pumps by their serial number or serial number of RS-232 to USB connectors (Note, some connectors to have serial numbers but it is rear.) The work around is to use the build-in non-volatile memory. (TODO: find a link to a manual and find a page where it is explained to how to write and read from non-volatile memory)

Start by importing Cavro Centris Syringe Pump.

from syringe_pump.driver import Driver
driver = Driver()
driver.discover()
driver
driver.init(pump_id=1, speed=25, backlash=100, orientation='Y', volume=250)
class syringe_pump.driver.Driver[source]
abort()[source]

Terminates plunger moves [A,P,D] , initialization commands [Z], and delay [M]; does not affect valve moves.

Examples

>>> driver.abort()
assign_pids(pid=None)[source]

Assigns pump id to each syringe pump according to dictionary; since pump ids are written to non-volatile memory, need only execute once.

assign_volume(volume=250)[source]

Specifies the syringe volumes for each pump in the dictionary of pumps. The command takes effect after power cycling the pumps, and need only be executed once. accepts 4 different volumes: 50, 100, 250, 500 uL # volumes of -> result in codes 50, 100, 250, 500 uL -> U93, U94, U90, U95

Parameters
volume: integer

input speed as float

Returns
reply: string

unparse complete response string

Examples

>>> driver.assign_volume(volume = 250)
property available_ports

return the list of serial devices

Returns
list: list

Examples

>>> driver.available_ports()
['/dev/cu.usbserial',
 '/dev/cu.usbserial1',
 '/dev/cu.usbserial2',
 '/dev/cu.usbserial3']
busy()[source]

queries if pump os busy or not. Command “/1?29Rr”

Examples

>>> driver.busy()
close()[source]

closes serial port

Examples

>>> ser_port.close()
convert_error_code(char=b'')[source]

the ` is ` character or chr(96)

discover(pump_id=None)[source]

Finds the serial ports for the specified pump controller id number. uses self.available_ports class property to get all potential serial ports. Then submits the identification command. If the query return corrrect string and the id matches self.pump_id, the tested port will be assigned to self.port of the syringe pump driver class.

Returns
port :: Serial

Examples

>>> driver.port = driver.discover()
get_speed()[source]

get speed as an atomic command.

Returns
reply: float

current speed as float num,ber

Examples

>>> driver.get_speed()
25
home()[source]

homes the syringe pump The homing parameters are hardcoded: +——–+——-+—————+—————-+————+ | pump | speed | orientation | Backlash | start pos | +========+=======+===============+================+============+ | pump1: | 25 | Y | self.backlash | 0 | +——–+——-+—————+—————-+————+ | pump2: | 25 | Z | self.backlash | 0 | +——–+——-+—————+—————-+————+ | pump3: | 25 | Y | self.backlash | 0 | +——–+——-+—————+—————-+————+ | pump4: | 25 | Z | self.backlash | 0 | +——–+——-+—————+—————-+————+

Examples

>>> driver.home()
init(pump_id, speed=25, backlash=100, orientation=None, volume=None)[source]

orderly initialization of the syringe pump: discovery of the pump, setting up and homing.

  • assigns pump_id class atribute to input pump_id

  • sets volume to input volumes

  • sets backlash

  • sets speed

  • sets orientation and homes the syringe pump.

Parameters
pump_id: integer

pump_id

speed: float

initial speed of the syringe pump, default is 25

backlash: float

the backlash of the syringe pump. The default value is 100

orientation: string

the orientation of the syringe pump valve: Y or Z

volume: float

the volume of the installed syringe

Examples

>>> driver.init(pump_id = 1, speed = 25, backlash = 100,orientation = 'Y', volume = 250)
initialize(orientation='')[source]

initialization command: Y for left pumps and Z for right pumps Z: input on left, output on right Rotate valve CW to port 1; move the plunger to zero at speed 7 (default: 2.33 s per 30-mm stroke); rotate valve CW to port 2. Y: input on right, output on left Rotate valve CCW to Input port 1; move the plunger to zero at speed 7 (default: 2.33 s per 30-mm stroke); rotate valve CCW to Output port 2.

The initialize command cannot be sent if motor is busy.

Note: the initialization is done in safe way where the vavle is set to ‘input’ before homing operation.

Parameters
orientation: string

input orientation as string with two possible settings Y and Z

Returns
reply: string

unparse complete response string

Examples

>>> driver.initialize(orientation = 'Y')
{'value': '', 'error_code': '@', 'busy': True, 'error': 'No Error'}
move_abs(position, speed)[source]

Move plunger of pump[pid] to absolute position. Plunger moves can be executed in increments or volume by appending to the destination ‘,0’ or ‘,1’. There are 181,490 increments in a 30-mm stroke. The volume in uL is internally calculated from the syringe volume (specified by a U command). Two arguments need to be passed: position and speed.

move_rel(position, speed)[source]

Move plunger of pump[pid] to relative position.

query(command, port=None)[source]

write-read command with build in threading lock to insure no commands can be send within 100 ms, which is the syringe pump hardware limitation. first performs write into port and later read out serial buffer of the port object.

Parameters
command: string

string command to be written into serial port input buffer

port: object

serial port object

Returns
reply: string

returns string from serial output buffer

Examples

>>> driver.query(command = '/1?29R\r')
"ÿ/0`0\x03\r\n"
read(port=None)[source]

serial read command. the port attribute is optional. if port left None, the self.port object will be used. this fucnction is both Python 2 and 3 compatible.

Parameters
port: object

serial port object

Returns
reply: string

returns string from serial buffer

Examples

>>> driver.read()
"ÿ/0`0\x03\r\n"
reset()[source]

Performs a soft reset on pumps

set_backlash(value)[source]
set_speed(speed, on_the_fly=True)[source]

set speed as an atomic command. can be executed if plunger is moving. If plunger is moving accepts speeds below 68.8. Example: ‘/1V25.0,1Fr’ set speed to 25.0 uL per s

Parameters
speed: float

input speed as float

Returns
reply: string

unparse complete response string

Examples

>>> driver.set_speed(speed = 25)
set_valve(value)[source]
Parameters
valvechar

one character command for the valve position ‘b’,’o’,’i’

Returns
replydictionary

a dictionary containing 4 key-value pairs

Examples

>>> self.set_valve(b'i')
{'value': b'', 'error_code': 64, 'busy': False, 'error': None}
property speed

get speed as an atomic command.

Returns
reply: float

current speed as float num,ber

Examples

>>> driver.get_speed()
25
property waiting

returns number of byyes in both in and out buffers as tuple

Returns
tuple

Examples

>>> ser_port.waiting()
(0,0)
write(command, port=None)[source]

serial write command. the port attribute is optional. if port left None, the self.port object will be used. this fucnction is both Python 2 and 3 compatible.

Parameters
command: strin

string command to be written into serial input buffer

port: object

serial port object

Examples

>>> driver.write()