GithubHelp home page GithubHelp logo

ibm / microscopy Goto Github PK

View Code? Open in Web Editor NEW
1.2K 56.0 113.0 246.17 MB

An open-source, motorized, and modular microscope built using LEGO bricks, Arduino, Raspberry Pi and 3D printing.

License: Apache License 2.0

Python 68.23% C++ 31.77%

microscopy's Introduction

An open-source MICROSCOPE built using LEGO bricks, 3D-printing, Arduino and Raspberry Pi

Animation

Images

Stop-motion

Key Features

  • Fully motorized: Camera angle, sample position, magnification and focus can be adjusted precisely using six stepper motors.
  • Modular: Stages and modules can be arranged in any configuration depending on the application.
  • Versatile: Uniform illumination guarantees high quality imaging for a variety of samples with reflective or transparent surfaces.
  • Wide magnification range: Samples with features from several centimeters to several micrometers can be imaged without changing the objective lens.
  • Low-cost: The whole assembly costs from $200 to $400 depending on the features and the vendors of the electronic components.
  • The microscope uses a Raspberry Pi mini-computer with an 8MP camera to capture images and videos. Stepper motors and the illumination are controlled using a circuit board comprising an Arduino microcontroller, six stepper motor drivers and a high-power LED driver. All functions can be controlled from a keyboard connected to the Raspberry Pi or a separate custom-built Arduino joystick connected to the mainboard. LEGO bricks are used to construct the main body of the microscope to achieve a modular and easy-to-assemble design concept.

Diagram

Assembly instructions

Video (YouTube) Instructions (PDF)
YouTube
Circuit assembly (PDF) Raspberry Pi HQ camera test
Circuit HQ-camera

Operation principle

The microscope has a simple operation principle based on changing the magnification and the focus by adjusting the relative distances between a camera, a single objective lens and a sample. Briefly, two linear stages with stepper motors are used to adjust these distances for a continuous and wide magnification range. Four additional stepper motors tilt the camera module and change the X-Y position and rotation of the sample. A uniform light source illuminates the sample either from an angle (reflected light) or from the bottom of the sample (transmitted light). The system can also be used as a digital water contact angle goniometer by taking cross-section images of droplets.

Operation

Assembly steps

3D printing

I assembled the main body of the microscope using individually-purchased LEGO bricks. Instead of using motors and gears from LEGO Technic, I designed custom actuators using FreeCAD software and printed them using my personal 3D printer. This approach not only lowered the cost of the microscope but also gave me some flexibility in the design and implementation of precise linear and rotary actuators. In principle, the whole structure could be 3D-printed without using any LEGO parts but that would be less modular and more time consuming.

All STL files for 3D printing and the original FreeCAD files for editing are available in this folder. You may need to install FreeCAD Gear workbench to edit the gears.

