Tuesday, April 12, 2011

Auto Macro Stacker

Intro:
This project is some hardware and software which allow precise positioning of a camera for taking multiple macro shots at fixed positions such that the images can be "stacked" in software to obtain a an image which is fully in focus.

When shooting with a macro lens typically the depth of focus is very small (1-2mm), so to take an image of something you need to combine multiple pictures.

So with this project; I specifies how many shots I want to take; and how many millimeters the shots are to be and the rest is automatic.  The hardware moves the camera the right distance and controls the shutter of the camera; and repeats for all the shots.  Check out the videos at the bottom of the post.

Here is the latest video:




Mechanical - Initial Prototype
- The hardware is essentially a threaded rod with a stepper attached which allows for precise positioning of the camera.
I used mostly recycled materials for the first build:

  • Plywood ($0 scraps lying around from other projects)
  • 3/8" steel rods ($0; taken from some old printers from the trash)
  • Stepper Motor and gears($0; again taken from old printers from the trash)
  • Plastic slider; surplus UHMW (similar to delrin/acetal), bought for $4 a pound, I used about $1's worth
  • 1/2" ACME threaded rod, left over from another project; though you can use regular cheap threaded rod from the hardware store
  • Brass Bushings; not really necessary; I used a single 3/8" brass bushing cut in two ($3)


Building the linear rail:
Frame:
I sized the frame such that the stepper could sit inside, I made the length long enough to fit my left over section of threaded rod (8")

Drilling:
This is the trickiest part of the build; the holes have to be well aligned for the slide not to bind.  I did this by clamping both end pieces and the slider together and drilling the three holes at the same time.

I laid out the two parallel rods such that they were 4" apart with the threaded rod running down the middle.

Threading the rod through the slider:
To do this I filed some slots in the end of a scrap of ACME lead screw, I then heated up the screw a bit and tapped the hole.  It a few passes until it became smooth.







I turned a 1/2" from the ends of the lead screw such that they would fit in the brass bushings; this is probably overkill for this situation; since its not a CNC machine there is minimal load on the screw; I'm pretty sure it would be fine just running the threads through a larger hole in the plywood.





Results turned out ok; but it really needs brass sliders instead of just using the UHMW directly on the rail.  The UHMW plastic seemed to bind on the rail occastionally which made the motion less smooth.





I've moved on to MK-II since I scored a great little linear rail from a friend of mine; The initial prototype works its just not as cool looking :)


Mechanical MK-II:
For MK-II I machined some brackets from UHMW-PE and used a Z-axis a friend of mine provided.  He got three of the Z-axis on e-bay cheap.  The white bits are the brackets I machined on my drill press.











Electronics:
To keep it simple I decided on a simple USB interface (could easily have done a microcontroller based solution (I may do this in the future); I used the FTDI FT232R since it supports bit-banged mode; I paired this with a standard stepper driver from pololu.  I also added shutter control.

Pretty basic stuff here:
- FTDI FT232R USB interface
- Alegro A4983 stepper driver
- NPN transistor for the shutter control

Schematic is a bit of a work in progress:



I assembled it on protoboard; but I'm in the process of building some PCBs; let me know if you're interested in one once they're made; I'll have some extras.







Software:
The software is pretty straight forward; I put the source up on github:

Its currently just a command line utility; still a work in progress; but its working.

https://github.com/scottjgibson/camera-motion-controls

Stacking Software:

Check this out for a comparison of software:
http://chdk.wikia.com/wiki/Stacking_Software
I ended up using Helicon Focus


Results:

Setup:
- I'm using a standard kit Canon 18-55 mounted backwards; makes for a pretty sharp macro lens.



Here is one of the images from the first set I took; as you can see only a small area is in focus.



I did a run and stacked the 30 images together to obtain the following result; not great but I'm happy with it for a first try.



Here is are some videos of the rig in action:


The macro stacking software can generate a 3D model based on the stack of photos:

4 comments:

Stephen said...

Very cool....

I've been stuck on a iPad software project for a while now, but I've got to get my hands dirty again soon!

Xevi said...
This comment has been removed by the author.
Xevi said...

Awesome!, I am a collector of microminerals, and that I have long intended to start taking pictures in layers and use Helicon to process them, I really liked your project by minimizing contact with the camera and thus prevent vibration. Have designed and a PCB?, You know it could cost?
I feel the inconsistencies in the text, I used a translator.
regards

Anonymous said...

I want to realize this installation. Which program to use to enter the command line? Sorry for my English.