I have a Swift SW380T, a common trinocular compound microscope of the kind sold for home and classroom use. Everything on it is manual, and two limits of manual microscopy show up quickly:
- The field of view is small. At 40× a camera on it sees about 160 × 120 µm. Seeing a whole sample means moving the stage and looking at hundreds of fields one at a time.
- The depth of field is shallow. At 40× it's about a micrometre, so a specimen thicker than that is never all in focus at once.
Motors, a camera and some code fix both. A motorized stage can step across a slide in a grid and stitch the tiles into one image. A motorized focus can sweep through a specimen and fuse the sharp parts of each slice into one image that is in focus everywhere. With both, the microscope can find its own focus.
The approach is to drive the microscope's own knobs rather than replace its stage. It's the cheapest route, it's reversible, and others have done it on other microscopes: Theo Sanderson automated the stage of a Leica research microscope this way for about £60, and the mouse-controlled microscope did it on an OMAX trinocular, the closest frame to this one. No one seems to have published a motorized SW380T.
The camera is already in hand. The build starts by measuring the microscope, because the numbers the mechanical design depends on aren't published.
What the microscope constrains
The SW380T's user guide settles most of the mechanical questions, and one fact shapes everything else: focusing moves the stage, not the head. The stage rides up and down, and its X/Y knobs ride with it.
| Part | From the user guide |
|---|---|
| Stage | 130 × 130 mm mechanical stage, X/Y travel 70 × 30 mm, coaxial knobs below it on the right |
| Focus | Coaxial coarse and fine knobs; fine focus marked in 2 µm divisions |
| Objectives | 4×, 10×, 40× and 100× oil |
| Working distance | 0.63 mm at 40×, 0.195 mm at 100× |
| Camera port | Trinocular, with a 1× C-mount under the adapter's top ring |
That gives four consequences:
- The X/Y motors ride on the stage. Whatever drives the stage knobs has to move up and down with them, and the focus mechanism has to lift it. That favours light motors there.
- The focus motor sits on the fixed body and drives one fine-focus knob, leaving the knob on the other side free for focusing by hand.
- A motor can drive the slide into the lens. See below.
- The camera goes straight onto the C-mount, with no printed adapter.
The one way to break something
The stage moves up toward the objective, and at 100× the gap is a fifth of a millimetre. A focus motor that overshoots pushes the slide into the lens. Three things guard against it: the microscope's adjustable rack stop, set so the stage can't reach the 40× and 100× lenses; soft limits in the firmware; and a coupling on the knob that slips, so the motor can never fight the mechanical stops.
The 40× and 100× objectives are spring-loaded, which helps, but it isn't a plan. The rack stop gets set in the first stage, before any motor is attached, so the lenses are protected from the start.
The numbers that set the design
Focus. Fine focus on this class of microscope typically moves 0.2 mm per knob turn, though cheap frames vary, which is one reason the first stage measures this one. At 0.2 mm per turn, a stepper motor on the knob at 1/16 microstepping moves the stage about 62.5 nm per microstep. A focus stack at 40× wants slices about half to one depth of field apart, 0.5 to 1 µm, which is 8 to 16 microsteps. So step size isn't the limit. Backlash and slop in the knob are, which is why every move approaches its target from the same direction.
Stage. With the camera on the 1× C-mount, a 10× field is about 630 × 470 µm and a 40× field about 160 × 120 µm. Covering a 15 × 15 mm area with 20% overlap between tiles takes about 1,200 tiles at 10× and about 19,000 at 40×. So whole-slide scans happen at 10×, and 40× is for regions picked out of them. 10× tiles step about half a millimetre, which a motor coupled straight to the knob can handle. 40× tiles step about 125 µm, which wants a belt reduction and careful backlash handling.
Decisions
Motion: Marlin on a 3D-printer control board. A 32-bit board in the class of the BTT SKR Mini E3 V3, with TMC2209 drivers and NEMA17 pancake motors. Marlin has backlash compensation built in, and Micro-Manager, the standard open-source microscope control software, already has an adapter that speaks its G-code. The drivers are quiet. Homing uses optical endstops: the drivers' sensorless homing works by stalling the motor against a stop, and here the stop would be the microscope's own mechanism.
- Rejected: the OpenFlexure project's Sangaboard with geared 28BYJ-48 motors, whose gearboxes add backlash; and GRBL, whose mainline has no backlash compensation and no Micro-Manager adapter.
Camera and host: an Arducam HQ camera on a Raspberry Pi at the microscope. The camera is a 12.3 MP IMX477 that I already own. Its C-CS adapter makes it C-mount, so it screws straight onto the port. The Pi runs the controller, so the rig is headless and its tiles go straight to storage on the homelab.
- Rejected: a USB microscope camera on a desktop running Micro-Manager, and a Micro Four Thirds camera.
Software: a small Python controller of my own. It sends G-code over serial, captures with picamera2, and autofocuses with OpenCV. Stitching and focus stacking run on the homelab: MIST or ASHLAR to stitch, and enfuse to stack.
- Deferred: Micro-Manager from the start, which is a heavy install and awkward on a Pi. It stays possible later through the same adapter.
The plan, in stages
Each stage ends with a test that has to pass before the next one starts.
0. Measure the microscope. Half a day with a dial indicator and a stage micrometer, a calibration slide ruled in 10 µm divisions. It answers what the mechanical design depends on:
- focus and stage travel per knob turn;
- backlash when a knob reverses;
- the knobs' sizes, and the gap between the coaxial pair;
- whether the knob assembly slides sideways as the stage moves;
- the room for motors that ride on the stage.
The pulley sizes and belt lengths follow from these. The rack stop gets set here too. Done when every measurement is in.
1. Camera. Mount the camera, write a capture script, and calibrate the pixel size at 4×, 10× and 40× against the stage micrometer. Autofocus and scanning both run on images, so this comes first. Done when calibrated images, with micrometres per pixel, land in homelab storage.
2. Motorized focus. One motor, belted to the fine-focus knob through a printed pulley that can slip at the ends of travel. Marlin is configured in micrometres, with soft limits and measured backlash compensation. On top go z-stacks, focus stacking, and autofocus that searches coarse then fine using the variance of the image's Laplacian, a standard measure of sharpness. This is most of the payoff for a third of the hardware. Done when autofocus lands repeatably at 40× and a fused stack comes out of one command.
3. Motorized stage. The hard mechanical part. The coaxial knobs need two nested drives: one coupled to the inner knob, one belted to the outer. Both motors ride on a bracket that moves with the stage. If the first stage shows the knobs slide sideways, the drive follows them on a linear bearing, as in Theo Sanderson's build. It's the part most likely to take more than one design. Done when stage repeatability, measured, is under a quarter of the 40× field (about 30 µm), and a 3 × 3 grid of tiles at 10× stitches cleanly.
4. Scanning. The software that turns motion into whole-slide images:
- a tile plan that snakes across the slide and always approaches from one side;
- a focus map, autofocusing at a few points and interpolating between them rather than focusing every tile;
- tiles and their positions uploaded to the homelab, where a stitching job writes a pyramidal OME-TIFF that a viewer can zoom through.
Done when a coverslip-sized area scanned at 10× opens as one stitched image, and a 40× region with a fused stack per tile does the same.
What gets built, bought and reused
- To reuse: printed parts others have published for this microscope: a Raspberry Pi camera mount, port extenders that match the camera's focus to the eyepieces, and an illumination adaptor.
- To design: the focus motor bracket and knob pulley, the stage-riding bracket with its nested knob drives, endstop mounts, and an electronics enclosure. They'll be written as code-CAD in build123d and printed on my Prusa.
- To buy: calibration tools, a Raspberry Pi 5, the control board, three motors, a 24 V supply, belts, pulleys and endstops. About $270 with a new Pi, or about $185 reusing one, at rough October 2026 prices.
For scale, the commercial motorized stages I priced run from about $2,000 to over $17,000.
The same loop at bench scale
The controller's motion layer sits behind a small interface, because the lab automation robot design study runs the same loop at the scale of a whole bench: move, capture, decide what to do next. One experiment script can then drive either machine.