Starting a stepper motor project, need one question answered regarding travel limits

wapo54001

Senior Member
I'm building a picaxe-controlled macro rail system for my camera.

The linear guide & stepper (1.5amp per phase) is here
https://www.ebay.com/itm/322895892356

The controller board is here
https://www.sparkfun.com/products/12859

The Picaxe version TBD once I figure out what I need in the way of input/output, display, etc.

Here is my question (just learning about stepper motors): Is there a reliable way to avoid using limit switches at the ends of travel to stop the motor at the end of available travel? I have seen examples of switches/sensors used for this purpose but I have space problems and in any event would much prefer an elegant software solution whereby the motor seeks to a limit when first turned on and then retains that position in memory and indexes all other operations off that one identified limit and never touches a limit again until the next indexing operation. Total available travel is 50mm -- plenty for high magnification macro photography, but no extra space for sensors.

I have read in several places that it's hard to damage a stepper by hitting a hard stop to index as long as it's at low speed and low current, but there's a lot of misinformation out there and I don't trust the information without confirmation. Hoping someone here can give me some confirmation or otherwise. The system will be moving perhaps 2~3 pounds of camera -- not necessarily on a level plane -- and the motor is rated at 1.5 amps per phase, and the driver board is good up to 2.0 amps per phase without heatsink.

Thanks in advance.
 

oracacle

Senior Member
in theory you should be able to detect a change in current draw from the motor.
there are actually stepper motor drivers that do this for you. Pretty sure the TMC2130 can do. however to get it to run like that requires the use of an SPI interface, something I have not played with as yet. These driver are often used with CNC machines and 3d printers often with express purpose pf sensor-less home and the x and y axis.

if you don't want to go the with a different different driver then maybe hack the sense resistor on your chosen driver and have the picaxe look for a spike in the voltage to indicate a increase in current draw from the motor,
 

bfgstew

Senior Member
A simple proximity sensor/switch for home position is the way to go. Program as home position and it should know where it is, as long as programmed correctly. End of use 'go to home', zeros everything ready for next run.
Work out how many steps to reach end of travel, use this as a travel datum and you shouldn't hit the ends! The elegancy is in the program, you can get steppers to sing if you really wish.
The old saying is keep it simple.
Good luck.
 

inglewoodpete

Senior Member
A simple proximity sensor/switch for home position is the way to go. Program as home position and it should know where it is, as long as programmed correctly. End of use 'go to home', zeros everything ready for next run.
Also need to add a call to 'go to home' in the startup routine, to be sure you're using the correct reference point. The system may have powered down unexpectedly in its previous use (eg Power/battery failure or unexpected reboot).
 

oracacle

Senior Member
Also need to add a call to 'go to home' in the startup routine, to be sure you're using the correct reference point. The system may have powered down unexpectedly in its previous use (eg Power/battery failure or unexpected reboot).
my macro rail does exactly that but with end stop switches.
 

Circuit

Senior Member
The TMC2103 drive can do what you want - it detects stall currents and will report back to the PICAXE chip; the downside is the 103 page datasheet! This is a challenging little chip to choose if you want to use the advanced features.
Stalling stepper motors against end-stops without stall current detection is a pretty ugly way of doing things and with higher power stepper motors (which you are using considering the weight of your camera on a non-level plane) makes things difficult. The best way is the optical gate end-stop. You do not need switches; just a simple optical gate at one end of travel. Plenty are available; I often choose the Sharp GP1S094HCZ0F because of its small size - just 2.6mm thick. VERY easy to use especially if you use a PICAXE pin with 'pull-up' available; then you can miss out the connection to Vcc with the resistor RL in the diagram below, connecting the device directly to the PICAXE pin.

photointerrupter.JPG

From a programming point of view, on power-up check the status of the optical end-stop. If it is not active then start stepping towards it with a do-while loop until the end-stop is triggered. From there you can step away backwards and forwards until the next power-down and restart or make occasional references if your system may lose steps for any mechanical reason. This way you only need one end-stop.
 

BESQUEUT

Senior Member
I have read in several places that it's hard to damage a stepper by hitting a hard stop to index as long as it's at low speed and low current, but there's a lot of misinformation out there and I don't trust the information without confirmation. Hoping someone here can give me some confirmation or otherwise. The system will be moving perhaps 2~3 pounds of camera -- not necessarily on a level plane -- and the motor is rated at 1.5 amps per phase, and the driver board is good up to 2.0 amps per phase without heatsink..
This is true. You can drive the stepper at low speed and low current using PWM. So you can send as many pulses as necessary to be certain to hit the hard stop, and this will be your starting point.
If the thing is close to the hard stop, it will buzz some time, but no damage as long as the current is low.
Of course, when you do a "soft stop" it is preferable to land on the opposite side. So at next start, the thing will travel to the reference point without buzzing to much.
 

