Homebrew Stacking Controller

A forum to ask questions, post setups, and generally discuss anything having to do with photomacrography and photomicroscopy.

Moderators: rjlittlefield, ChrisR, Chris S., Pau

nucleobyte
Posts: 51
Joined: Sun Aug 22, 2010 8:00 pm
Location: Virginia, USA

Homebrew Stacking Controller

Post by nucleobyte »

I've been working on an automated stacking setup for a while now and have been making more progress recently. I thought I would start a thread here to summarize and share the project.

The basic concept was/is to build a complete stacking system with a few of loosely defined motivations & goals:
  • 1. Have fun & learn a lot
    2. Build as much as possible
    3. Good usability in the 2X to 20X range
    4. Use standard or easily obtained paarts
    5. Work with current gear (Canon 5DMII, MPE-65, 4X, 10X finites)
    6. Flexibility
    7. Portability
    8. Low cost
There are a number of stacking systems both here at photomactography.net and elsewhere; While I don't believe there are any profound inventions in my setup, it is a bit different than others I have seen and does implement some original ideas.

I plan to submit this in multiple messages since there is quite a bit of information.

Part 1. Focus Block
Part 2. Stepper Motor Mount
Part 3. Stepper Motor Driver
Part 4. Controller
Part 5. Examples
...
Last edited by nucleobyte on Mon Dec 08, 2014 9:52 pm, edited 3 times in total.

nucleobyte
Posts: 51
Joined: Sun Aug 22, 2010 8:00 pm
Location: Virginia, USA

Part 1. Focus Block

Post by nucleobyte »

I was fortunate to get a good focus block for about $30 on auction. It is a Zeiss Invertoscope base (no optics.) While not as ready to use as some focus block designs, it looked like some basic modifications would make it usable. The focus mechanism itself is ideal since it is very precise and the fine focus will range the entire block movement.

Image

Some internal details, disassembly and cleaning.

Image

The microscope base sat around for several months while I planned how to proceed and dared to make irreversible cuts on the focus block. I have access to a good wood shop, but no high end metalworking tools (lathe, mill.) I was able to make some fairly accurate cuts with a metal cutting blade in a bandsaw and clean up with a bench belt sander and files. I cut the focus block column into a more rectangular shape preserving as much metal as possible where I needed to tap screw holes.

Image

I fabricated a "L" mounting bracket out of mild steel stock and tapped and countersank mounting screws into the focus block with hand taps. I managed to break a drill off in one screw hole in the focus block which I had to cut out with a grinder and fill with JB Weld. I also tapped the bracket for 1/4"-20 standard threads and tack welded a backing nut for better support.

Image
Image

The project languished again at this point for quite some time until I was able to properly weld the "L" bracket and finish it.

Image

Finally, the "L" bracket welded and a spare quick release plate are mounted on the focus block. I left the support arms for the scope objective head in place as they didn't seem to interfere with camera mounting and though they may be useful for mounting lighting or other accessories. At this point the block is usable for manual stacking.
Last edited by nucleobyte on Tue Dec 09, 2014 3:06 am, edited 1 time in total.

nucleobyte
Posts: 51
Joined: Sun Aug 22, 2010 8:00 pm
Location: Virginia, USA

Part 2. Stepper Motor Mount

Post by nucleobyte »

Having taken apart a number of old inkjet printers and fax machines, I had a supply of unipolar and bipolar "pancake" stepping motors available. The fine focus on the Zeiss focus block requires very little torque, so these motors are quite powerful enough to drive the focus block. Most of these have a gear affixed as well. A number of builds here have used a direct drive, however the gear gave me an idea for a slightly different approach. I found a mating gear about the size of the fine focus knob from the random printer parts bag and (after a light sanding and cleaning) epoxied it to the fine focus knob. I constructed a bracket from 1/8" aluminum stock material and a lift arm to hold the motor in proper position.

Image

Image

The lift arm is held in place by a spring and is easily lifted to allow manual re-adjustment of the focus block. The spring may be a little under tensioned, but works for now. I'm still not completely satisfied with the use of epoxy to hold the plastic gear, but I cut a T-slot in the gear hub when I glued it and it has held up so far. I used a unipolar stepper motor since the driver I planned to use initially was a unipolar only driver. The motor I used was (I think) the form feed motor for a plain paper fax. It should be possible to drive this motor in bipolar mode if I ever change the driver.

There are 12 gears on the motor and 30 teeth on the fine focus knob for a 2:5 ratio. The stepper motor has a 7.5 degree step (48 steps per rotation.) This yields 7.5 * ( 2/5) = 3 degrees per step. The focus block is tricky since the coarse focus ring marker moves with the fine focus, but I think the fine focus moves 360 µm per revolution and therefore 1 µm / degree. So I think I am getting 3 µm per full step if all the math is right.
Last edited by nucleobyte on Tue Dec 09, 2014 1:38 am, edited 7 times in total.

nucleobyte
Posts: 51
Joined: Sun Aug 22, 2010 8:00 pm
Location: Virginia, USA

Part 3. Stepper Motor Driver

Post by nucleobyte »

Not having worked with stepper motors until recently, I found they were more complicated to drive than I expected, good driver circuits where somewhat hard to find, and driver chips could get quite expensive. After a lot of searching, I decided to try a unipolar motor/driver with the open source Linistepper v2 driver designed by Roman Black. You can buy them as a kit, but I chose to build one out on protoboard from the schematic. Here is the board connected in an early test configuration (controlled by an arduino clone.)

Image

The PIC microcontroller is programmed with the stock Linistepper firmware. The schematic, firmware, and documentation can all be download from the Linistepper site linked above. The driver is easily controlled with a fairly standard enable/direction/step logic interface.

Image

The Linistepper driver uses power darlingtons in a linear mode to implement microstepping. It is designed to handle current quite a bit higher than I needed for my motor (for CNC applications.) Based on specs for similar motors and the heating characteristics for my motor, It seems to want about 250mA per phase. The tuning resistors in the Linistepper driver were scaled up to 4.7 ohms from 1 ohm to lower the drive current to this range to prevent overheating of the motor. The heatsink was ripped from an old Pentium II/III CPU module and has a fan if it were ever needed. In retrospect this driver is much more than required, and I am experimenting with a simpler L293 based driver that could also be used with bipolar motors.
Last edited by nucleobyte on Tue Dec 09, 2014 1:27 am, edited 4 times in total.

nucleobyte
Posts: 51
Joined: Sun Aug 22, 2010 8:00 pm
Location: Virginia, USA

Part 4. Controller

Post by nucleobyte »

For initial testing I used an arduino clone, but I wanted to build a board with some extra hardware features like optocouplers for the camera control, eventually possibly to get a custom PCB made. As far as basic requirements, I wanted the controller to be operable from a tethered PC as well as run independently. I also wanted to be able to operate from a single 12V battery source for field use. I picked the ATtiny4313, a basic DIP packaged Atmel 8-Bit microcontroller, since I had some available and it has a serial USART and appropriate i/o pins and peripherals. Here is the circuit design output from my advanced CAD program.

Image
Bigger => http://www.photomacrography.net/forum/u ... 24px_1.jpg

There is a jumper in the power input circuit to select between regulated +5V and unregulated 7V-15V to make things easy during testing. I used the RS-232 port for communications, since it was a little easier than USB. I may add USB to future versions. The pin selection on the microcontroller was not too critical. I put the run button on hardware interrupt pins in case I wanted to make a hard cancel feature. The LEDs share the serial programming pins without problems. The motor step control is on a PWM capable pin, though not required for this version. The optocoupler outputs were current limited for about 30 mA. Here is the controller on protoboard.

Image

All connected for testing and development.
Image

I decided to separate the controller and motor driver since the controller can be used independently as an intervalometer and I wanted to be able to swap out stepper driver boards. The controller is hacked into the enclosure from an old wireless router than went bad. I cut sections off the old board to reuse the old power connector and LED areas. The ethernet port is unused. The 1/8" phono jack for camera control fit nicely in the antenna opening. I'm still working out the connector for the motor driver, possibly a Mini-DIN 6-pin connector.
Image

The control firmware is designed to operate in two environnments. One is tethered to a computer via the RS-232 serial port and the other is untethered with the microprocess assuming full control.

In tethered mode the controller responds to simple text commands entered using a standard terminal program. The command-response syntax is very minimal since there is little room on the micro for text processing. The commands are single letter and single letter with one numeric argument. For example "g" issues a "Go" command starting a stack capture. "s" returns the number of motor steps/slice and "S 20" sets the number of motor steps/slice to 20. There are direct control commands like "x -10" to immediately move 10 steps backward.

Image

The controller has 2 mode selection switches which allow a selection of 4 operating modes. Each of the 4 modes has a set of configuration parameters for a stack capture stored in EEPROM. The idea is to set up and test configurations of camera-lens hardware with a stack capture protocol while tethered in the lab. Then when out in the field, one of the 4 protocols can be selected based on the subject and lens setup.

Here is a link to the ATtiny controller firmware written in C for the avr-gcc compiler as well as Makefile. It's very much beta quality code but some folks might like to look through it.
Last edited by nucleobyte on Wed Dec 17, 2014 1:26 am, edited 6 times in total.

nucleobyte
Posts: 51
Joined: Sun Aug 22, 2010 8:00 pm
Location: Virginia, USA

Part 5. Summary

Post by nucleobyte »

In summary, the system is working well for my purposes. There are a number of obvious potential improvements.

A small display screen for more detailed reconfiguration when untethered along with some better input controls would be nice. A cancel feature would be handy. A smaller stepper motor driver would be easier to package.

There are a number of potential improvements to the firmware. I should have a better serial driver at some point as I'm working on it for another project. Also, a GUI type control program would be nice and fairly easy to build.

The current step size is 3 um, rework with a different motor or gear combo or using a driver in 1/2 step or smaller mode could reduce this, although, the images slices I'm capturing at 10X are small enough with about 5 steps per slice. Currently there is significant backlash in the motor mount when changing directions, this doesn't effect single stack captures, but thows off the start point if I automatically return-to-zero.

Rather than post image examples inline, I will just link to other forum posts with as they are available.

1) Small Electronics: http://photomacrography.net/forum/viewtopic.php?t=25781

...
Last edited by nucleobyte on Tue Dec 16, 2014 11:22 pm, edited 4 times in total.

ChrisR
Site Admin
Posts: 8668
Joined: Sat Mar 14, 2009 3:58 am
Location: Near London, UK

Post by ChrisR »

Great! :smt038 Watching with interest! I'm sure others will too.

Guido
Posts: 333
Joined: Wed Jun 08, 2011 1:02 am

Post by Guido »

Nice work!

BugEZ
Posts: 850
Joined: Sat Mar 26, 2011 7:15 pm
Location: Loves Park Illinois

Post by BugEZ »

Optocouplers for camera control are an excellent choice. That is an improvement compared to my home built controller which interfaces the camera's shutter release via pins on the microcontorller with only resisters to avoid coupling unwanted signal levels into my camera.

Keith
Aloha

abpho
Posts: 1524
Joined: Wed Aug 17, 2011 7:11 pm
Location: Earth

Post by abpho »

Nice work. A very clean DIY project.
I'm in Canada! Isn't that weird?

Guido
Posts: 333
Joined: Wed Jun 08, 2011 1:02 am

Post by Guido »

In stead of an optocoupler you can use an ir led to command the camera wireless.
If you don't like to programme the ir code you can use a Gentled.
The Gentled can work as a servo but also as a digital switch.

Rylee Isitt
Posts: 476
Joined: Fri Apr 13, 2012 3:54 pm
Location: Canada
Contact:

Post by Rylee Isitt »

Nicely done, I see lots of folks doing this now. Giving Stackshot some mild heart palpitations, perhaps ;)

I made a controller a few years back, have been continually revising it. For what it's worth, I found motor controller boards to be more hassle than they were worth. I ended up using a plain old L293D. It can drive some pretty powerful steppers and the code is not difficult.

Bonus: it can also drive DC motors/gearmotors, servos, etc. Good for when you want your project to also work sliders, rotating stages, barn door equatorial mounts, and whatever else you might stick a camera and motor on.

You have focused much more on the hardware end of things here than I did, I left that up to the user to figure out the mechanics of it all. But perhaps you might find some inspiration in my project: http://www.ryleeisitt.ca/articles/build ... ontroller/

My software is open source (although I've yet to add the license in there officially). If you use any of the code, all I ask is that you make note of the source in your code. Of particular interest to you may be the stepper motor function that includes the waveforms necessary for driving a stepper in full-step and half-step mode.

I am working on adding an IR transmitter for wirelessly triggering cameras. It's actually very easy... all you need is a sufficiently powerful IR led, a transistor, two resistors, and the protocol. Because you are pulsing the LED, you can drive them at high current - in the datasheet will be a graph of permissable current versus pulse time at different duty cycles. I am driving my LED at 700 mA which is suitable to trigger the camera even without direct line-of-sight (I have white walls/ceiling so the IR light bounces around a lot). For Canon cameras it's been extremely easy, because the protocol is literally just a burst at a certain frequency repeated twice, with a specific delay between the bursts. Unfortunately my lack of Nikon et al. equipment means it will be a bit harder for me to code and test the transmitter for other camera brands.

I use reed relays to trigger the camera shutter when I used it with a cable. This works extremely well. The relays are rated for several million actuations, I believe. So theoretically they may wear out in my life time... but soldering in some replacements if they do wear out would be very easy. They do a pretty good job of isolating the camera from potential voltage/current. However, I do think optocouplers are slightly better there. Technically I think a reed relay could arc if something bad were to happen (eg, if I accidentally dropped a live 120V cable on my open project box, I might fry my camera).

GemBro
Posts: 261
Joined: Wed Aug 20, 2014 5:20 pm
Location: Surrey [UK]

Post by GemBro »

Lovin' this ... the plates for tidy up are well done ... looks professional ... I still need to do that to my Olympus CH ...

Great idea for the cogs on the fine focus ... my stepper is a bit wobbly at the moment ... I need to sort that out but the stacking works ok but just moves a bit and the geometry shifts slightly ... I got a bolt that screws directly in to the fine focus knob thread (like Rylees's setup) which in turn couples to a coupler to the stepper ... could be that ...

I'll be posting my 'Stepper Stacker' soon ... so I'm watching this thead with great delight ...

Well done on a brilliant DIY project nucleobyte ... you gonna do a video showing it in action? ...
Canon 550D(T2i) ML (Nightly Builds) | Canon 5D MKII | Raynox 250 | Palinar 35mm f2.8 (reversed) | EL-Nikkor 50mm f2.8 N | EL-Nikkor 50mm f4 N | EL-Nikkor 50mm f4 | Bellows | Objectives: LOMO 3.7x 0.11 : 8x 0.20 : 40x 0.65
RiG II - 'Bamboo': Olympus CH Focus Block with Inverted Arca/Swiss | Canon 430 EX (x2) | Olympus T20 flash (x2) | Youngnuo YN-622C Wireless triggers (x3) | Ikea Jansjo 3W LED Lighting (x3)
Stepper Motor Focusing System (Helicon Remote)

nucleobyte
Posts: 51
Joined: Sun Aug 22, 2010 8:00 pm
Location: Virginia, USA

Post by nucleobyte »

Thanks for all the comments folks. I'm still working on getting stuff posted here. The project is currently functioning for my purposes so I'm mostly working on packaging and waiting for some connectors to arrive. I have thought of trying to make a video at some point, but my best camera for video has to be in the video...

A couple of you mentioned using the IR receiver. That would probably work fine, however the direct cable was easy, cheap and reliable, and I need to run a cable for motor control to the stacking assembly anyway.

Rylee, you have a nice project going there, I somehow missed that in my research. I doubt Stackshot is too worried. The amount of work for DIY solutions is probably too great for many people to be cost effective.

Funny you mention the L293D driver, I have a board based on that chip prototyped and will probably swap out the Linistepper eventually. I went with higher power stuff initially because some of the impetus for this project came out of another project - I'm working toward a small 3-axis CNC router build.

I'm happy with the optocoupler solution too. I almost just used a couple of transistors to do the switching, but since I had the optocouplers and the camera is by far the most expensive part of the setup, I though it would be a good idea to protect it from any potential disasters in the rest of my electronics. :D

Rylee Isitt
Posts: 476
Joined: Fri Apr 13, 2012 3:54 pm
Location: Canada
Contact:

Post by Rylee Isitt »

I like your solution, definitely. It is often the DIY part of this hobby that keeps me coming back to it. Mixing a bit of photography, science, and engineering to me is the perfect trifecta :)

The only reason I'm leaning towards an IR transmitter in some instances is that I recently couldn't resist the insanely cheap price on a Canon EOS M, which, for reasons I cannot fathom, doesn't have a wired shutter release port. For macro is seems a great camera because its main weakness - slow AF - doesn't matter anymore.

Regarding optocouplers vs reed relays... I remember trying to make up my mind about both and actually picking reed relays over optocouplers for some reason. It might have just been complexity... the reed relays don't need resistors because the winding resistance limits the current, and they still respond quickly enough (double digit milliseconds to go from open to closed).

The L293D runs nice and cool with even pretty botched heat sinking, even in a closed case. I am driving a stepper that uses about 740 mA at peak, which is probably double what those little pancake steppers draw (although the pancakes are very suitable for fine focus knobs). Still, no heat issues at all.

The great thing, too, is that with the massive rise in the popularity of 3d printers... good, inexpensive stepper motors are just getting easier and easier to find.

Regarding microstepping... I have heard that it is pretty inaccurate for fine positioning unless you use a position sensor to make it closed-loop. On the other hand, you could achieve much the same by physically gearing down a stepper. So what's the allure?

Post Reply Previous topicNext topic