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

Tinkering with Gary Liming's Stepper Motor control sketch

All Topics | Latest Posts

Search for:  in Thread Title in  
Greensands16/08/2021 10:37:24
250 forum posts
43 photos

I have been playing around with a Type 17 stepper motor using the Gary Liming Arduino sketch running with a UNO/Type 6600 Driver but could do with some help with some fairly basic questions regarding tweaking the software. Basically I would like to know how to increase the speed of rotation by say a factor of 2 or 3. Currently the micro-stepping DIP switch is set 8 but what is the significance of 'front end gearing' and the sketch variable GearRatio1top equal to 3? Any assistance on the subject would be much appreciated.

John Haine16/08/2021 11:25:12
4172 forum posts
242 photos

A simple thing to do is change the microstep setting from 8 to 2 or 4. You get 200 steps per rev from the "native" stepper motor and the microstepping function in the driver interpolates 8 additional steps in between so the motor will take 1600 steps for one rev, I'm not familiar with the software you mention but I would guess that "front end gearing" refers to any mechanical reduction between the motor shaft and what it's driving. If for example there was a 2:1 reduction this would increase the effective steps per rev to 3200.

Edited By John Haine on 16/08/2021 11:26:47

John Haine16/08/2021 11:28:50
4172 forum posts
242 photos

Without looking in more detail at the Gary Liming site I can't think what GearRatio1top can be but I suggest that you set it to 1, as also the "front end gearing".

John Haine16/08/2021 11:33:54
4172 forum posts
242 photos

Looking slightly more closely and making a wild guess, I think that originally Gary assumed that there would be a simple reduction gear ratio like 1/4, but then people were saying that their mechanics had ratios like 3/4 - so the parameter "3" would be the numerator (top) and "front end gearing" would be set to 4.

SillyOldDuffer16/08/2021 13:43:52
7550 forum posts
1680 photos

The answer is probably a lemon because my copy of Gary's code (version 2.3) already defaults to Fast.

The gear ratio settings don't effect motor speed; Gary just allows for common rotary table ratios like 90:1 and 40:1. The two main parameters that do are:

  • Line 45: #define DefaultMotorSpeed 0 // zero here means fast, as in no delay
  • Line 73: #define pulsewidth 2 // length of time for one step pulse

The main thing slowing the motor down is the number of microsteps per revolution, probably set to 8. Setting the motor to 4 microsteps would double the speed and halve the accuracy. Probably don't want to mess with microsteps because the accuracy of your rotary table depends on them. It's at

Line 27: #define Microsteps 8

A few things you might try:

Gary updates the display after every step in moveangle and movesteps modes, which slows the motor down. Try disabling the display by altering the movemotor() function at about line 546, to cut out a section of code with an #if defined(DO_UPDATE) and #endif block thus:


The code between #if and #endif will be ignored when the sketch is recompiled, and not having to wait while the display is altered should speed the motor up. Noticeable improvement rather than gee whizz, and of course the display is disabled.

And/or try setting Line 73 to #define pulsewidth 1

The latter might not be satisfactory because how fast the motor can spin is limited by your power supply. 48V or more if the controller can cope please. Unfortunately the motor will skip steps If the power supply can't react fast with enough amps, so there's a limit to how quickly the software can issue pulses and have the motor keep up.

Ask again if #define pulsewidth 1 performs OK with the table carrying a load because delay() can be replaced by delayMicros() to give sub-millisecond stepping, which might be worth trying. I doubt it because stepping quickly takes the motor into unreliable 'here be dragons' territory.


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
walker midge
Eccentric July 5 2018
rapid Direct
JD Metals
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