Poseidon Syringe Pump

From MC Chem Wiki
Jump to navigation Jump to search

Overview

This page is dedicated to the set-up of the Poseidon Syringe Pump (as originally constructed by the Pachter Lab at CalTech) for Advanced Physical Chemistry (Spring 2019). The project page is found here: Poseidon.

Obtaining Materials and Printing Parts

You can find the list of materials and vendors here.

Next, you must print the parts for the syringe pump apparatus.

The .stl files for the 3D printed parts can be found here.

You may consider cloning the main project repository, since it includes all of the software we will need to run it. I would recommend cloning it to the desktop of the Raspberry Pi that you will be using for the project.

Assembly of 3D-Printed Parts

The Pachter lab has created helpful videos on the construction of the pump apparatus once you have all the necessary materials and 3D printed parts.

Syringe Pump Assembly

Microscope Assembly (Optional)

Raspberry Pi Set-Up

If you are using a brand-new Raspberry Pi, you should see this page on set-up basics.

Once you have installed your Raspbian OS using NOOBS, you should connect to a Wi-Fi network. Then, open a terminal and run the following:

To update the Pi:

    sudo apt-get update

To upgrade the Pi:

    sudo apt-get upgrade

(If either of the above commands fails, then you have not connected to a Wi-Fi network yet... Do this and try again.)

To install a necessary GUI dependency:

    sudo apt-get install python3-pyqt5

To install a necessary library that will allow us to establish a serial connection between the Raspberry Pi and the Arduino:

    sudo pip3 install pyserial

We need to install a library called OpenCV, but first must get its dependencies by using the following commands:

    sudo apt-get install libatlas-base-dev
    sudo apt-get install libjasper-dev
    sudo apt-get install libqtgui4
    sudo apt-get install libqt4-qt3support
    sudo apt-get install libqt4-test

There is apparently some difficulty with loading OpenCV through the terminal... So we will put some extra steps into the process. We first must install an updated version of the Python Package Manager (pip) via the following:

    wget https://bootstrap.pypa.io/get-pip.py
    sudo python3 get-pip.py

Now officially getting OpenCV-Python is another series of steps:

    wget -O opencv.zip https://github.com/Itseez/opencv/archive/3.4.1.zip
    wget -O opencv_contrib.zip https://github.com/Itseez/opencv_contrib/archive/3.4.1.zip
    unzip opencv.zip
    unzip opencv_contrib.zip
    sudo apt-get install cmake
     cmake -D CMAKE_BUILD_TYPE=RELEASE \
     -D CMAKE_INSTALL_PREFIX=/usr/local \
     -D INSTALL_PYTHON_EXAMPLES=ON \
     -D OPENCV_EXTRA_MODULES_PATH=~/opencv_contrib-3.4.1/modules \
     -D ENABLE_PRECOMPILED_HEADERS=OFF \
     -D BUILD_EXAMPLES=ON ..

Now, open a new tab in the terminal (SHIFT+CTRL+T) and do the following:

    cd
    cd ..
    cd etc
    sudo nano dphys-swapfile

You will have to save the file using CTRL+O (this will write out the change to the file) and then hit enter. Now hit CTRL+X to exit the Nano Editor.

    sudo /etc/init.d/dphys-swapfile stop
    sudo /etc/init.d/dphys-swapfile start

This is done to facilitate compiling the OpenCV code using all four cores of the Raspberry Pi... Now, back to the other tab. Enter the following:

    make -j4

This should take care of the compilation. Since we have allowed all four cores of the Pi, this should only take about 2 hours... (Yes, I know that is a long time to wait - grab yourself a cup of coffee.)

WARNING: You had better put your heatsinks on the processors of the Pi before running this because it is going to use every bit of processing power that the Pi has... It's going to run at 100% for the entire time and give you a temperature warning.

Next, you simply need to run the installation:

    sudo make install
    sudo ldconfig

Now you should test the installation to ensure it was successful. This can be done by firing up a Python3 interactive console and using two lines of code...

To launch a python3 interactive console:

    python3
    import cv2
    cv2.__version__


