Forgot Password
Pentax Camera Forums Home
 

Reply
Show Printable Version Search this Thread
2 Likes  #1
DIY Auto Focus Rail - Phase 1
Posted By: AggieDad, 07-31-2018, 10:52 AM

About two week s ago I bravely (foolishly?) announced on the forum I was going to build my own automatic macro focus rail.

This post is my first progress report on this project as I "march through mud" learning about the wonderful world of hobby electronics.

So far much of my time has been spent buying stuff, reading and watching videos, buying more stuff, learning to solder (soldering little, teeny, tiny, things with fat fingers and trifocal eyes – what could go wrong?), and buying even more stuff.

THE RAIL
I bought my rail about a year ago – yes, it has taken that much time to get started. It is a really nice linear actuator with a ball screw and a nice stepper motor, a shorter version of the one in this link. It has a 4mm pitch and the stepper motor has a step angle of 1.8 degrees or 200 steps per revolution. In other words, one full step will result in linear travel of just 0.02mm. Which should be plenty accurate for my macro efforts. I have since learned that the electronic stepper motor controllers will allow "micro-stepping," meaning it could step at as little as 1/16th of a full step or 3200 increments per revolution.

THE ELECTRONICS
Like everyone else who has built a macro rail, I am using an Arduino Micro Controller, an absolutely wonderful little electronic board that you can use to do all sorts of neat things by adding other little PC boards and wires and stuff to. The key additions are a stepper motor controller to (duh) control the motor and a keypad and lcd display to use to communicate with the Arduino. There are also other little bits and pieces (resistors, etc.).

When you read a writeup on how someone designed and built a rail, there is generally a parts list, and they all like to tell you how you can get everything on eBay for pocket change. When you don't know what you are doing and you are fearful some knock-off component won't work properly, you buy the stuff locally or perhaps from Amazon. Either way, the cost of the parts seems to increase almost exponentially. Then, of course, you fry something and have to buy it again. I think it is fair to say there will be little if any money saved during this project.

PROGRAMMING
Oh yeah, you gotta do some programming so the Arduino knows what the heck it is supposed to do. The last programming I did was in Visual Basic about 25 years ago. Fortunately, the Arduino folks have a great website that includes a programming tool. The Arduino uses a subset of C++ called IDE and the programming tool checks your code for errors and handles downloading it to the Arduino board.

PROGRESS TO DATE
So what I have actually accomplished? Not a whole lot, but something.

At the moment I can tell the macro rail to make a slice x mm thick, delay long enough to take a picture and give a flash some recovery time. I can specify the number of slices that will be needed for a stack so that when I start the program the rail will move, wait, move, wait, etc. until it has done so the number of times necessary for the stack. Once it has completed the stack the rail will reverse its direction and move directly back to home position.

From what I can tell with my cheap little Harbor Freight micrometer, I have an accuracy of about +/- 0.015mm per slice. That's totally acceptable for me. Some of the hardcore macro boys might find that a bit sloppy.


NEXT ON THE LIST
The very next thing will be to do some measuring tests so I can equate motor steps to actual distance. Then I will be able to enter a slice size as a measurement rather than a number of steps.

I have also figured out how to get a readout on an lcd screen and how to input from a keypad. But I do not know how to get either of these to interact with my stacking program. Dealing with that out comes after the slice size thing.

Once I have the keypad and screen interacting with program, then I will have to write the code for the inputs and outputs I will want.

That's it. A lot of words to tell you I can make a stepper motor move at my whim.

Last edited by AggieDad; 07-31-2018 at 05:04 PM.
Views: 1,338
07-31-2018, 11:23 AM   #2
Pentaxian
LensBeginner's Avatar

Join Date: Sep 2014
Photos: Albums
Posts: 4,561
Interesting thanks for sharing.
07-31-2018, 05:22 PM   #3
Loyal Site Supporter
Loyal Site Supporter




Join Date: May 2016
Location: East Coast
Posts: 1,939
Neat project. I like this type of stuff. Keep the updates coming. I often think I should turn to macro fun when the cold sets in. Rails have caught my eye, and making one is very appealing.
07-31-2018, 07:26 PM   #4
Site Supporter
Site Supporter
david94903's Avatar

Join Date: Nov 2010
Location: San Rafael, CA
Photos: Gallery
Posts: 654
QuoteOriginally posted by AggieDad Quote
I bought my rail about a year ago – yes, it has taken that much time to get started.
Don't want to rush these things, ha! Actually I think this is a great project. And like clickclick, the idea of making one is very appealing. Definitely keep us up to date, and include pictures. We tend to be a very visual crowd

