External Motorized Z-Axis Control for Microscopes (Arduino & MicroManager)

by NirL in Workshop > Science

483 Views, 7 Favorites, 0 Comments

External Motorized Z-Axis Control for Microscopes (Arduino & MicroManager)

Instructables_CoverV1.jpg
F6LRW1JM3X1GZUV.gif

When you think of making something on a budget, you usually aim to save money while accepting some compromises in quality compared to commercial products. Achieving 90% of the quality at 50% of the cost is often considered a win. But today, we're pushing the boundaries—this project cost me about 0.1% of the price of existing commercial solutions. That's a 99.9% savings! And in this case, I'd say the result meets 100% of our lab's needs and about 50% of what a full commercial version can do.

In this Instructable, I'll show you how I built a simple, motorized mechanism to adjust the focus of our microscope in a teaching lab. It's based on a stepper motor that turns the microscope's focus knob, and the entire setup is controlled by an Arduino. Movement is managed via serial communication between the computer and the Arduino.

The key features of this z-axis setup are:

  1. Extremely low cost: ~$10–20.
  2. Sub-micron resolution: Precise movements of the focal plane.
  3. Computer-controlled: Works with simple serial communication interface (such as Arduino IDE) or through MicroManager, enabling z-stack captures.
  4. Non-invasive: Requires no permanent modifications to the microscope.

But let's also be honest and upfront - this solution has some limitations compared to commercial versions:

  1. No feedback loop: The system relies on counting steps, which may lead to accumulated errors over time.
  2. No autofocus (PFS): Long time-lapse experiments requiring autofocus are not supported.
  3. Manual control restricted: The attachment locks the focus knob during use, though it can be removed and reattached easily.
  4. Relative movements only: The system measures positions relative to a user-defined z = 0 micron plane. If the attachment is removed, this reference is lost.

Some of these issues can be solved quite easily, but that's for another day!

I hope you find some of this instructable useful, and if you have any questions or comments, feel free to share them at the comment section below!

Supplies

Tools:

Other than screwdrivers and such, you'll need access to a 3D printer and a laser cutter. If you can't find a laser cutter, you could design a motor mount and print it.

You'll also need:

  1. An Arduino board (I used Uno) & a USB cable for serial communication with the PC
  2. A small stepper motor (I used a common 28BYJ-48)
  3. A suitable stepper motor driver (I use the ULN2003)
  4. 5V Power supply (to power the stepper motor)
  5. Jumper wires (~6)
  6. Anti-slip stickers
  7. 6 mm plywood (for the base).

Motor Mount (& How to Customize)

PXL_20241120_103507612.jpg
PXL_20241120_103348864.jpg

The basic concept of this motorized z-axis is to turn the focus knob using a stepper motor. We use a Nikon Ts2R microscope, and the dimensions were adjusted to fit it, but they seem to be quite generic. In any case, you can modify the design to fit a different microscope and motor if you like. If you need help, leave a comment and I'll be happy to assist.

  1. Cut the parts out of 6 mm wood.
  2. Squeeze the two parts together and add glue if needed.
  3. Using two small bolts and suitable nuts, attach the motor to the motor mount.

Knob Attachment (& How to Customize)

PXL_20241120_103123554.jpg
PXL_20241120_103144082.jpg
PXL_20241120_103219523.jpg
PXL_20241120_103419100.jpg

To turn the focus knob, we'll need some adapter between the motor and the focus knob. I wanted it to be easy to attach and remove and made it sure it doesn't obscure the scale.

  1. Print the adapter. I used clear resin (1st image), but you can print it out of PLA or anything you like.
  2. Add anti-slip stickers to provide better grip (2nd & 3rd images)
  3. Make sure it fits your focus knob.
  4. Attach the adapter to the motor (4th image).

If you want to modify the design to fit a different motor or a different focus knob, you can do it in TinkerCAD. You can stretch the model in all directions as needed, and use boolean operations to create a suitable hole for the motor. I attached the STL file I used, and a blank version that can be modified (rescaled & hole punched into it in TinkerCAD).






