benmiles.xyz Biotech 🦠, startups 🚀, tech 👨‍💻

Flow chemistry automation with Pumpy

Flow chemistry is pretty hot right now, check out anything by Steve Ley he does some cool stuff. Flow chemistry and microfluidics are really popular, they enable precision control over the spatial distribution of materials during continuous processes. This is useful when one wants to continuously combine materials such as in a chemical process ultimately yielding a higher throughput when compared to batch processing. Flow chemistry and microfluidics also enable the emulation of biological systems, replicating similar kinetics and shear flows at surfaces which are not necessarily possible in bulk processes.

During my PhD I used two PHD 2000 Harvard apparatus syringe pumps to run an experiment where I would alternately flow two solutions through a membrane for 40 hours. Getting into programming at the time I wanted to automate this. Here’s a quick video of the set up.

Automation with Pumpy and a Raspberry Pi

A colleague of mine, Tom Phillips, at Imperial College had made a really nice python package called Pumpy. Pumpy enabled me to express protocols as python scripts. Which means that they can be version controlled with Git and shared and improved with GitHub. This is really what I want the future of protocols to be like, because it enables so much in for collaboration on method development and ultimately repeatability in the lab.

The set up required:

  • 1 Raspberry Pi B+
  • 1 USB to RS232 converter
  • 2 RS232 cables
    • all of the tubing and connectors etc for the fluidics
  • I also used a Sensirion solid-state flow meter (these things are awesome!). Though sadly I didn’t have time to get this working with the Raspberry Pi.

Because I’m a super nerd and have the excitement of a puppy when my devices talk to me via the internet (#IoT) I added a pushover method to send me a push notification at the start of each cycle of the alternating process.

![pump notifications](/assets/pushover.png) Internet of pumps #IoP

This is what a Pumpy protocol would look like to do an alternated flow from two pumps:

import sys
import pumpy
import logging
import time
import os
import httplib, urllib

pushover_user_key = os.environ['PUSHOVER_USER_KEY']
pushover_app_key = os.environ['PUSHOVER_PUMPY_APP_TOKEN']

## Here I used pushover to notify on the run progress.
def push(message):
  conn = httplib.HTTPSConnection("api.pushover.net:443")
  conn.request("POST", "/1/messages.json",
    urllib.urlencode({
      "token": pushover_app_key,
      "user": pushover_user_key,
      "message": message,
    }), { "Content-type": "application/x-www-form-urlencoded" })
  conn.getresponse()

logging.basicConfig(level=logging.INFO)

## Communication config
chain = pumpy.Chain('../../../../../dev/ttyUSB0')
PHDcoll = pumpy.PHD2000(chain,address=1, name="PHDcoll") # PHD2000
PHDha = pumpy.PHD2000(chain,address=12, name="PHDha") # special pump

## Experimental parameters
tVol = 2000 # 2mL
tTime = 60 # 60 minutes
flowRate = tVol/tTime
cycles = 21 #21 does 20 cycles

# Set diameters BD plastpak 50/60mL
PHDcoll.setdiameter(26.7)
PHDha.setdiameter(26.7)
# Set Flow Rates
PHDcoll.setflowrate(flowRate)
PHDha.setflowrate(flowRate)
# Set each target volume for each infuse.
PHDcoll.settargetvolume(tVol)
PHDha.settargetvolume(tVol)

## Begin the alternating process
for i in range(0,cycles):
  push("Starting Coll cycle: " + str(i))
  PHDcoll.infuse()
  logging.info('coll: infusing, cycle ' + str(i))
  PHDcoll.waituntiltarget()
  PHDcoll.stop()
  logging.info('coll: stopped infusing, cycle ' + str(i))
  push("Starting HAnp cycle: " + str(i))
  PHDha.infuse()
  logging.info('HAnp: infusing, cycle ' + str(i))
  PHDha.waituntiltarget()
  PHDha.stop()
  logging.info('HAnp: stopped infusing, cycle ' + str(i))

push("Job Complete :)")
sys.exit()

Tom did a really nice job with Pumpy, it’s so straight forward to use. I recommend that anyone who does any microfluidics or flow chemistry consider giving this a go. What’s even cooler is you can ssh onto the Raspberry Pi from anywhere and execute experiments!