07-31-2018, 09:10 PM   #5
Veteran Member
kevindt's Avatar

Join Date: Jun 2008
Location: Northern California
Posts: 322
That's a nice little project. You might want to look into micro-stepping a little further, as the movement is smoother and more controllable - especially if you use stepper control software that ramps up and down to accelerate/decelerate gently, like the Arduino AccelStepper library does. I don't know which stepper driver you're using, but most are compatible, so there is no extra cost. Your movement per micro-step is then pitch / steps per rev x micro-stepping rate = (4mm/200) x 1/16, or 1.25 microns per step for a 1/16 micro-stepping rate.

What are you using for stacking software? I've never tried macro-stacking, but I have done quite a bit of playing with these motors and Arduino or STM32 for other projects (CNC and 3D printing, mostly, and a "barn-door" for playing astro-photos).
08-01-2018, 06:45 AM   #6
Loyal Site Supporter
Loyal Site Supporter
AggieDad's Avatar

Join Date: Jan 2015
Location: Houston, TX
Photos: Gallery
Posts: 762
Original Poster
QuoteOriginally posted by kevindt Quote
That's a nice little project. You might want to look into micro-stepping a little further, as the movement is smoother and more controllable - especially if you use stepper control software that ramps up and down to accelerate/decelerate gently, like the Arduino AccelStepper library does. I don't know which stepper driver you're using, but most are compatible, so there is no extra cost. Your movement per micro-step is then pitch / steps per rev x micro-stepping rate = (4mm/200) x 1/16, or 1.25 microns per step for a 1/16 micro-stepping rate.

Yes. I do have my little project running at 1/16th steps or 3200 increments per revolution. The micro steps really do smooth it out. I actually came upon this by accident as my first stepper controller was configured for 1/16th micro steps by default.

I am looking into the AccelStepper library but have not yet included it into my code. One interesting video from NYC CNC shows more accuracy without the acceleration/deceleration I'll probably do some home experiment to satisfy myself about this.

The motor controller I am currently using is theTB6560-V2.0. It appears to be very robust with screw connectors and a large heat sink. I was using a Big Easy controller, but that has apparently cratered. I started getting any number of skips and slips after running for a short length of time it acted as though it might be overheating. The new controller runs the motor much smoother than the Big Easy right from the git-go.

QuoteOriginally posted by kevindt Quote
I've never tried macro-stacking, but I have done quite a bit of playing with these motors and Arduino or STM32 for other projects (CNC and 3D printing, mostly, and a "barn-door" for playing astro-photos).
It's good to know someone on the forum knows about Arduinos and steppers. As I stated in my previous posts, I am learning on the fly. Any thoughts, advice, or code you wish to share will be gratefully received.

Question: How much acceleration/deceleration can actually occur when the motor is running on a short cycle? Let's suppose the step is 9 degrees or 2.5% of a rotation. That's just 80 micro steps or 5 full steps. Is that enough travel for the acceleration/deceleration to occur and have an impact? I will be interested to know your thoughts on this.

Don
08-01-2018, 09:42 AM   #7
Loyal Site Supporter
Loyal Site Supporter




Join Date: May 2016
Location: East Coast
Posts: 1,939
This is a new area for me. Is the idea behind controlling the acceleration/deceleration to reduce vibration?
08-01-2018, 11:26 AM   #8
Loyal Site Supporter
Loyal Site Supporter
AggieDad's Avatar

Join Date: Jan 2015
Location: Houston, TX
Photos: Gallery
Posts: 762
Original Poster
QuoteOriginally posted by clickclick Quote
This is a new area for me. Is the idea behind controlling the acceleration/deceleration to reduce vibration?
It seems, from what I have read, the main advantage will be dependent upon the load on the motor. Right now, my motor is running free (nothing attached to the shaft) and there is no real difficulty in it moving to its programmed speed from zero. However when it is driving the linear actuator that is moving a K-3ii with bellows and lenses and clamps and other stuff, then the load on the motor will be significant. Imagine a loaded truck. It has to go through the gears; it can't just immediately go to highway speed.

I have already tested the motor on the linear actuator without the load of a camera on it and am pleased with the performance and accuracy. But I want to try the motor under load (game conditions) both with and without acceleration/deceleration before I make a decision for my project.

Now understand I am new – very new – to steppers and all of this neat stuff, so I have yet to have practical knowledge from which to draw. I welcome someone with knowledge and experience to jump in here and add, subtract, or correct my thoughts.

Don

08-01-2018, 07:51 PM   #9
Veteran Member
kevindt's Avatar