The Circuit

PXL_20241120_104023106.jpg
PXL_20241120_104019069.jpg
PXL_20241120_104008402.jpg

Now all we need to do is connect the circuit.

  1. Connect the Arduino to the stepper motor driver:
  2. Pin 8 of the Arduino to IN4.
  3. Pin 9 of the Arduino to IN3.
  4. Pin 10 of the Arduino to IN2.
  5. Pin 11 of the Arduino to IN1.
  6. Connect the stepper motor driver to a 5 volts (DC) power supply. Do not use the Arduino to power the motor.
  7. Connect the motor to the stepper motor driver.

I used a breadboard, but you can solder the parts if you want a permanent solution. I'll be doing that in the future.

Control Via Serial Communication

simple arduino 1.png
simple arduino 2.png

At this point, everything is connected. You can control the motor either through MicroManager or through direct serial communication, but each will require flashing the board with a different software. I advise you to first test that everything is working properly using a simple software and direct serial communication via the Arduino IDE.

This software will turn the motor in steps of a constant turning angle defined by the user, and pause between steps. These are defined in the software (first image). You're allowed to divide a full rotation into multiples of 2 (for example, a in each step, move 1/32 of a full turn, 1/64, 1/128...).

  1. Once you've set the magnitude of each step and the time interval between them, upload the software to the Arduino board.
  2. Using the serial communication, type RUN to initiate motion, STOP to pause, or FLIP to change direction.


Disclaimer - I used the assistance of ChatGPT to write the Arduino software.

Setup and Control Via Micro Manager

micro manager setup 1.png
micro manager setup 2.png
micro manager setup 3.png
micro manager usage.png

Controlling a stepper motor through MicroManager using an Arduino turned out pretty tricky. The concept I ended up using is to kind of hijack a communication protocol of a commercial product to control it. This also ensured that there's a user interface for it in MicroManager (a normal z-axis movement interface). This idea is not mine, but since I had a really hard time finding it and making it work, I decided it's worth sharing.

  1. Upload the software to the Arduino. Note that you will need to define the step size in microns. For example, my motor makes a full turn in 2048 steps, and the focus knob moves 100 microns in a full turn, so each step is ~0.04883 microns. That's your maximal resolution!
  2. Note the COM used in for the Arduino, and close the Arduino IDE.
  3. Open MicroManager. Go to the Hardware Configuration Wizard (Devices -> Hardware Configuration Wizard).
  4. Look for the MarzhauserLStep, select the ZAxis: LStep Z Axis (see first image) and press Add.
  5. Setup the connection (see second image):
  6. At the top, select the right COM. In my case the Arduino is connected via COM6
  7. Set the port properties. I set these a bit different than usual. Most importantly, I allowed for a long AnswerTimeout of 5 seconds. I guess this won't be needed when using a faster board.
  8. Once finished, press OK.
  9. You should see the installed device with it's status 'OK'. See 3rd image.
  10. Finish the setup and save the configuration.

Once installed, you should be able to open the stage controls and change the Z-axis! As easy as that!

Make sure to perform the commands slowly - let the previous one end before sending a new one. Otherwise you'll get an error message (which is harmless, but annoying).


Disclaimer - I used the assistance of ChatGPT to write the Arduino software.

Mount and Test

PXL_20241120_133051658~2.jpg
Small Steps.gif
Full rotation - small.gif

That's it! Once you're done with software and assembly, mount the setup onto the microscope. Make sure it grips the focus knob firmly. Go ahead and enjoy your motorized z-axis. You can now take z-stack images or move with sub-micron resolution, which you couldn't do by hand. I tested moving the motor back and forth, and found that it returned to the same position reliably. I'm sure it may accumulate errors over time, but that seems negligible compared to what we need.

Thanks for reading my instructable! I hope it helps! I'd love to hear your thoughts and comments if you have any :)

If you like my instructable, feel free to

visit my instructables page and my website for more! See you soon!