Saving 99.5%: automating a manual microscope with a 3D printed adapter

TL;DR: Some 3D-printing hackery can create an automated microscope stage from a manual stage for ~0.5% of the cost from the manufacturer.


I have always wanted access to a microscope with an automated stage. The ability to scan an entire slide/plate for a cell of interest seems to unlock a wealth of new possibilities.

Sadly, these systems cost quite a bit. The lab I work in now has a Leica DMi8 microscope with automated movement in Z. But XY movement is (on our model) still manual. It is possible to purchase an automated XY stage for this microscope, but the list-price quote is around £12,000 (including stage, and control hardware and software).

I’m not going to argue that this price is unreasonable. I am sure that the manufacturers of scientific equipment spend a lot of time and money innovating, and that money has to be made back by selling devices which have relatively small production runs. Nevertheless, the result is that the costs of kit that makes it to market are fairly staggering – and this prevents someone like me from being able to play around with an automated stage.

But I still wanted to experiment with an automated stage! So I wondered how easy this would be to do myself. After all, we have a manual stage, and we move it by rotating two knobs. Couldn’t I just get motors to turn those instead of doing it with my hand?

As I thought this through further I realised it was slightly complicated than this. Firstly, the knobs are co-axial, making them rather harder to deal with than would be two separate shafts. And secondly, as you rotate the X-knob, the shaft moves in X.

So the motors need to be able to move with it. But they also need to be to rotate and exert a twisting force on the knob – so they need to move linearly but be locked in one orientation.

Hardware: 3D printed pieces, 2 stepper motors and a RAMPS controller

I made a quick design in OpenSCAD

Basically the first knob,which controls movement in Y, is simply connected to the mechanism by a (red) sleeve which connects to a motor below. The knob above, which controls movement in X, is placed inside a (blue) sleeve which covers it in a gear. That gear is turned by a (turquoise) gear turned by a second motor. Both motors are mounted on a (transparent) piece which also connects them to a LM6LUU linear bearing which allows them to slide but keeps their orientation constant.

I printed out these 3 pieces – then tweaked the dimensions a little to be more snug on the knobs and printed them again. The final STL files, and the SCAD file that generated them are available on Thingiverse.

To control it I connected the steppers to a trusty RAMPS 3D printer controller. These cost £30 with a screen and a rocker controller (the Leica hardware to control a stage is ~£3k). Since the 3D printer controller is also all set up to control the temperature of a hot-end and a heated bed, if you want to add warm stage down the line this might be ideal.

Initial tests controlling the position using the system using the RAMPS controller went well, and let me calibrate the number of steps per micrometer.

Software: MicroManager

Regrettably, the Leica software isn’t going to allow you to easily hook it up to an Arduino-based controller. But, as ever, open-source software comes to the rescue. Micro-Manager is a very advanced ImageJ plugin that can connect to the Leica camera, and to the microscope itself to control filter cube positions, Z-focusing, etc.

Don’t expect quite the user-friendliness of Leica software from Micro-Manager, but do expect a wealth of packages to perform common operations in automated-microscopy (Leica charges ~£2.5k for the software to revisit a position multiple times – which was included in the quote given above).

Theoretically, MicroManager even allows you to control XY position using a RAMPS controller – someone has already written a package for exactly this board. This step, which should have been trivial, was actually the most complicated. The device adapter is designed to ask the RAMPS controller for its version, and somehow I could never make my board submit a response that the software was happy with. I had to download the MicroManager source and remove the code that checked the version. Successfully setting up the build environment for Windows took an age. Do get in touch if you have a similar project and want the DLL I built [update: DLL here, I offer no guarantees at all that it will work. This is an x64 build which will only work with a recent nightly build]. Anyway, to cut a long story short I got MicroManager to talk to the RAMPS board successfully.

Testing by making a 100X oil immersion slide scanner

Now to put it into practice.

I wrote a Beanshell script to scan a slide in X and Y and capture images. In this case I captured images in a grid 40 microscope images wide by 30 microscope images high, for a total of 1200 images.

This took a few minutes – try doing that by hand.. Then I stitched them together with the MIST plugin. The result is a 27,000 x 12,000 pixel image, featuring a whole lot of red blood cells. You can zoom in on the version below. This was taken with a 100X oil immersion objective, at which magnification the smallest motion of the stage is a substantial fraction of the image, but still allows enough overlap for stitching.

Fun! Still a bit more experimenting to do, but I’m hoping to get this acquiring tagged proteins from 96-well plates.

Caveat for anyone who tries to implement this: obviously be very careful not to create significant non-twisting forces on the coaxial knobs – you don’t want to damage your stage and ruin the alignment.

8 thoughts on “Saving 99.5%: automating a manual microscope with a 3D printed adapter”

    1. This is awesome.

      I’ve built an XY stage for a dissecting microscope out of a 3d printer and I gave up on using the RAMPS plugin. Instead I used the scripting panel to send gcodes over serial, which works but it doesn’t use the built in stage position features of micromanager.

      I would love to have your dll!

      Have you considered setting up homing on your system?

      1. Hi Andrey,

        I’ve just added a link to the DLL to the post. As I mention it will only work with a recent nightly build of MM. If anyone needs an x86 version I can compile but I’m away from my VM for the next week so not until then. And just a warning that this doesn’t just suddenly make all the stage based features of MM work. I’ve still had quite a few problems with getting SlideExplorer, for instance to work. But simple stage control should be fine. For me, no homing plans any time soon (I’m guessing super fine endstop controls would be needed? or something cleverer). The easy options for me are for instance to manually move the stage right to the top left and then set that at 0,0.

        Good luck!

        T

        1. I have attempted to use your DLL and I got it to show up in my micromanager devices list! However, when I try to connect to my stage it says error. Does the response from the printer still matter, with your modified DLL? What exactly does your printer output when the connection is made? Sadly I can’t just use your exact firmware file because my electronics are custom and only appear (barely) like a RAMPS controller when you talk to them by serial.

          1. (Apologies for the typo in your name in the comment above – now corrected!)

            Sorry that it is not working for you at present. I will try to get you the output in the next days. My intent was that the response from the printer would not matter but it is possible I did not achieve this..

  1. Thanks so much for sticking with me in this.

    I still can’t get it to work. When I add the RAMPS hub device i specify the COM port and then hit OK, and it says (error message unavailable) (110). This is actually the exact same error I get with the stock RAMPS hub device dll. What did you set your RS 232 settings to? I have gotten the free serial port device to work before with default settings so I doubt this is it, but I really have no idea.

Leave a Reply

Your email address will not be published. Required fields are marked *