Join Date: Jun 2008
Location: Northern California
Posts: 322
Yes, that's what I believe too. I'm more used to getting a relatively heavy gantry or spindle mounting moving from stationary, getting it into place and stopping or reversing without a lot of jerking and vibration. That causes overshoot and puts a lot of stress on the tool (and the machine) due to the inertia/momentum. Gentle acceleration to a plateau speed and gentle deceleration back down is a lot smoother and less stress on everything (just like your car example). The camera is a lot lighter, and distances here are small in numbers of steps, but it's still a big jump from zero to full speed in one microstep, and if the motor's load is too heavy, it may miss steps and move too little, as well as stressing the motor. The other nice thing about AccelStepper is that it holds the home position in a variable, and that makes it easy to move repeatedly to absolute numbers of micro-steps from home and to finally return to home.

Make sure you get the current limit right for the motor you're using. It's usually quoted on the specs for the motor. Steppers are pretty voltage insensitive over a fairly wide range, but limiting the current matters, especially if micro-stepping. Those TB6560s make setting the current really easy, compared with twiddling minute pots on some of the small controllers while trying to measure voltages on test points you can barely see (I'm also in the trifocal years).
08-02-2018, 05:05 PM   #10
Loyal Site Supporter
Loyal Site Supporter




Join Date: May 2016
Location: East Coast
Posts: 1,939
Completely makes sense given the weight of the gear and the size of motors and all the pieces that inertia is an issue.

What type of torque do these motors develop? And now I'm wondering about the drives involved e.g. direct gearing or a transmission? I obviously need to go look at some of these, as some of these questions, like direct drive, can be obvious when you see them.
08-02-2018, 08:29 PM   #11
Loyal Site Supporter
Loyal Site Supporter
AggieDad's Avatar

Join Date: Jan 2015
Location: Houston, TX
Photos: Gallery
Posts: 762
Original Poster
QuoteOriginally posted by clickclick Quote
Completely makes sense given the weight of the gear and the size of motors and all the pieces that inertia is an issue.

What type of torque do these motors develop? And now I'm wondering about the drives involved e.g. direct gearing or a transmission? I obviously need to go look at some of these, as some of these questions, like direct drive, can be obvious when you see them.
Stepper motors are totally different from other DC electric motors. They are designed to rotate to fractions of a full rotation. Typically they are designed to have 200 steps to a rotation (1.8 degrees/step). Using the electronics in the motor controller, each step can be divided into smaller steps micro steps. With the controller I am using, each step is divided into 16 micro-steps for a total of 3200 micro steps per revolution. Consider that my linear actuator has a pitch of 4 mm per revolution and you can see the linear movement can be pretty small, although I am not sure as to what is a practical limit.

Here's a good primer on stepper motors that might interest you: LINK.

Don
08-03-2018, 08:25 AM   #12
Loyal Site Supporter
Loyal Site Supporter




Join Date: May 2016
Location: East Coast
Posts: 1,939
Thanks. I'm familiar with them at a high level, but I've never had any hands-on experience. Being a gearhead who's played with engines for over 40 years and also being in IT, it's pretty hard to resist getting into this. Winter and macro photography just seem like a natural pair of activities.
Reply

Bookmarks
  • Submit Thread to Facebook Facebook
  • Submit Thread to Twitter Twitter
  • Submit Thread to Digg Digg
Tags - Make this thread easier to find by adding keywords to it!
arduino, diy, do it yourself, macro, motor, move, program, rail, slice, step, stuff, yourself
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads
Thread Thread Starter Forum Replies Last Post
DIY Auto Focus Rail AggieDad Do-It-Yourself 3 07-17-2018 09:34 PM
Macro New focus stacking rail Nass Post Your Photos! 17 07-30-2017 05:30 PM
Focus Rail for 645n grhazelton Pentax Medium Format 6 01-19-2012 10:08 AM
Phase detect auto focus inaccurate fignewt18 Pentax K-5 13 11-18-2010 11:48 PM
For Sale - Sold: Pentax M42 Bellows 135mm and 35mm lens with focus rail Peter Zack Sold Items 3 08-25-2008 06:26 PM



All times are GMT -7. The time now is 10:23 PM. | See also: NikonForums.com, CanonForums.com part of our network of photo forums!
  • Red (Default)
  • Green
  • Gray
  • Dark
  • Dark Yellow
  • Dark Blue
  • Old Red
  • Old Green
  • Old Gray
  • Dial-Up Style
Hello! It's great to see you back on the forum! Have you considered joining the community?
register
Creating a FREE ACCOUNT takes under a minute, removes ads, and lets you post! [Dismiss]
Top