wapo54001

Senior Member
Yes! Actually, the idea of moving the object rather than the camera never occurred to me but it solves some stick problems and I will think about this carefully. Thanks!
One downside that occurs to me -- also need to connect to the camera for automatic shutter, so this approach would require wires going to several locations . . .
 

wapo54001

Senior Member
Stalling stepper motors against end-stops without stall current detection is a pretty ugly way of doing things and with higher power stepper motors (which you are using considering the weight of your camera on a non-level plane) makes things difficult.
The driver board I've selected does have a system to cut power when the sense resistors report high current -- it cuts power, waits, then resets and then cuts it again if the short persists. They guarantee the driver chip will not be harmed with continuously shorted motor or power cable which I think is the equivalent of being up against a stop. Only thing is, it does not have the capability to report back to the Picaxe that this condition exists, so I see myself manually running the motor to the stop and then noting motion has ended and manually telling the Picaxe that the stepper has reached a limit. The board is so simple otherwise I feel it's a cheap compromise to do this manually once in a while -- since no one has suggested a more elegant solution. I'll try the optical solution if this doesn't work -- but really, I don't want to complicate the mechanical design at all.
 

bfgstew

Senior Member
If it was me, I would fit a micro limit switch at your 'home' end, hook that up to the Picaxe. You know the length of travel, you know how many steps per rev, you know the pitch of thread.....once it has reached 'home' you can reset it zero every time, no need to monitor current draw etc etc.
I have a return home button, any jams or the like, I press that, it returns, resets itself and away you go again, can't get much simpler imho.
 

wapo54001

Senior Member
you wont need a large motor to move the camera. mine runs a NEMA 17 and will lift the batter part of 20kg
here's the complete project thread
http://www.picaxeforum.co.uk/showthread.php?25841-New-macro-Rail&highlight=macro+rail
Very interesting! It appears you built your rig from the bottom up; I am wanting to kludge together pre-built pieces to achieve a similar result with much less work. :)

My rail is rated to vertically lift about 4.5kg, so I think it's about right, but the 50mm travel is beginning to look too short to cover all my needs -- now looking at a CNC rail with 200mm travel which I believe will be ideal for subjects at lower magnification, say a flower at 1:1 which is where my main interest is. I have an 80mm macro primary lens with which I have been converting a lifetime's negatives to digital, and now want to use it to branch out a bit and do some "pretty" photography as well as the high magnification stuff.
 

bfgstew

Senior Member
Rather than move the camera and lens which is rather heavy, so need bigger gear to move it, why not move the subject, this would need lighter more managable stuff.
I must admit the 50mm travel did ring alarm bells slightly, 200mm would give you so much more scope.
 

oracacle

Senior Member
While moving the subject sounds good on paper, it's not always practical. I shot a tiny mushroom once which looked lovely in its natural habitat. Moving it not only would have ruined the shot but also stopped other from enjoying it and it's future propagation.
 

wapo54001

Senior Member
The driver card I referenced in my first post makes 5VDC at up to 75ma available for external use. That would be more than enough for a picaxe, but if I include a display and a keypad etc, it becomes a question mark.

As I see it, my options for control are:
1. Design a hand-held control box containing the Picaxe, an input method and display (for parameter confirmation) with a connection from the hand-held Picaxe to the motor driver board mounted at the motor with appropriate control lines.
2. Design the motor driver board and picaxe board to be co-located at the motor and have a separate control device (custom, android phone, Sony remote) connected via IR or wire or Bluetooth. Simple IR is one-way, so the display would have to be located with the Picaxe controller.

The android phone seems most elegant -- built in display, usb or bluetooth output -- if I can find the requisite programmable android software and a good way to connect the android to the picaxe. Has anyone investigated these options for some project and found a good android program that I could set up or modify to meet the needs of this control?
 

Circuit

Senior Member
While moving the subject sounds good on paper, it's not always practical. I shot a tiny mushroom once which looked lovely in its natural habitat. Moving it not only would have ruined the shot but also stopped other from enjoying it and it's future propagation.
Slight deviation, but still the same theme of macro-photography. I have had focus-stacking racks and so forth but today I just pick up my Panasonic TZ200 (new model released in June) and use the built-in focus-stacking which works superbly. The camera is a compact camera with a 1" sensor so plenty of sensitivity and resolution but its party trick is to be able to macro-focus 30mm from the lens, take a heap of photos at various focal positions and then merge them together - in camera - to produce a fully-focussed focal-stack image. It enables me to do macro focus-stacking anywhere and I leave my focus-stacking rack back in the cupboard. It is truly astonishing and enables me to go to the subject rather than trying to bring the subject into the studio with all that entails - most often the death of the subject!
 

oracacle

Senior Member
There is a piece of software called Helicon that does the same thing but with just about any SLR and with the residing of focal distance too
 

wapo54001

Senior Member
There is a piece of software called Helicon that does the same thing but with just about any SLR and with the residing of focal distance too
Only useful with Canon and Nikon DSLRs (sadly, mine is a Sony mirrorless and Sony does not make focus control accessible externally). But between the Helicon site and hearing about newer digital cameras with the capability built in, I'm not sure why exactly I'm pursuing this particular capability with a motorized linear track! The one good reason could be using my dedicated 80mm macro lens which produces amazingly sharp images which would need a motorized track. I'll proceed to test with the parts I've acquired but depending upon what I find as I look into it further, it might not be worthwhile to proceed. Has anyone ever connected a stepper motor to a lens focus ring to brute-force lens focus control? The change of focus per degree of ring rotation is not linear, so that would also have to be taken into account but at least with my macro lens, the lens does not physically move in-out as the focus changes.
 

wapo54001

Senior Member
https://www.wexphotovideo.com/blog/tips-and-technique/how-to-use-focus-stacking-for-landscape-photography/

But it looks like a lot of fuss and Photoshop!

However, if I were richer, I would buy the Lumix TZ200 at c. £750

And if I was really rich, the Nikon D850 at £3500 +

I'll dream on. :-(
I've come across a $12 program called Elements+ which you install on top of Adobe Elements ($68) which gives you one-touch stacking. I'm a long-time GIMP user 'cause it's free, but this capability may drive me into the arms of Adobe because these two programs together also provide some very convenient RAW capabilities that I dont currently enjoy. Apparently Adobe Elements has many features which are available in the more expensive programs present in Elements also but hidden, and the Elements+ program simply makes them accessible.
 

Circuit

Senior Member
Only useful with Canon and Nikon DSLRs (sadly, mine is a Sony mirrorless and Sony does not make focus control accessible externally). But between the Helicon site and hearing about newer digital cameras with the capability built in, I'm not sure why exactly I'm pursuing this particular capability with a motorized linear track! The one good reason could be using my dedicated 80mm macro lens which produces amazingly sharp images which would need a motorized track. I'll proceed to test with the parts I've acquired but depending upon what I find as I look into it further, it might not be worthwhile to proceed. Has anyone ever connected a stepper motor to a lens focus ring to brute-force lens focus control? The change of focus per degree of ring rotation is not linear, so that would also have to be taken into account but at least with my macro lens, the lens does not physically move in-out as the focus changes.
I think perhaps you have chosen the least capable toy for focus stacking macro work with the Sony. Some Panasonic and Olympus SLRs also have built-in focus stacking within their firmware and, as you say, there is external control software available for Nikon and Canon SLRs.
 

wapo54001

Senior Member
I think perhaps you have chosen the least capable toy for focus stacking macro work with the Sony. Some Panasonic and Olympus SLRs also have built-in focus stacking within their firmware and, as you say, there is external control software available for Nikon and Canon SLRs.
Well, the purchase of the Sony was purpose specific about seven years ago -- to copy negatives and slides in very high quality -- and the mirrorless operation and other capabilities served very well with about 15,000 images transferred. I didn't choose it for stacking, so it doesn't have the stacking capability built in. The camera and specialty lens cost well over $1k at the time so I'm not going to dump them just so I can have the latest and greatest gadget. I think I'm going to be crazy and see if I can't find a way to physically connect a smaller stepper motor to the focus ring of my macro lens. Maybe a stepper with feedback built in. The focus travel of any lens is non-linear, but I think I can count steps between distances and program the picaxe to change the step count based on the location in the focus range. You can do that with a series of adjusted straight line formulas for various points on the focus travel, or maybe there is a better mathematical way to make the adjustments. The challenge will be the physical interface -- belt or roller wheel or ?? I'll stick with the rail with 50mm travel for high magnification macros.
 

Circuit

Senior Member
Well, the purchase of the Sony was purpose specific about seven years ago -- to copy negatives and slides in very high quality -- and the mirrorless operation and other capabilities served very well with about 15,000 images transferred. I didn't choose it for stacking, so it doesn't have the stacking capability built in. The camera and specialty lens cost well over $1k at the time so I'm not going to dump them just so I can have the latest and greatest gadget. I think I'm going to be crazy and see if I can't find a way to physically connect a smaller stepper motor to the focus ring of my macro lens. Maybe a stepper with feedback built in. The focus travel of any lens is non-linear, but I think I can count steps between distances and program the picaxe to change the step count based on the location in the focus range. You can do that with a series of adjusted straight line formulas for various points on the focus travel, or maybe there is a better mathematical way to make the adjustments. The challenge will be the physical interface -- belt or roller wheel or ?? I'll stick with the rail with 50mm travel for high magnification macros.
I used Elements + and stacking with my Canon 5DIII before I bought the Panasonic ZD200 earlier this year. The focus stacking in the modified Photoshop works extremely well and this should serve you nicely; to work well, though, you need a pretty capable processor and lots of RAM otherwise the stack merge takes an absolute age. Recording the images at the lowest reasonable pixel-count resolution helps matters enormously in this respect. A stepper motor + PICAXE can easily handle non-linear focus travel; that should be very easy to do as you say simply by programming the number of steps between each shift. I would recommend using a belt drive with pinch rollers to set the degree of grip as per the diagram below. That way you can mount the motor rigidly on the stand and adjust the grip on the lens with the pinch rollers (red arrows)

