This page describes how to build an automated inverted 3d printed microscope for observing microfluidics chips.
This is a SPOC lab project. Original source code of the project is provided under MIT License. The source may contain code under a different license, if this is the case it is stated in the LICENSE file. This page describes how to create a simple het cam robot.
If not stated otherwise, the designs and documentation in this repository are made publicly available under a Creative Commons Attribution 4.0 International (CC BY 4.0) License.
Image of the 3D-printed microscope.
The microscope is designed to be as cheap and quick to manufacture as possible, and still achieve high accuracy. Due to the chosen delta kinematics the device has a very small footprint, and is also suitable for use in an incubator. incubator. In the SPOC lab, the microscope is used to observe and monitor the generation of spheroids in self-constructed chips and monitor the process. The microscope can be controlled directly or automated via a program to observe an experiment over time.
The microscope model was designed in openSCAD in parametric form. For each part, an stl file was created and all files where then sliced with Prusa Slicer and sent to print on an 3D filament printer (Prusa MK3). For the ease of reproduction of the slicer files are also saved within the directory.
A screenshot of the microscope in openSCAD (for the file see ./files/3d/openscad-microscope.scad).
item | number | purpose | bought from | part-no | costs in € |
---|---|---|---|---|---|
Allegro A4983 Based Stepper Boards: here the ‘Big Easy Driver’ | 3 | stepper board | Technobots | 2900-445 | ~ 70 |
Teensy 4.0 or 4.1 Microcontroller | 1 | stepper control | Conrad | 2269230 | ~ 30 |
Nema 17 Steppers (0.9° 2.4 A) | 3 | stepper motor | Act-motor | 1402-050 | ~ 60 |
Fine Hex Adjuster, 1/4”-80, 4” Long | 3 | leadscrew | Thorlabs | F25SS400 | ~ 40 |
Locking Phosphor-Bronze Bushing with Nut, 1/4”-80, L=0.50” | 3 | leadscrewnut | Thorlabs | N80L6P | ~ 28 |
Linear Guide Rails (min 200 mm) | 3 | slides platform | Amazon | CNBTR214 | ~ 45 |
Universal Coupling Body | 3 | motor-screw-connector | Technobots | 4604-050 | ~ 12 |
Universal Coupling Insert - 5 mm | 3 | motor-side | Technobots | 4604-059 | ~ 8 |
Universal Coupling Insert - 1/4” | 3 | screw-side | Technobots | 4604-066 | ~ 8 |
OTHER SMALL ITEMS | |||||
160 mm x 100 mm Copper Clad Stripboard | 1 | mount for electronics | Conrad | ~ 2 | |
Male & Female PCB Headers 2.45 mm pitch | some | simple connectors | Conrad | ~ 10 | |
Screws M3 (10 mm): 12 for motors, 6 for sliders, 15 for guides | 33 | mount slider & motors | Bauhaus | ||
Nuts M3 | 33 | fixing screws | Bauhaus | ||
Screws M6 (15 mm) | 12 | suspension | Bauhaus | ||
Screws M6 (60 mm) | 6 | suspension | Bauhaus | ||
Nuts M6 (end nut) | 6 | suspension | Bauhaus | ||
Neodymium bullet magnets ⌀ 10 mm | 6 | suspension | Bauhaus | ||
USB (micro) cable | 1 | Conrad | ~ 3 | ||
6 wire colored ribbon cable | 3 m | Conrad | ~ 3 | ||
12 V / >=5 A power supply | 1 | Conrad | ~ 20 | ||
197 g 3D-printer filament (PLA 1.75 mm) | 1*250 g | microscope structure | 3d jake | ~ 10 | |
USA Digital Microscope 40x-1000x | 1 | microscope camera | Bysameyee | ~ 20 | |
< 400 |
- Technobots: http://www.technobotsonline.com
- Thorlabs: http:/www.thorlabs.com
- CPC-Farnell: http://cpc.farnell.com/
- RS: http://uk.rs-online.com/web/
- Techsoft: http://www.techsoft.co.uk/
- Maplin: http://www.maplin.co.uk
All components but the optics-screws (Thorlabs) can be obtained commercially. If other leadscrews are used, the software has to be adapted to the distance/revolution grading.
- FDM 3D-printer (we use an Prusa MK3, but any model with an similar precision would do)
Image of the robot.
Biocompatibility is of new untested materials is an important field. This robot is a proposal of an automated het-cam experiment.
- PLA
- stepper motor driver
- stepper motor
- arduino
- raspberry 4
- raspberry hq video camera
- FDM 3D-printer (Prusa MK3, but any model with an similar precision would do)
- Soldering iron
- Hand tools (screwdrivers etc.)
- tin the leads of the motors with solder, add a male PCB-connector (or any other connector of your choosing. On our motors the colored leads are GREEN, BLACK, BLUE, RED).
- we use heatshrinking tube to electrically isolate the connectors at the end.
- add the connector for the leadscrew (5 mm brass insert) to the motor - you might not have space to do that later.
- add the brass insert to connect the motor onto the leadscrew
- insert the screw VERY carefully to avoid damaging the thread which can happen rather easily.
The Microscope can be exchanged with an variety of solutions. We tried an Raspberry HQ Camera v1.0 with SM1 to C-mount adapter (thorlabs, SM1A9) to 1 inch optics connected to an Zeiss Plan 2,5 objective, but eventually ended up with an 25€ USB microscope camera that has a 40x-1000x zoom option for maximal flexibility.
The STL files for the microscope where sliced in Prusa Slicer 2.2.0 and printed in ecoPLA NeonOrange with 20% infill. The linear guide rails where screwed onto the main part, and the top part was then screwed onto the guide rails with 15xM3 screws and nuts. For correct assembly, the top part has to end on height of the guide rails. The three stepper motors where then screwed (12xM3) onto the bottom part. The bottom part needs to be screwed on the other end of the guide rails (3xM3). Now the universal couplings are screwed onto the motors and the optical fine threaded rods are fixed on the other side of the universal couplings. For better durability, the plastic part of the universal couplings are glued to the metallic part with epoxy glue. Six M6x15 mm screws are glued into the three slider parts, and M6x15 mm are glued into the platform as preparation for the magnetic joints. The slider parts are now joined with their threaded insert and can be screwed onto the guide rails. The end nuts are now placed on the M6 screws (60 mm) and the microscope stage is completed by putting the neodymium magnets in the joint positions. Finally, the microscope-camera can be put in the ring on top where it is held in position with the printed clamp.
To drive the stepper motors we use a A4983 stepper driver chip from Allegro Microsystems (datasheet http://www.technobotsonline.com/Datasheets2/1518-009-A4983SETTR-T.pdf). For convenience we use one ‘Big Easy Driver’ for each motor (http://www.technobotsonline.com/big-easy-driver.html, http://www.schmalzhaus.com/BigEasyDriver/). The ‘Big Easy Driver’ boards are nice, because they default to 16 step microstepping mode, when the ‘MS1, MS2, MS3’ pins are left unconnected (which means that less soldering has to be done). With 16-step microstepping, one revelation of the leadscrew (318 micrometer movement) is divided into 400*16=6400 steps resulting in a stable flow even at very low flowrates. The stepper drivers are controlled with a teensy 4.0 or 4.1 microcontroller.
Left: Images of the electronics board with three stepper driver boards mounted. Right: Schematic diagram.
- solder connectors onto the driver board (e.g. PCB-connectors)
- layout the parts on a stripboard and drill holes so that you can mount the board with screws to an enclosure (e.g. from laser-cut acrylic).
- solder female PCB-connectors on the board for the teensy and the stepper boards (don’t forget to cut the traces on the stripboard underneath).
- make all the necessary connections (see layout…)
- we made the system as simple as possible:
- no connection to MS1, MS2, MS3 - all are pulled high when not connected (means the driver defaults to 16 microstep-mode
- no connection to sleep (slp) and reset (rst) - if powered the system will be on all the time. If you want to shut down the motors, turn off the power.
- this leaves only the following connections to be made:
- enable (en) is pulled low on all by connecting to ground (this is important, else the pins float).
- shared GND between teensy and the quadstepper board (or single big easy drivers)
- step-pin (stp): if high for >1 microsecond, the motor will step
- direction-pin (dir): high/low sets the direction (if one of the motors steps the ‘wrong’ direction, just reverse the connections of the leads from (e.g. green, black, blue, red –> to red, blue, black, green).
- Teensy is powered by a USB connection and the motors are powered separately (we use a 12V 5A power supply).
- Don’t forget to adjust the current supplied to the motor with the small potentiometer on the stepper driver board. On max, the chip gets hot and the motor might have enough torque to continue beyond the end-stop, damaging the microscope assembly.
The microscope motors are controlled with a microcontroller (a ‘teensy’ 4.0 or 4.1) and a software front end written in Pure Data (PD). The teensy (https://www.pjrc.com/teensy/teensy31.html) is a 3.3V, 32-bit ARM based microcontroller that is compatible with the Arduino toolchain (https://www.arduino.cc/en/Guide/HomePage) and therefore easy to program. The prime reason to use a teensy is the high speed USB data transfer they allow (https://www.pjrc.com/teensy/benchmark_usb_serial_receive.html). Apart from controlling machinery, the teensy is well suited for data acquisition tasks.
Pure Data (PD, https://puredata.info/) is an open source dataflow programming language used primarily for music and video applications. It runs on nearly every computing platform, is straightforward to learn and can be modified ‘live’.
The communication protocol between the microcontroller and PD is OSC (‘Open Sound Control’, https://www.opensoundcontrol.org). It is a very flexible, easy to use two-way communication.
System diagram.
The easiest way to program teensy microcontrollers is to use the Arduino IDE (download:https://www.arduino.cc/en/Main/Software). For the teensy microcontrollers to be recognised by the Arduino IDE, one must additionally install ‘Teensyduino’ (download: https://www.pjrc.com/teensy/td_download.html). There is a detailed tutorial on software installation and its use on the webpage. Most of the Arduino libraries are compatible with teensy, Teensyduino itself comes with many optimized ones (full install recommended).
- program the teensy
- open the webpage
In the frontend control on the webpage, the rotation movement of the individual of the individual motors is calculated. This number of steps is now sent to the microcontroller, which in turn controls the motor driver via the Step/Dir protocol.
Screenshot of the program.
- Hit [devices], and the available serial ports will show in the console window. One of them is connected to the teensy. Click [open x[ (change the numbers by entering editing mode, ctrl-e (linux), cmd-e (mac)) and PD should connect to the teensy.
- upload the corresponding file to the microcontroller (./files/delta_microscope_arduino/delta_microscope_arduino.ino).
- place the PD-programs (./files/delta_microscope/delta_microscope.pd) together with a little helper-program for OSC (./files/o.io.slipserial.pd) in a folder and open it in PD-extended or PD-L2ORK.
- The file ‘run.py’ is the python/flask software.
- The files (./files/python/calibration.py) and (./files/frontend/delta_microscope_pd_osc_receiver.pd) can be used together to calibrate the microscope.
The microscope stage can now be controlled via an additional python script. At first, an experiment to run to different x/y positions and back to the origin has to be created and executed. After reaching the origin again, a picture of a raster is taken and saved in the experiment folder.
After running the experiment 25 times (n = 25), this resulting boxplot was calculated automatically with the calibration.py script.
git clone –recurse-submodules [email protected]:spoc-lab/delta-microscope.git
pip install -r requirements.txt for torch on armv7l: https://github.com/Kashu7100/pytorch-armv7l
sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools cd ~/Downloads git clone https://github.com/Kashu7100/pytorch-armv7l.git cd pytorch-armv7l/ sudo pip3 install torch-1.7.0a0-cp37-cp37m-linux_armv7l.whl sudo pip3 install torchvision-0.8.0a0+45f960c-cp37-cp37m-linux_armv7l.whl
sudo pip3 install -r requirements.txt
How to make the script run on startup: sudo nano /etc/rc.local insert: cd home/pi/het-cam-dashboard sudo CAMERA=opencv python3 run.py &
sudo nano ~/.profile git –git-dir=/delta-microscope/.git pull main
or for additional logging: sudo CAMERA=opencv python3 run.py & > /home/pi/Desktop/log.txt 2>&1
https://blog.miguelgrinberg.com/post/flask-video-streaming-revisited
to start an OpenCV session from bash, you can do this:
$ CAMERA=opencv python3 run.py
From a Windows command prompt you can do the same as follows:
on windows run: $ python run.py CAMERA=opencv $ py -3.7 run.py CAMERA=opencv
or: $ set CAMERA=opencv $ python run.py $ py -3.7 run.py
or on linux with gunicorn: