How to build a focus stacking controller

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

Moderators: Pau, rjlittlefield, ChrisR, Chris S.

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

How to build a focus stacking controller

Post by Rylee Isitt »

I have written an article on building a compact Arduino-based focus stacking controller. It's hosted on my personal website. It's not for profit, and everything is there - schematics, software, and build notes. Hopefully people find it useful!

At the moment, it is not linked to from the rest of my website, since I'm writing a few more articles before I add the new section. So I guess you have some temporary exclusivity over here :)

Please do comment - here or there, or PM me - if you notice any errors. I've gone over it carefully several times, but there are always things I miss...

g4lab
Posts: 1434
Joined: Fri May 23, 2008 11:07 am

Post by g4lab »

I am in a hurry and only just scanned it briefly and not even the whole thing.

What a superbly presented and documented project!!! You are to be congratulated. Thank you!!

Charles Krebs
Posts: 5859
Joined: Tue Aug 01, 2006 8:02 pm
Location: Issaquah, WA USA
Contact:

Post by Charles Krebs »

Rylee,

Gene said:
What a superbly presented and documented project!!!
I could not agree more. Well done!

Planapo
Posts: 1533
Joined: Tue Nov 07, 2006 2:33 am
Location: Germany, in the United States of Europe

Post by Planapo »

This is very helpful, Rylee, thank you very much for putting it together and sharing!

Usually, I shy away when DIY projects seem electronically too complicated to me, but you've presented it so nicely step-by-step that even I, with some assistance :oops:, are tempted to have a go.

Thanks much again. :D

--Betty
Atticus Finch: "You never really understand a person until you consider things from his point of view
- until you climb into his skin and walk around in it."
Lee, N. H. 1960. To Kill a Mockingbird. J. B. Lippincott, New York.

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

Post by Rylee Isitt »

Thanks everyone for the wonderful comments!

Planapo, I am glad that you are tempted to try this! The hardest part for me was decoding the IR remote. It is also arguably the most technical and unaided part of this project.

I guess soldering technique is pretty important, too. There are lots of solder connections, and they all need to be nice and neat. Keeping the iron tip properly tinned and clean is a huge part of the technique. An oxidized tip is just terrible to work with.

But otherwise, the parts are reasonably plug-able. Just pay attention to voltages, currents, and polarity. The Arduino really makes life much easier. When I discovered micro-controllers, it was revelatory... it opens up a whole new world of rather complex projects that are software-driven rather than hardware-driven. Personally, I'm better with software than hardware, so I liked that :)

Chris S.
Site Admin
Posts: 3544
Joined: Sun Apr 05, 2009 9:55 pm
Location: Ohio, USA

Post by Chris S. »

Bravo, Rylee!

What you've done here--both in development and sharing--is phenomenal; a huge contribution.

I think this work stands out both in the Arduino community and ours. For those not familiar with the Arduino development community, it is very sharing oriented. But rarely (so far as I've seen) does anybody communicate as clearly or thoroughly as Rylee has done here, let alone about a project as soundly developed as this. And in our photomacrography community, it greatly advances what has been shared about DIY stepping controllers.

I've been working with/learning about microcontrollers too, but Rylee, you are way ahead of me. So please pardon this question: What led you to choose not to use one of the motor shields available for the Arduino--would one have made your work easier and perhaps opened up additional options?

Again, way to go, Rylee.

--Chris

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

Post by Rylee Isitt »

Chris,

Thanks for the comments! Do you think I should post a link in the Arduino forums? I don't have an established presence over there though, and don't want to post-and-run.

I remember looking at the official motor shield and was not convinced it was worth it. They are more expensive than a $3.50 quad half-H-bridge chip (which adds up to a dual H-bridge, same as the shield), and not a whole lot easier to use. In terms of cost, compactness, and learning experience - the shield looses hands down.

Where the shield wins is in terms of features, but those features are unnecessary for this project, and end up translating into unnecessary bulk, code, and memory usage.

The shields are also not compatible with all Arduinos, or other microcontrollers, unless you use jumper wires to connect the pins (what a mess!). You could keep my circuit as designed, and use entirely different microcontrollers, or things like the 3.3V Arduino Pro Mini with fairly minor tweaks. It's just more flexible this way - call it a design decision!

geetee50
Posts: 91
Joined: Tue Mar 06, 2012 1:23 pm

Post by geetee50 »

Great post Rylee, I've been looking into building one of these over this winter, if i attach the motor direct to a digital micro meter do you think it would give me half micron steps?

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

Post by Rylee Isitt »

geetee50 wrote:Great post Rylee, I've been looking into building one of these over this winter, if i attach the motor direct to a digital micro meter do you think it would give me half micron steps?
The stepper I use is 3.6 degrees per full step, and can do fairly nice 1.8 degree half-steps as well. To figure out how many micrometers that is, you'd have to do a little math. Take the micrometers of movement per full revolution and divide it by 200, and that's the smallest resolution you can get with most stepper motors that are not geared.

One thing I came to realize near the end of my build was that my stepper motor - the Portescap 44M100D2B - just barely does the job. It worked in my LEGO apparatus very well because it was hooked up to a gear train that massively increased its torque.

But hooking it directly up to a focusing knob is hit and miss. I got it to work with my BHMJ only after removing a tension washer from the knob. I suspect it would turn the knob of a digital micrometer, but I don't know for sure. It would definitely turn the fine focus knob of most microscopes, but the BHMJ is pretty stiff and I don't know how stiff your micrometer is. A potential option is to use sprockets and a timing belt to gear the motor down to both increase the torque and decrease the step size. Put a small-radius gear on the stepper and a large-radius gear on the knob. The downsize is that it will move pretty slowly. These motors can only go so fast, and gearing down will make that even more obvious. During stacking that won't be a problem at all, but if you want to move your specimen/camera by quite a distance, it might take a minute (unless you just do it by hand).

It might be worth it to shop for a more powerful stepper, and attach a heat sink to the controller chip. My plan is to buy a new, more powerful stepper motor, test it out, and change my recommended part number / stepper specs.

geetee50
Posts: 91
Joined: Tue Mar 06, 2012 1:23 pm

Post by geetee50 »

The motor i wanted to use is the screw type but its 5v and 2.4w, my stage has a tension spring that i can adjust to drop the tension and turning the meter requires little torque even when the spring is wound up.

Image

I've fitted a large wheel to allow fine turning and this can accept a belt or even cogs to allow for gearing so should work out with the right motor but i think my motors voltage may be an issue so was thinking of going for a standard motor fitted like yours or side on and with a belt.

Image

What i was hoping would happen is when the programe was set up, what i set in control box is confirmed though the movement of the micro meter so if i had gearing issues i would have a confirm of movement as i changed settings.

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

Post by Rylee Isitt »

That looks like a linear actuator stepper - meant for directly moving things back and forth (so good for directly moving a platform back and forth, but not so much for turning a knob). That said... you could turn a knob with anyway. Might as well try!

The Arduino UNO recommends 7V-12V input voltage, and no lower than 6V, so you can't run the Arduino UNO on 5V. But you could power it with 12, and then use its 5V supply for your motor. The Uno's 5V pin can apparently handle about 650mA.

Your motor seems to peak at 480mA if I understand your specs correctly (I am assuming that 2.4w is the peak, not an average or anything).

Another option is to not use the UNO. The Arduino Pro can operate off of a 5V supply! It's a bit more of a DIY situation, though... requiring a separate little FTDI cable or breakout board for programming, but otherwise... it seems like it would be very easy to adapt for this project.

You can also just buy the chips. I am led to believe that it's actually reasonably easy to use the bare-bones chips with very minimal external components, in which case you can get the 5V chip and supply it with your own regulated power source.

So - I think your motor might work! The question is... will it have enough torque?

geetee50
Posts: 91
Joined: Tue Mar 06, 2012 1:23 pm

Post by geetee50 »

The Arduino UNO recommends 7V-12V input voltage, and no lower than 6V, so you can't run the Arduino UNO on 5V. But you could power it with 12, and then use its 5V supply for your motor. The Uno's 5V pin can apparently handle about 650mA.
Nice one! i think i may try this option first and remove the micro meter as origanly my linear motor was intended to sit in it's position, if i have no joy with torque then go for a cognisys type motor and place it across from the meter and link via a belt.

Thaks Gary

Chris S.
Site Admin
Posts: 3544
Joined: Sun Apr 05, 2009 9:55 pm
Location: Ohio, USA

Post by Chris S. »

Rylee Isitt wrote:Do you think I should post a link in the Arduino forums? I don't have an established presence over there though, and don't want to post-and-run.
Rylee, yes, I think you should. Not only will your work be of interest there, but your communication approach will help raise the quality level of future documentations. Just watch--I bet you'll see aspects not only of your mechatronics showing up in other people's work, but also aspects of your documentary technique.
. . .unless you use jumper wires to connect the pins (what a mess!).

Dumb as it sounds, my tolerance of jumpering became much higher after I discovered the "premium female/female jumper wires" at Adafruit. I bought a selection of them, along with a bunch of "premium male/male jumper wires" from the same source. These are a substantial enough improvement over other jumpers I've used that jumpering doesn't seem like such a mess as before.

Not sure I'm right about this, but my sense has been that using a motor shield can make the controller somewhat more agnostic about what stepping motor one uses? If so, as you said, a design decision.

--Chris

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

Post by Rylee Isitt »

Hi Chris,

Somehow I missed your last comment.

Regarding shields, I generally dislike them. They make things easy, at the expense of pretty much everything else. There are times I use them, but I am almost always frustrated with poor documentation, extremely feature-limited libraries, and unnecessary complexity. The added ease must be very high before I consider them worth it. A motor controller is a fairly simple thing. Yes, it can be made more difficult and feature-rich with things like microstepping, and programmable current limiting, but for a project like this that's all overkill.

I know exactly how my motor controller works, and can diagnose and solve hardware issues with ease. I can swap out the chip with others if needed, for example to support more than 1200ma motors. It's much harder do that with the motor shield since you'd be dealing with surface mount components, and last I checked, the library was very limited. For example, there was no apparent way to select between full and half stepping. You could write your own code, but figuring out how to interface with a device you didn't build will be harder than working with a device you known inside an out. My motor controller is a single chip (I don't count the shift register, since it's optional), with a simple architecture that could be replicated with transistors if you wanted to. It's easy to build, flexible, and doesn't assume that you have a specific Arduino board. But your mileage may vary...

I made some major software changes to this project recently which greatly increase its usability (eg, non-volatile configuration set through the UI). I also got a new stepper, and some timing pulleys and belts, so I will probably update my guide slightly. I recently ran a much higher powered stepper (drawing about twice the current of my pancake stepper) for 45 minutes, with no heat issues. I am very happy, but now I'm waiting on some M3x25mm screws to arrive from the US so that I can attach the timing pulleys to my BHMJs.

Edit: revised my comments to clean up some hurriedly-written stuff (I was on a smartphone with a fairly bad keyboard!)

Post Reply Previous topicNext topic