⚠️ A good quality printing depends on many factors. I optimized the designs after several iterations of printing. If the parts do not match well, some minor modification in the original design file (e.g. enlarging the holes matching to LEGO studs) or polishing/drilling may be required. More information on the printer and slicer settings is given in the PDF document (page #72).

3Dprinting

Electronics

⚠️ This part requires some basic knowledge on electronic circuit design and Arduino.

All design and Gerber files of printed circuit boards (PCBs) are available in this folder. I designed the PCBs using DesignSpark PCB software. The list of all components can be found in the PDF document (page #71)

There is also a separate instruction manual giving more details about the assembly of the circuit boards.

The operation of the electronics is straight-forward. I used two Arduino microcontrollers, one for the mainboard (essential) and one for the joystick controller (optional), to control the stepper motors and the LED illumination of the microscope. In principle, everything could be controlled directly from the Raspberry Pi without using any Arduino microcontroller but I decided to leave testing this option for another time.

💡 The joystick controller is optional because the stepper motors and the LED can also be controlled from a keyboard connected to the Raspberry Pi. But having a joystick is fun!

Electronics

I preferred Adafruit ItsyBitsy 32u4 5V but any Arduino board with enough number of I/O pins should work. If you want to use the joystick controller, the Arduino boards should support serial (UART) communication because they cannot communicate with each other via their USB ports.

The Arduino on the controller circuit reads the status of three thumb joysticks (for six stepper motors) and a potentiometer (for the LED intensity) via its analog inputs. The data is sent to the Arduino on the mainboard via UART (RX, TX) serial communication. An OLED display on the controller can be used to display useful information, like the PWM (pulse-width modulation) intensity of the LED. The Arduino on the mainboard receives and processes the incoming data and sends stepper motor signals to the corresponding stepper motor via its respective motor driver. Six motor drivers share the same signal pins but only one driver is activated at a time using the enable (EN) or the sleep (SLP) pin of the driver. This implementation requires only 10 I/O pins (4 signal + 6 enable) instead of 24 (4 signal x 6 motors). It also prevents the heating of the motors when they are idle and limits the current consumption by allowing only one motor running at a time. Alternatively, a motor driver with a built-in indexer with STEP/DIRECTION control can be used to reduce the number of I/O pins but such drivers are more expensive. The data is sent only if there is a change in the joystick position is detected to avoid continuous communication.

The mainboard can be powered from an external 5V wall charger or directly from the USB port of the Raspberry Pi. The latter also allows USB communication between the mainboard and the Raspberry Pi to control the stepper motors and the LED intensity from a keyboard. The intensity of the LED is controlled by PWM using a dedicated pin on the Arduino. I recommend keeping the LED off while the Raspberry Pi is booting and then gradually increasing the intensity. The LED driver and the high-power LED used in this project required more than 6V for a rated operation. I initially used an external 12V power adapter for the LED but later generated 12V directly from the USB port of the Raspberry Pi using a step-up DC-DC converter. In this case, the 5V power adapter should be able to supply enough current for the Raspberry Pi, stepper motors and the LED. I tested the system using a single 5V / 3A supply (original Raspberry Pi 4 power supply or a wall charger). Different configurations may require different power ratings. For example, if the display is also powered from the same source, then a more powerful 5V source would be needed. Here is a good one.

⚠️ The high-power LED gets hot after some time, be cautious. I used a standard aluminum heat sink to help cooling a little bit.

Uploading the Arduino code

  • Download the latest version of the Arduino IDE
  • Install the libraries (Sketch → Include Library → Manage Libraries):
    • AccelStepper: used to control the stepper motors (mainboard).
    • (Optional) Adafruit NeoPixel: if you want to have a status LED or nice color effects in the mainboard.
    • (Optional) Adafruit_GFX and Adafruit_SSD1306: if you want to have an OLED display in the joystick to show the intensity of the LED illumination.
  • Add the board by following these instructions.
  • Upload the code(s).

Arduino

Final assembly

Follow the detailed instructions given in the PDF document. Briefly:

  • It is important to fix the 32x32 LEGO baseplate to a rigid table or support for a good mechanical stability. Rubber dampers or an air cushion can be used to minimize vibrations.
  • Unfortunately it is not possible to create a public shopping basket in the LEGO shop, all parts need to be added one by one. I listed the LEGO parts in this document but I recommend buying extra bricks and plates in case you need to change something.
  • Some LEGO parts are needed to be glued permanently for better stability. I provided recommendations in the document based on my experience. In general, it is a good idea to glue a smaller LEGO piece (e.g. 2x2) to a larger one (e.g. 2x4) to have a stronger interlocking while preserving the advantage of LEGO bricks for modularity.
  • After assembling the microscope and connecting all the cables, boot the Raspberry Pi.
  • ⚠️ Do not forget to enable the camera from the Raspberry Pi configuration (Preferences → Raspberry Pi configuration → Interfaces → Camera Enabled → Reboot) as explained here.

Assembly

Python-Raspberry Pi

I wrote a simple program in Python 3 to control the microscope, modify camera settings and take photos and videos from keyboard. The code allows changing almost all camera settings using keyboard shortcuts. The speed and the direction of the stepper motors and the LED intensity can also be controlled from the keyboard independently from the joystick controller.

The code requires following dependencies:

  • EasyGUI: to generate simple message boxes and select the folder where the images are saved
  • pySerial: to communicate with the Arduino via USB
  • pynput: to monitor keyboard inputs

There are two important parameters in the program to be changed according to your configuration:

HighResolution:

  • True for (3280x2464), tested with Raspberry Pi 4.
  • False for (1920x1080), tested with Raspberry Pi 3 and Zero.

KeyboardControl:

  • True if the Arduino mainboard is connected to the Raspberry Pi via USB.
  • False if the mainboard is not connected and powered from an external 5V supply

Finally, launch the program from the terminal and enjoy the microscope:

python3 /home/pi/MicroscoPy.py 

Program

Basic operation modes

Modes

Media coverage

IEEE Spectrum: "Build A Sophisticated Microscope Using Lego, 3D Printing, Arduinos, and a Raspberry Pi"

IBM - Medium article: "IBM open sources $300 fully-functional LEGO®microscope design"

Futurism: "This Engineer Published Scientific Papers Using a Lego Microscope"

License

This project uses the Apache License Version 2.0 software license.

Separate third-party libraries used in Arduino and Python codes are licensed by their respective providers pursuant to their own separate licenses.

About

The microscope is not currently available for purchase in kit or built form.

Copyright 2021 Yuksel Temiz

microscopy's People

Contributors

imgbotapp avatar stevemar avatar yukseltemiz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

microscopy's Issues

Raspberry Pi Camera Module 3

I am currently working on integrating a new camera module into the project, and I am seeking guidance from the community to ensure a smooth implementation. The new camera module module 3 uses Picamera2 libraries as opposed to the Camera Module 2 (the one used in the project) which used Picamera libraries.
Are there any changes that need to be done in the code for this? Or rather is there any significant advantage in using the newest camera module?

Information for printing PCBs

I am trying to get a quote for printing the PCBs. Unfortunately, I don't know much about PCBs so the options are very confusing to me (layer count, material type, FR4-TG, thickness, finished copper, min spacing, min hole size, surface finish, etc. etc.--example from a vendor is attached).

Is there somewhere I can get more information to answer these questions for a PCB printing service? Also, if you or someone else can supply me with the correct responses, I can document this for your project so others will know what to do as well.

Thank you so much for sharing your knowledge on this! Not only an amazing project, the final result will be incredibly useful! Thank you!

image

BoM and lenses

Hello, :) It would be great if the project had a BoM (Bill of Materials), with links (to the recommended items), and specifications. This would help, and make it easier for people to buy the required items and do the project. Regarding the lenses, what other options do you recommend (high-quality ones) besides the TREEYE 15.3mm lens M12? What other lens do you recommend for the HQ-camera? Cheers!

Mainboard, mystery component?

Hello.
I'm looking at the Instructions.pdf page Electronics - Mainboard. On the picture of the Mainboard, there is an unlabeled black capacitor(?) on the Mainboard to the left of the LED driver. Does this component need to be soldered on? What is it and its specifications? Do you have a part number for it?
Thank you!
Keith

STL for Joystick enclosure?

Is there not an STL for the joystick enclosure or am I just totally blind? I can't find anything about it in the instructions

Digital Zoom Moves Off The Screen

Hello. This project is incredible! Thank you so much for doing the design work and making it all available here. I have printed all of my parts with my Prusa i3 MK3S+ printer, ordered the PCB boards and soldered everything up. I took my time and great care. When I loaded all the software and turned it on for the first time, it worked!! Amazing and gratifying.

That said, I have an issue I am encountering that I'd like to discuss and wonder if anyone has thoughts about how to solve this. When I zoom in with the digital zoom, the picture goes off the screen. Is there any advice about how to solve this? Is there a software fix that might center it? I fear that the cause of this issue might be that the camera lens and the Raspberry Pi v2 camera are just slightly misaligned, in which case a software fix wouldn't help.

I'll post my pictures here. I am still learning how to position the camera and lens to achieve macro and microscopy. I have not yet been able to create the beautiful full screen pictures that are shown in the Instruction Manual and on this GitHub
IMG_0598
IMG_0597
IMG_0596
IMG_0595
IMG_0594
IMG_0593
IMG_0592
IMG_0591
IMG_0590
07-02-113538
07-02-113534
07-02-113526
Uploading 07-02-113521.jpg…

add Microscopy to Open Neuroscience

Hello!

We are reaching out because we would love to have your project listed on Open Neuroscience, and also share information about this project:

Open Neuroscience is a community run project, where we are curating and highlighting open source projects related to neurosciences!

Briefly, we have a website where short descritptions about projects are listed, with links to the projects themselves, their authors, together with images and other links.

Once a new entry is made, we make a quick check for spam, and publish it.

Once published, we make people aware of the new entry by Twitter and a Facebook group.

To add information about their project, developers only need to fill out this form

In the form, people can add subfields and tags to their entries, so that projects are filterable and searchable on the website!

The reason why we have the form system is that it makes it open for everyone to contribute to the website and allows developers themselves to describe their projects!

Also, there are so many amazing projects coming out in Neurosciences that it would be impossible for us to keep track and log them all!

Open Neuroscience tech stack leverages open source tools as much as possible:

  • The website is based on HUGO + Academic Theme
  • Everything is hosted on github here
  • We use plausible.io to see visit stats on the website. It respects visitors privacy, doesn't install cookies on your computer
    • You can check our visitor stats here

Please get in touch if you have any questions or would like to collaborate!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.