microstepping issue

Hello all,

I am somewhat new to Arduino coding, and was wondering if someone could help me out with some microstepping.

I currently have a Nema 17, stats below, paired up with a A4988 stepper motor driver connected to a Arduino Leonardo.

My project I created is a barn door mount for star tracking. Basically, I just run this to track stars at Earth’s rotation speed to get steady pictures while stargazing.

I created the mount and had some success with it, but am having issues with the motor hesitating and I believe it has to do with my programming, set up and coding seen below.

// STEPPER DRIVER CONNECTED TO:
// ENABLE pin: D10   (PB6)
// DIR pin:  D9      (PB5) 
// STEP pin: D8      (PB4)
// ratio between the large gear and the small one=0.2549
// Length from middle of rod to hinge = 158mm
// M8 rod rises 1.25mm for every rotation of the Big Gear.
// 15 degrees per hour = rise of 42.3359724mm
// 1/4 degree per minute = .70559954mm
// Rotation of Big Gear for 1/4 degree per minute = (.70559954*360)/1.25) = 203.21266752 degrees
//marked off 203 degrees on big gear and kept modifying step amount and speed until 203 degrees was reached at 1 minute. 

#include <Stepper.h>
#include <AccelStepper.h>

Stepper stepper(295,8,9,4,11);
void setup()
{
  //Speed of motor 
   stepper.step(295);
  stepper.setSpeed(6);
}
void loop()
{
  stepper.step(295);
}

So a couple things…One, what can I do to stop this from hesitating? Two, how do I microstep the motor to make it turn more smoothly or am I already microstepping and don’t know it? I am not grasping the basic concept of microstepping even after reading the tutorials from here, so hoping someone could lend me a hand. You can see a video of the mount running below. Thanks!

One, what can I do to stop this from hesitating?

What is causing the hesitation(s)? Underpowering the stepper? Excess load on the stepper?

Two, how do I microstep the motor to make it turn more smoothly or am I already microstepping and don't know it?

The stepper driver would typically have microswitches or jumpers to determine how many microsteps to take per pulse.It is impossible to tell from a Fritzing diagram which stepper driver you are using or how you configured it.

PaulS:
What is causing the hesitation(s)? Underpowering the stepper? Excess load on the stepper?
The stepper driver would typically have microswitches or jumpers to determine how many microsteps to take per pulse.It is impossible to tell from a Fritzing diagram which stepper driver you are using or how you configured it.

Thanks Paul for the reply.

As for the hesitation, my guess is it is underpowered, but the amount of force needed to turn the cog for my project is not much. So I am guessing it is in the coding that my be the issue?

As for the stepper driver, it is a A4988, diagram for connections seen below.

So I seemed to have fixed the hesitation when I found that the pentometer was reading .6 amps, when it should have been .77. Been running for a minute and no hesitation.

Now for the microstep, should I be doing something with the MS1, MS2 and MS3 connections?

As for the stepper driver, it is a A4988, diagram for connections seen below.

I'm afraid that the picture is about useless. I would GUESS that MS1, MS2, and MS3 refer to microstepping modes, but that is ONLY a guess. Post a link to the device.

What is powering the stepper motor/driver? How much voltage? How much current?

MS1, 2 and 3 do indeed represent microstep, diagram below

As for voltage, it is connected to 12v, 8x2AA batteries

So, you would connect one or more of the MSn pins to 5V, to control the level of microstepping. Connect all three to make each pulse step 1/16 as much as it steps with none connected.

Thanks for the info.

So when I hook up ms1 to 5v, it slows the motor down. So in the code, would I need to increase pulses to compensate for the fractional microsteps?

jburkhardt0:
So when I hook up ms1 to 5v, it slows the motor down. So in the code, would I need to increase pulses to compensate for the fractional microsteps?

Yes.

So when I hook up ms1 to 5v, it slows the motor down. So in the code, would I need to increase pulses to compensate for the fractional microsteps?

Let's back up. Why do you think you need micro-stepping? If you really need to make the stepper step very tine distances, it should be obvious that you need to step more times to get the same overall degree of rotation.

Your code (currently) does nothing but run the stepper like it was a standard electric motor.

If you need microstepping, you will have to accept that the speed of the motor will go down.

Don't you just need to turn the motor in counter earth rotation based upon the units longitude? Thus you need not step but torque in continuous counter earth rotation. I would think, even micro stepping, that the starts and stop would introduce jitter.

I'd use a Optical Flow sensor, aimed at a guide star, to compensate for any longitude speed variations by controlling the motor speed, based upon guide star positional changes on the optical flow sensor.

Okay, so the need for microstepping is to limit the vibration on the device, since the device needs to be a steady as possible for the camera to take steady 10 minute + exposures to prevent stars from getting elongated as the earth moves. With the motor at full step, the jerkiness between each cog for each step causes the camera to jerk a bit, causing stars to not be perfect circles.

So I figured that in full steps, the stepper motor would need to move 295 steps in order to move the bigger gear 203 degrees every minute. The timing seems to be spot on from tests I have done, but I needed the motor to run more smoothly. I will be honest, not even sure if the coding I supplied was the most efficient or even done 100% correctly, but in my eyes, it worked and all is good.

So now with the info you guys supplied, I have tried this with 1/2 step, simply multiplying the stepper.step 295 by 2, and it seems to be running at the speed I want.

// STEPPER DRIVER CONNECTED TO:
// ENABLE pin: D10   (PB6)
// DIR pin:  D9      (PB5) 
// STEP pin: D8      (PB4)
// ratio between the large gear and the small one=0.2549
// Length from middle of rod to hinge = 158mm
// M8 rod rises 1.25mm for every rotation of the Big Gear.
// 15 degrees per hour = rise of 42.3359724mm
// 1/4 degree per minute = .70559954mm
// Rotation of Big Gear for 1/4 degree per minute = (.70559954*360)/1.25) = 203.21266752 degrees
//marked off 203 degrees on big gear and kept modifying step amount and speed until 203 degrees was reached at 1 minute. 

#include <Stepper.h>
#include <AccelStepper.h>

Stepper stepper(590,8,9,4,11);
void setup()
{
  //Speed of motor 
   stepper.step(590);
  stepper.setSpeed(6);
}
void loop()
{
  stepper.step(590);

Idahowalker:
Don't you just need to turn the motor in counter earth rotation based upon the units longitude? Thus you need not step but torque in continuous counter earth rotation. I would think, even micro stepping, that the starts and stop would introduce jitter.

As for this device, the way it works is that the stepper motor has a small gear attached, which is connected to a big gear, which the big gear turns around a bolt that make it rise over time. The rise is what matches the speed of earth's rotation, lifting the camera in the same direction as the star movements to match. You can see this in action in the video linked below.

Barn Door Mount Video

You can see the full build at this following link

Barn Door Mount Build