pinch rollers for lens drive.png
 

Circuit

Senior Member
Perhaps not... consider that the stepper motor will need a reference point to start from - effectively an electronic end-stop so we are back with the discussion that started this thread in the first place. Now consider that you need to ensure that the stepper motor does not bring excessive force on the lens ; I certainly would not be enthusiastic about using a motor stall approach on a much treasured Sony macro lens. The advantage of using the drive belt approach is that you can release the pinch rollers, set the lens to whatever reference point you wish be it infinity or close and then start the power-up with the stepper assumed to be at zero reference no matter where it stopped last time you powered down. i.e. there is no need for end stops or limits. From a hardware viewpoint all that you need is a single GT2 pulley and a toothed belt of the right diameter together with a couple of free-running rollers which could be as simple as two ball-races stacked on top of each other and then bolted to the carrying plate.
 

oracacle

Senior Member
the solution may well be to use a shaft encoder. It would also be useful to be able to put the lens into the setup "homing" the focusing ring to the mechanics.
 

wapo54001

Senior Member
Oh, my, therre have been major changes since the last time I researched camera solutions!

There is now a semi-standardized system called "follow focus" intended for the video crowd which has a variet of ways to access the focus ring of a dslr camera. Mostly, they use large manual knobes, levers, or extension cable knobs to make video focusing smoother and more accurate. But, these mechanisms which are available in a huge variety of price points, look absolutely perfect as the foundation for the system I have in mind.

I think a follow focus system with nema 8 motor (20mmx20mmx38mm) could be compact and precise. All the brains would live in the Picaxe. (BTW, my focus ring has no hard stops, so Id just turn the ring to infinity and set the point in the Picaxe program as starting point.)

Main question in my mind: do I use the follow focus mechanism which would have the motor at right angles to the lens, or just the FF mount and have the motor gear aligned with the focus ring. The devil is in the FF mechanism details.

Also, wondering what kind of torque a NEMA 8 can produce. 5.5V @300ma is the smallest motor I can find, so if used directly against the focus ring the motor gear would have to be at least perhaps 30mm in diameter and perhaps 40mm to extend adequately beyond the edge of the motor. Having no experience, I have no understanding of the force specifications of the various motors. Can anyone help with that?

Also was reminded that the best optical solution would be to add spacer rings between the body and the macro lens. Starting out at the default 1:1 provided by the lens, adding 12-, 20-, and 36mm rings should get me easily into the 1:5~1:10 range. I'd lose focus (done externally) and aperture (default to lens f2.0), but in this situation, that's fine.

Everything fits on the 15mm tubes with 60mm spacing which has become a standard while I wasn't looking, and there are a bazillion components and mounts that fit these tubes.

I think I will be able to spend less time on hardware and more time on software than I originally imagined, and the moving-lens-on-a-cncrail system seems to be going the way of the dodo.
 

wapo54001

Senior Member
I have completely abandoned the precision track solution that I originally envisioned. As it turns out, the up-to-date way to layer macro photos of different focal planes is not to move the camera and leave the focus fixed, but to leave the camera fixed and move the focus.

Attached is a photo of my current hardware solution in progress. The gear attached to the focus ring is a custom gear made by followfocus.com ($50), the stepper is a 200-step nema 8 with 4mm shaft ($14), and the highly adjustable mounting hardware consisting of tripod mount, camera mount, and auxiliary bracket are all standard camera mounting hardware from Amazon which in total cost about $25.

I have asked followfocus.com to build the drive gear which must be about 1.25" diameter and if they demur I will use RC car gears which are of the right tooth size but the face of the gears is rather narrower than I want. The camera gear face is 25mm and I anticipate the drive gear should be about 15mm. The gear ratio will give me about 600 steps for full focus rotation, and if need be, I can use additional picaxe outputs to reduce the step travel down to fractions of a step although I can't image needing to do this.

The tiny stepper driver board is ready=made from sparkfun and will require only pulses from the picaxe to move the stepper. The picaxe will keep track of where the focus ring is in its rotation, etc. The question that originally started this thread is moot because the focus ring on this lens does not have hard stops at all.
 

Attachments

Top