By continuing to use this site, you agree to our use of cookies. Find out more
Forum sponsored by:
Forum sponsored by Allendale Jan 24th


Sanity check

All Topics | Latest Posts

Search for:  in Thread Title in  
Charles Shearer 120/04/2019 15:28:29
9 forum posts
3 photos

I'd really appreciate some help with my ageing brain - what I thought was simple is causing me a lot of confusion!

I'm designing a microcontroller for an extreme macro platform using a linear rail driven by a stepper motor. I have the rail finished and the code for the microcontroller is virtually complete.

However, during early testing I found that the linear rail did not always come back to the exact same spot (I'm working in fractions of a millimetre).

The answer was obvious - backlash on the leadscrew - which I measured with a DTI as 0.065 mm. In 'full' steps ( I can microstep to 1/16th of this) the backlash is measured as 13 steps.

To describe a typical situation.

I start with all backlash taken up and move in the Forward direction.

As an example let us say 500 steps Forward.

I've overshot so I step back 10 steps in Reverse.

Still not right so I move 20 steps Forward.

Finally, I move 5 steps back.

Please ignore the obvious fact that the linear hasn't physically moved if less than 13 steps - the figures are for calculations only.

My question is how many 'real' steps Forward have I taken and do I have to cater for any 'unused' backlash at the end of my travels?

Many thanks in advance


Bazyle20/04/2019 17:22:13
5214 forum posts
201 photos

You have moved 510 steps forward. Neither of your reverses did anything.

I suggest spring loading the device in one direction sufficiently that every step in reverse does move because the spring pulls the carriage back against the screw.

Martin Connelly20/04/2019 17:27:26
1368 forum posts
159 photos

Typical method for CNC is to set up a dial indicator. Move towards the indicator until it moves a suitable amount to be sure it is off its stop and set it to read zero. This is the zero position. Reverse away from the indicator and back to zero to check zero is correctly set on the indicator, repeat as necessary.

Move forward another mm or other suitable distance to ensure the indicator moves away from zero then back to the zero position. The difference on the indicator from zero is the backlash value. If you can't enter this value into your program then calculate the number of steps to move this distance and add them to the reverse move.

Repeat the above with the backlash compensation and check the indicator returns to zero when the reverse move is made.

It is probably a good idea to reverse the direction and check backlash from the other way as well.

Martin C

SillyOldDuffer20/04/2019 18:12:44
5759 forum posts
1222 photos

Not sure if it will hold accuracy well enough for your purpose, but if you know backlash to be equivalent to 13 microsteps, then change the code to add 13 extra steps each time direction is reversed.

After making sure backlash is taken up at start, say the platform is moved forward by turning the screw 500 steps. No problem with backlash. Also, if the platform is advanced in the same direction by another 20 steps, there's no need to compensate for backlash because the screw is still engaged properly.

But when the direction is reversed backlash kicks in and the screw has to be turned 13 steps in the new direction to re-engage the screw; after that the normal move should work.

if ( directionChanged )

Adding a correction on each reversal might be 'good enough' but because the computer can't guarantee its exact position over time the platform may drift sufficiently away from it's calculated location to mess with the focus. If that happens either:

  1. Always step accurately in one direction so backlash can't intrude. When a reverse is required, return the platform to its start position, take up backlash, and move forward again, or,
  2. Add a DRO so the computer knows where the platform is and can stop at any position; this method doesn't need to count steps or know how big the backlash is.

Assuming a digital camera such that you can see the platform is out of position because of backlash, it would be possible to combine the compensate on reverse method with a manual rewind to start as in 1, at any point the operator decides a reset is necessary.


Andrew Johnston20/04/2019 19:38:01
5497 forum posts
647 photos

Oh dear, the cart seems to be in fromt of the horse. smile

Ideally one would have specified an acceptable backlash before building hardware and writing software; then one can select the hardware to achieve that accuracy, or at least get close to it. What positional accuracy do you want to achieve?

If we assume you need to move from point X to point Y and then back to point X with a given accuracy then the question arises; can you overshoot position X on the way back and then move forward to it? If so then all you need to do is step past point X by more steps than the backlash and then move forwards again to point X. It's a standard technique when machining for taking into account backlash in items like a lathe cross slide.


Michael Gilligan20/04/2019 19:59:19
15700 forum posts
684 photos
Posted by Andrew Johnston on 20/04/2019 19:38:01:

Oh dear, the cart seems to be in fromt of the horse. smile

Ideally one would have specified an acceptable backlash before building hardware and writing software; then one can select the hardware to achieve that accuracy, or at least get close to it. What positional accuracy do you want to achieve?


I'm struggling a little to understand what Charles is trying to achieve

The usual reason for using such a rail is to do stacked images, so it will be stepped through increments where each puts a plane in focus: For 'macro' work, the steps might be between 10 and 100 microns, and on the microscope [say] 0.5 to 5 microns. ... Obviously, the preferred approach is to start at one extreme and step to the other, in a constant direction.

... But perhaps Charles only wants to focus on a particular plane, and will need to 'hunt' for that point.



For the unitiated:

Edited By Michael Gilligan on 20/04/2019 20:01:18

John Haine20/04/2019 19:59:28
3080 forum posts
162 photos

If the forces involved are not great (i.e. not machining), I'd suggest making a new zero backlash nut, either using a ballscrew or a plastic nut, possibly melted to a close fit on the thread.

Also don't rely on microstepping to save you by getting more resolution, it doesn't necessarily behave as expected.

Howard Lewis20/04/2019 21:17:37
3264 forum posts
2 photos

Not into CNC, but if you know that there is backlash equal to 13 steps, then you must reverse the overshoot plus more than 13 steps so that when you move forward again, the first 13 steps will be taking out the backlash (just as you would if you were turning the dials on a manual machine. .Say the overshoot is 0.005:and you know that you have 0.020" backlash - reverse by 0.030 - move forward 0.020 to take out the backlash, then you are then 0.005 before where you want to be, so advance 0.005 to the required position.


Ian P20/04/2019 21:55:53
2380 forum posts
100 photos

Another factor that can affect repeatability is 'wind-up' or other flexibility in the drive train, or lack of rigidity in the structure. The inertia and weight of the moving carriage (plus sticktion) and the fact that stepper motors move in jerks rather than smoothly means you need very high reduction ratios

If you want to return to a specific position several times and always be sure it the same as last time then apart from always approaching from the same direction, you need to approach at the same speed and or decelerate identically each time.

As others have said it depends on what sort of accuracy/resolution you require. In general the mechanics of the system needs to have a higher specification than it would first appear.

Ian P

Michael Gilligan20/04/2019 22:04:47
15700 forum posts
684 photos

For info. ... Here is the StackShot rail: **LINK**


Charles Shearer 120/04/2019 22:35:01
9 forum posts
3 photos

Good Evening to all - and thanks for the responses. I had no idea the forum was so active!

To clarify - I am very aware of the commercial offerings for macro rails - the problem with them is the controllers are pathetic in the functionality they offer in that they expect you to do all of the Depth of Field calculations, efStops, magnification factors, CoC etc etc etc and then input the distance to travel.

I've written the code that allows you to input numerous variables via a 3.5" touchscreen tft panel - such as size of sensor, leadscrew pitch, stepper angle, microstepping, fstop used, acceleration, deceleration, flash recharge times. The microcontroller now does all the calculations such as steps between shutter actuations, effective fStop etc etc and controls the stepper movements, fires the flashes, lights etc.

I'm delighted with the accuracy of the movements, particularly when microstepping - no 'jitter' and amazing accuracy and repeatability.

To set up a 'run' I need to find the exact IN spot for the start of a run and the exact OUT point for the end of the run. This usually involves some forward / backwards movements while I study the target images and adjust the points. It is here that I'm coding in precise measurements for backlash so that when I set the aforementioned points the precise and actual microsteps for the IN and IN to OUT is calculated - even 'unused' backlash not taken up is a factor.

A straight run in one direction is achieved after the run set-up and all I need to worry about is the backlash when returning to IN if I want a repeat run.

In any event - Silly Old Duffer confirmed my over-thinking! Shame you adopted that nickname - it'd suit me nicely!

Best to all.


Michael Gilligan20/04/2019 22:48:06
15700 forum posts
684 photos

Thanks for the clarification, Charles

... I should perhaps explain that my link to the StackShot rail was by way of background information for those who might be familiar with CNC but not with image-stacking.



P.S. personally, I'm not entirely convinced that you need to find exact IN and OUT points ... I generally err on the side of caution and take a few too many shots; then just use the ones that show useful detail in some area.

... Your way of working may, of course, be different.

Edited By Michael Gilligan on 20/04/2019 22:49:03

Charles Shearer 120/04/2019 22:59:01
9 forum posts
3 photos



You are of course correct that there is no absolute necessity to find the exact IN and OUT points - but when at 20x magnification even being slightly out can result in many wasted shutter actuations - and wasted images!

With some runs in the hundreds of images for stacking and a touch of OCD I'm just seeking to make things as accurate and as automated as I can within the mechanical limitations of the linear rails / stepper.

Thanks again


Michael Gilligan20/04/2019 23:03:57
15700 forum posts
684 photos

Nothing wrong with a touch of OCD, Charles

... I wish you well-earned success !!



If you haven't seen it ... have a look at this little beauty, from Zeiss:


Edited By Michael Gilligan on 20/04/2019 23:09:16

Charles Shearer 120/04/2019 23:26:51
9 forum posts
3 photos


Don't suppose you've got a spare one going cheap!!!!!


AdrianR21/04/2019 10:52:56
475 forum posts
23 photos

Just a couple of thoughts.

Micro stepping is a nifty feature but is not usually guaranteed for positional accuracy. The higher the micro stepping ration the greater the error. So if you are using 32 micro steps, 5 steps could be quite normal error.

How fast are you driving this? if it is too fast you could be missing steps. Just because you tell the motor to move does not mean it does. Especially when accelerating. Are you using ramped acceleration/de-acceleration?


Edited By AdrianR on 21/04/2019 10:53:42

Charles Shearer 121/04/2019 11:11:33
9 forum posts
3 photos


Understood - but from initial testing I appear to be very lucky.

That being said - because of the nature of the work I am putting it to the distances travelled are very small. A total run of 10mm is a long run. Vibration at high magnification is a serious problem - so the speed of travel i.e. the speed between steps is set by variable and during the run is currently 200 milliseconds between steps with a 2 second delay before any shutter actuation to ensure any vibrations have subsided. This combined with flash recharge delays makes for a lengthy run time given there'll be 200-300 images each run. The rare microstep loss shouldn't be an issue - at a stepsize of 0.0003125mm I don't even have the hardware to measure it.

During resets, returns to 'home' or 'in points I ramp the speed up.

I've finally finished the code and I'm testing with temporarily attached DTI's - will know soon enough if things are indeed reliable.



john carruthers21/04/2019 11:43:40
604 forum posts
176 photos

The usual solution for this, when using astro telescopes, is to incorporate an absolute encoder to see actual movement rather than rely on step counting.
The cheapo diy version uses an old mouse encoder wheel.

Charles Shearer 121/04/2019 11:53:55
9 forum posts
3 photos

Hi John,

Oh no! I feel project creep kicking in here. If I understand you correctly I need to physically add said encoder to the linear rail?

Much as I'd like to declare version 1.0 - this intrigues me, I'll have to look into this.

Can they actually have the resolution to detect the microstep sizes I'm using?

Any further detail appreciated.



SillyOldDuffer21/04/2019 12:08:29
5759 forum posts
1222 photos
Posted by Charles Shearer 1 on 21/04/2019 11:11:33:


Understood - but from initial testing I appear to be very lucky.


will know soon enough if things are indeed reliable.


Adrian is right to suspect the accuracy of micro-stepping, but my experience with a rotary table suggests it's much more reliable than 5 steps in 30! Provided the motor is lightly loaded and not driven too fast with an adequate driver, it should work well. I'll be surprised if Charles doesn't get good results - unless his stepper motor is tiny.

Any chance of sharing some pictures when it's working Charles? It's an interesting project. Macro-photography and frame stacking go together like bacon and eggs!


All Topics | Latest Posts

Please login to post a reply.

Magazine Locator

Want the latest issue of Model Engineer or Model Engineers' Workshop? Use our magazine locator links to find your nearest stockist!

Find Model Engineer & Model Engineers' Workshop

Latest Forum Posts
Support Our Partners
Allendale Electronics
Eccentric July 5 2018
Eccentric Engineering
Subscription Offer

Latest "For Sale" Ads
Latest "Wanted" Ads
Get In Touch!

Do you want to contact the Model Engineer and Model Engineers' Workshop team?

You can contact us by phone, mail or email about the magazines including becoming a contributor, submitting reader's letters or making queries about articles. You can also get in touch about this website, advertising or other general issues.

Click THIS LINK for full contact details.

For subscription issues please see THIS LINK.

Digital Back Issues

Social Media online

'Like' us on Facebook
Follow us on Facebook

Follow us on Twitter
 Twitter Logo

Pin us on Pinterest