Since we are already working on the Pi, we should prepare by downloading the Arduino IDE. This can be done by first going to the Arduino Website and then selecting Linux ARM. This should initiate a download.

Once your file is downloaded, you must extract the file. You can do this by going to your downloads, right-clicking on the file (it should look something like "arduino-1.8.8"), and selecting Archiver. This will take a moment to load.

Once the red and green light in the lower right-hand corner has stopped flashing, you should click on Action and Extract. Then extract the contents to your Downloads folder.

Once you have successfully done this, open up a Terminal window! Type in the following:

    cd Downloads
  
    ls 

This should show all of the files/directories in your current working directory. You should see something like arduino-1.8.8 listed here. Next, type in:

    sudo ./install.sh

Congratulations, you have now installed the Arduino IDE onto your Raspberry Pi!!!

You should next download the AccelStepper library for the Arduino here.

Once downloaded, you will have to unzip/extract this to the following location: pi/Downloads/arduino-1.8.8/libraries

If you are using the touchscreen display and Pi Microscope, then you should consider watching this video!

Arduino Assembly

You can find the instructions on how to set up the Arduino and the CNC shield here!

Downloading and Running the Software

If you have not already done so, you should navigate to the Github repository for the Poseidon project and clone this.

This is done by clicking on the "Clone/download" button in the upper right corner of the screen, then clicking on "Download zip". Once you have done this, you will have to extract the file contents. I would suggest extracting to the desktop of the Raspberry Pi.

Once extracted, you should open up the folder. In this, there should be a folder name "SOFTWARE". You should double click on the file that ends in ".ino", which should open up the Arduino IDE. Ensure that you have connected your Arduino to the Raspberry Pi and have selected it, then flash this code to the Arduino.

Running the Software

For running the software, I would strongly recommend watching this video.

Once you have flashed the code to your Arduino, you should open up a Terminal window. navigate to the location of the SOFTWARE folder...

For example, if you have extracted to the desktop of your Raspberry Pi, then you will have to type something like this:

    cd Desktop/poseidon-release/SOFTWARE

This is called "navigating to the directory" in which the software exists. Once you are in this folder you can type

    ls

to list the files in this current directory.

To execute the software, you should ensure that you have everything connected, meaning the Arduino has the CNC shield and motor(s) connected to it and the Arduino is connected to the Raspberry Pi.

Now type the following into your Terminal window:

    python3 poseidon_main.py

This should execute the Graphical User Interface (GUI) and let you start playing around with the software.

It should look something like:

SyringePumpInstructions1.png


Next, you should click on the "Setup" tab in the Syringe Pump GUI. This should lead to a screen that looks like:

SyringePumpInstructions2.png

Under this window, you will be able to configure the settings with which you would like to configure the Syringe Pump.

First, you should click on "Refresh Ports" and then select the port at which the Arduino Uno is located. This should be something like /dev/tty/AMA0. Then select "Connect to Controller" (located in the lower left portion of the screen). This connects the Raspberry Pi to the Arduino so we can control the CNC Motor Shield with the GUI running on the Raspberry Pi.

Next, you should select the appropriate micro stepping setting. The device is set up to do up to 1/32 micro stepping, but you can choose any micro stepping setting below this.

Next, you should configure the pumps according to the settings that you want to use. This is done by selecting the Syringe, Units, Speed, Acceleration, and Jog Delta. You may find the following table to be useful while choosing settings:

51273546-d49c4f00-1981-11e9-8946-9ec0baf57dbd.png

Once you have chosen your settings, you should "Send All Settings" by clicking the butting that says "Send" at the end of each row or by clicking the "Send all settings" button. (Note that the "Send" button at the end of each row has turned green once you changed the settings.

SyringePumpInstructions3.png

Now you can navigate back to the main "Syringe Control" tab of the GUI:

SyringePumpInstructions4.png

Select the checkboxes associated with the pumps that you plan on using and adjust the amount that you intend on moving each pump. Once these are selected, you can simply click on "Run" and watch as the syringe pumps go to work!