Raspberry Pi Controlled Microscope - OpenLabTools
-
Upload
nguyenkhanh -
Category
Documents
-
view
220 -
download
1
Transcript of Raspberry Pi Controlled Microscope - OpenLabTools
![Page 1: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/1.jpg)
Raspberry Pi Controlled Microscope
![Page 2: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/2.jpg)
Aims
• Open Source Microscope
• High quality images
• Modular Design
• Automation of simple tasks
![Page 3: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/3.jpg)
Mechanical Design Thomas Roddick
![Page 4: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/4.jpg)
Structure
• Frame constructed from OpenBeam – an open source construction kit
• Aluminium slotted extrusion
• Brackets suitable for 3D printing – all designs available online
Image from Grathio Labs http://grathio.com/wp-content/uploads/2012/07/openbeam.jpg
![Page 5: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/5.jpg)
Actuation
• Leadscrew driven actuation
• Inspired by RepRap 3D printers
• Bearings left and right of the screw prevent rotation
• Microswitches limit range
![Page 6: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/6.jpg)
3D Printing
• Current version contains 15 3D printed parts,
• Printed in ABS using a MakerBot Replicator 2X printer
• All designs available on Github
![Page 7: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/7.jpg)
Stage
• Perspex stage supported by steel rod frame • Designed for microscopy but suitable for other
scientific applications
![Page 8: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/8.jpg)
X-Y Translation
x-axis
y-axis
![Page 9: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/9.jpg)
Cell Counting
1. Gaussian blur
2. Threshold
3. Erode
4. Blob detection
Implemented using SimpleCV
![Page 10: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/10.jpg)
Hardware
● Raspberry Pi
● Arduino Duemilanove
● Motor Shield
● LCD Screen
● LED Ring
● 60mW White LED
● Manual Controls
● Total cost ~£100
![Page 11: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/11.jpg)
Hardware
● Raspberry Pi
● Arduino Duemilanove
● Motor Shield
● LCD Screen
● LED Ring
● 60mW White LED
● Manual Controls
● Total cost ~£100
![Page 12: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/12.jpg)
Hardware
● Raspberry Pi
● Arduino Duemilanove
● Motor Shield
● LCD Screen
● LED Ring
● 60mW White LED
● Manual Controls
● Total cost ~£100
![Page 13: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/13.jpg)
Hardware
● Raspberry Pi
● Arduino Duemilanove
● Motor Shield
● LCD Screen
● LED Ring
● 60mW White LED
● Manual Controls
● Total cost ~£100
![Page 14: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/14.jpg)
Software
● Arduino Sketch
● Accepts Serial Commands from Pi
● Use Serial Library/Terminal on Pi
○ Arduino IDE Serial Terminal
○ PySerial, Twisted
○ Boost ASIO
● Stepper Control
● Illumination Control
![Page 15: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/15.jpg)
Serial Commands
● Human readable
● Format:
○ Command name
○ Argument if required, space separated
○ Terminated with newline
e.g
calibrate set_ring_colour 8A2BE2
z_move_to 500
● Returns confirmation, value and/or error message
![Page 16: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/16.jpg)
Stepper Control
● Non-blocking
● Self-calibrating
● Independent axis control
● Absolute and relative positioning
● Acceleration limits
● Serial and Manual Control
![Page 17: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/17.jpg)
Future
● Better Pi-side software support
● GUI
● Casing
● Power Supply
● Custom PCB/Shield?
![Page 18: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/18.jpg)
Optical system
olympusmicro.com
•Raspberry Pi Camera Module •Substitute Tube Lens
•Infinity Corrected Objective
![Page 19: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/19.jpg)
RPi Camera Module
3628.8μm
2721.6μm
Pixel pitch 4.1μm •Small Sensor
•Suitable Depth of Field
•Difficulty controlling brightness etc.
![Page 20: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/20.jpg)
3D Printed Optics
•Cheaper than commercial tubes •Easy to adapt
![Page 21: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/21.jpg)
Automation
Now put together all different aspects:
Mechanics
Electronic control
Optics and Imaging
and of course, the Pi
![Page 22: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/22.jpg)
Horizontal stage control
for live sample tracking
Focus stacking of macro
images
Extra sensors for
environmental control
And anything else you
might think is useful in a
microscope!
•Open-Source project → Many possibilities
![Page 23: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/23.jpg)
Example :: Auto-focusing
• Using this formula to compute a 'focusing value' for an image, it is possible to auto-focus the microscope.
• Here in particular, we implement the following algorithm
F=1
W Hμ∑ (I (x , y)− μ)
2
![Page 24: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/24.jpg)
Auto-focus :: algorithm
Compute focus value for starting Image (F_start)
Do the same for an Image above or below (F_1)
If F_1 > F_start Stay there and repeat cycle
Else
Compute focus of Image on other side of start Image (F_2)
If F_2 > F_start Stay there and repeat cycle, Halving number of steps
Else
Go back to start, Halving number of steps
![Page 25: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/25.jpg)
Auto-focus :: values
• For example, this is a graph of the focusing values of a sequence of images taken at equal distances, going downwards from the objective. The position corresponding to the peak is the focus point.
![Page 26: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/26.jpg)
Auto-focus :: added_complexity
• The previous algorithm relies on the starting position being already reasonably close to the focus point. However, a more automated version is also available, that can do everything without user input.
• The possibilities for other automation software are endless, and they can all be easily implemented using Arduino commands and image processing algorithms
![Page 27: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/27.jpg)
Auto-focus :: future_improvements
• Improvements on the efficiency of the auto-focusing
algorithm will be derived primarily from:
– Faster image acquisition (usage of MMAL library
directly, rather than RaspiStill program)
– Analysis of images loaded through MMAL in RAM
memory, rather than saved on disk
![Page 28: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/28.jpg)
Data Acquisition using the Pi
![Page 29: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/29.jpg)
Introduction
• Produced a set of tutorials based around Data Acquisition using the Pi
• All tutorials involve taking an analog input voltage, digitising it and saving the result to the Pi
• Tutorials divided into two groups:
– Interfacing an ADC with the Pi (Ti ADS1115)
– Interfacing the Pi with a microcontroller (Arduino Uno)
![Page 30: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/30.jpg)
Aims
• Aimed at undergraduate level students
• With:
– Basic programming experience
– Little / no experience using microcontrollers
• Motivations:
– In the future should be helpful in the microscope project
– Many engineering students terrified by the prospect of using a microcontroller / interfacing with hardware
![Page 31: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/31.jpg)
Pi + ADS1115
• Sold by Adafruit on pre-soldered PCB
• 16 bit resolution, maximum 860sps
• Interface using I2C
• Python libraries provided by Adafruit allow easy interfacing
![Page 32: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/32.jpg)
• Tutorials involve:
– Introduction to how I2C works
– Description and configuration of ADS1115 (using device
datasheet)
– Simple python script to log data
• Problems:
– Raspbian not a Real Time Operating System – lots of jitter
– Maximum sample rate 860ksps
![Page 33: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/33.jpg)
10sps 860sps
Time Between Successive Samples
![Page 34: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/34.jpg)
Pi + Arduino
• Based around the ATMega328 microcontroller
– Has a 10bit ADC
• Advantages:
– Sample with very low jitter
– Higher sample rates (10s of ksps)
• Interface options:
– SPI
– I2C
– Serial
![Page 35: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/35.jpg)
• Serial chosen for simplicity
– Up to 50kbytes / second
– Effective resolution of ADC drops below 10 bit above
15ksps anyway!
– I2C and SPI require level converter
– Allows programs to be run from a PC
• On the Pi side using python + Pyserial to communicate
with the Arduino
![Page 36: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/36.jpg)
Tutorials
• Introduction to Arduino environment
• Serial communication between Arduino and Pi
• Interrupt Tutorials – External
– Timer
– ADC
• Data logging with Pi + Arduino – Continuous logging (up to 35ksps – 8 bit)
– Burst sampling (100ksps – 8 bit)
![Page 37: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/37.jpg)
Burst Sampling of 750Hz waveforms sampled at 100ksps
![Page 38: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/38.jpg)
Teensy 3.0
• Based around ARM Cortex M4
• Programmed from the Arduino
IDE
• Serial functions work using USB
protocol (12Mbit/s)
• 16 bit - 100ksps continuous
sampling with Pi
![Page 39: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/39.jpg)
3rd Year Bread Making Lab
• Existing lab involves recording a voltage output using voltage meter by hand
• Use Pi + ADS1115 to log data instead
• Gives students a digital output format
![Page 40: Raspberry Pi Controlled Microscope - OpenLabTools](https://reader031.fdocuments.in/reader031/viewer/2022022417/587b36531a28ab6b028b56a5/html5/thumbnails/40.jpg)
Extensions
• I2C and SPI communication between Arduino and Pi
• Modify burst sampling programs to make simple digital oscilloscope
• Circuit designs
• Interrupts on the Teensy
• DMA tutorial on Teensy / Arduino DUE