A syringe pump controller system for Raspberry Pi and Arduino.
The syringe pump controller uses the Adafruit motor HAT v2.3 for Raspberry Pi and the Adafruit motor shield for Arduino.
A case for the Raspberry Pi with the Adafruit motor HAT can be found at RPi2.
The syringe pump control software is written in Python and requires
Python 2.7 to be installed. The software also requires that the
pyserial
library is installed (see below for installation details).
The syringe pump controller can operate in three separate modes: motor emulation, Adafruit Motor HAT (via Raspberry Pi or some Linux) operated, or Arduino (with Adafruit motor shield) operated. The type of the motor operation is automatically selected when the server is started. If an Arduino is detected via serial connection, then it is used. If the Arduino is not found, then the Adafruit Motor HAT libraries are searched for, and if they are found, they are utilized. If neither of those libraries are found, then the server falls back to motor emulation which is useful for testing the client. The rest of the setup will be broken up for each of these types.
Nothing further to setup. Everything should work as long as the Python 2.7 is installed.
To use the Adafruit motor HAT with the syringe pump controller, the Adafruit Python library must be installed. Once it is installed, the syringe pump controller will select it by default during startup.
To use the syringe controller with an Arduino with an Adafruit motor shield, the pyserial library must be installed so that the controller can communicate with the Arduino. The pyserial library can be installed a number of ways depending on what system is being run.
On Debian based systems the pyserial library can be installed by performing an apt update and then installing
sudo apt-get install python-serial
sudo apt-get install npm
This section contains description of standard syringe pump usage.
cd into client/src directory
The client code is found in the client/src
directory. The client
uses nodejs for building and managing
dependencies. Typing
npm install
will install the required JavaScript libraries to the node_modules
directory.
npm run build
Will take the code from the client/src/
and compile it to the
client/dist/
directory where it will be served by the
syringepump_server.py
. DO NOT directly edit the /client/dist/
since the contents will be overwritten when the project is rebuilt;
instead, only edit the contents of client/src/
.
To start the syringe pump controller, cd
to the server
directory
and type:
python syringepump_server.py
This will generate the following output.
Using motor emulation.
Bottle v0.13-dev server starting up (using WSGIRefServer())...
Listening on http://0.0.0.0:8080/
Hit Ctrl-C to quit.
This starts the syringe pump controller server on port 8080. Directing a web browser to
http://localhost:8080/index.html
opens the syringe pump controller page.
The first action that should occur when the syringe pump is initially run, is to perform pump calibration. Clicking on the Calibrate button starts the calibration wizard. This makes the syringe pump perform a series of three loads and unloads. Each loading and unloading is a larger amount of motor steps, which results in a larger amount of fluid being loaded and discharged. The loaded amounts are as follows.
- 1000 motor steps
- 2000 motor steps
- 4000 motor steps
Each time the motor loads the fluid and then discharges it, the amount of fluid is measured and recorded.
Finally, a linear regression is performed on the motor steps vs the amount of fluid, and this formula is used to calibrate the syringe pump. This allows the syringe pump controller to get very accurate results without strictly relying on measurements of the syringe size and the screw pitch.
Assuming the syringe pump has been calibrated, then the standard operation is quite simple. The amount to be loaded is specified (the default value is 1ml). Next, the Load Syringe! button is pressed. The syringe loads the fluid in approximately 20 seconds.
Next, the amount of time to take for the fluid to be discharged is specified (the default is 30min). The Unload Syringe! button is pressed, and the fluid begins to empty at the specified rate.
There are a number of buttons listed below the basic operations for moving the syringe plunger. The options are 100, 1000, and 2000 in either direction. There is also the option to reset the motors initial position back to zero (the motor control software calculates load amounts relative to this position).
There is also a button to shutdown the system. This button only works
if the system password has been specified at the top of the
syringepump_server.py
file. The line looks like the following.
SYSTEM_PASS = '' # set this if you want to be able to shutdown the server
You can decide for yourself if this is a security risk for your system and setup.
This section contains settings that most users are unlikely to edit (at least directly).
The default load time of 20 seconds is a reasonable speed to load 1 ml of fluid at 200 motor steps per revolution. Setting its value too low may result in the motor skipping steps. The system is intended to move the syringe pump slowly, so if a decrease in this value is needed, then changes to syringe and motor gearing may be required.
The calibration settings affect the amount of fluid that is loaded and discharged by the syringe pump. By default, the number of steps per 1 ml of fluid is 1415. Additional default settings are shown in the table below.
Setting | Default Value |
---|---|
Syringe Diameter | 15 |
Pitch (# mm / 1 rev) | 0.8 |
# Steps / 1 rev | 200 |
The syringe diameter is the inner space of the syringe. The pitch is the distance that a single rotation of the screw causes the plunger to move in millimeters. The # steps / 1 rev is how many motor steps it takes to make the screw complete a single revolution.
The project is licensed under the terms of the GPL3 license.