How to make the stepper motor more smooth

Thread Starter

EyalZimer

Joined Oct 29, 2022
5
Hello

I am trying to built small conveyor, that will move PI camera using:

-raspberry PI
-stepper motor nema 17
-A4998 stepper motor
-gt2 belt

The base that the motor is moving is 3d printed ,around 100 gram and the belt is stretch.

The problem is that I think its pretty noisy and I want to reduce it.

I understand that I can do it via Microstepping (I operate the motor with full step), but, when I try the motor is glitching.

Also in the code I'm using delay between the step of 0.001 sec and when I try to increase/reduce it also glitching or doesn't turning.

How can I find or compute the best setup?? taking in account that I need more accuracy and quiet then speed and loud.

Regards,
 

MrSalts

Joined Apr 2, 2020
2,617
Is your controller connected to the proper coils?

►Full Step Sequence
In the full step sequence, two coils are energized at the same time and motor shaft rotates. The order in which coils has to be energized is given in the table below.

Full Step Sequence
 

Thread Starter

EyalZimer

Joined Oct 29, 2022
5
Is your controller connected to the proper coils?

►Full Step Sequence
In the full step sequence, two coils are energized at the same time and motor shaft rotates. The order in which coils has to be energized is given in the table below.

Full Step Sequence
Thanks for replying,

What do you mean proper coil? There is 4 wires that coming from the motor. 2 pairs. I connect them by continuity test( 1A-1B , 2A-2B) as in the picture
 

Attachments

twohats

Joined Oct 28, 2015
362
Why has no one asked to see the program?
Good luck with your project.
I would like to see the program and some pictures of your project.
 

Thread Starter

EyalZimer

Joined Oct 29, 2022
5
Why has no one asked to see the program?
Good luck with your project.
I would like to see the program and some pictures of your project.
Thanks for replying,

I'm making the project in the university, I can send photos in a couple of days.

I think my code is general:

import time
import RPi.GPIO as GPIO

DIR = 14
STEP = 15

GPIO.setmode(GPIO.BCM)
GPIO.setup(DIR, GPIO.OUT)
GPIO.setup(STEP, GPIO.OUT)


for x in range(step_count):
GPIo_Output(STEP, GPIO.HIGH)
time. sleep(0.001)
GPIo_Output(STEP, GPIO.LOW)
time.sleep(0.001)

GPIO.cleanup()


If I changed the delay time more small from 0.001 it's gliching
 

MisterBill2

Joined Jan 23, 2018
13,774
The sure and simple way to smooth a stepper motor drive is to have a gear reduction between the motor and the load. The motor will be running at a much higher speed and so probably not even come to a full stop between steps. In addition, the resolution in position control will be 100 times better.
So there you have another option. No code changes required, except for scaling the move instructions.
 

panic mode

Joined Oct 10, 2011
2,363
Thanks for replying,

What do you mean proper coil? There is 4 wires that coming from the motor. 2 pairs. I connect them by continuity test( 1A-1B , 2A-2B) as in the picture
yes but 4 wire need to be connected correctly - because order matters. Connections need to match programmed pattern your program generates.

lets take another look at the example of steps in post #6....

if you like, rename columns A,B,C,D to 1A,1B,2A,2B to match motor terminals.
then change color of each "1" so that it stands out. and since motor can do many steps, why not duplicate the 4 steps couple of times to make it clearer... what do you see?

you should see a bit pattern that is gradually shifted with each step and always in the same direction.
this is needed to ensure smooth motion of the motor - values move like a wave from one step to another.
you can see smooth ramp of "1" along the diagonal.

but what happens if your motor is not wired correctly? sure you identified two coils but are you sure terminals of each coil are not swapped?

lets see what happens when there is a swap...notice that:
when one of the coils is reversed motor still can run but obviously not as good because steps are not smooth transitions in the same direction. if running fast inertia can help carry it from one state to the next but this is clearly erratic and motor is easy to disturb.
when both coils are swapped, problem is corrected but motor runs in the other direction.

so... swap wires of ONE of motor windings and see if it runs better.

Microstepping will improve smoothness of transitions and also reduce noise motor makes.

1667660361078.png
 

Attachments

Last edited:

MrSalts

Joined Apr 2, 2020
2,617
He's moving a Camera,
any oscillations of any kind need to be avoided.
.
.
.
i think you you should get more feedback from the OP
to understand the severity of oscillations and goal of
the project before you claim "any oscillations of any
kind need to be avoided" - especially when recommending
a $200+ item with poor reviews (which usually indicates
that a decent one will cost more).
 

LowQCab

Joined Nov 6, 2012
2,644
Having more ideas to choose from is generally better than having tunnel-vision.

A "decent" one will most defiantly cost more than ~$200.oo, no surprise there.
The listing has --> 1 <-- review,
was that review conducted by a reputable testing-facility ?,
or maybe by a clown who had no idea of what he was doing and repeatedly overloaded it ?
Was it mounted out in the Weather?,
Was it run with excessive Voltage ?
Was it run under semi-continuous-duty conditions ?, for an entire year ?,
Was it used to open a ~400-pound Gate at the entrance to a parking-lot ?
Was it installed in an Industrial-Production-Environment ?
Was it subjected to heavy side-loads, or impacts ?,
How many times was the Motor stalled because of excessive loads ?

No one really knows.
So until there's at least ~20 or so reviews, that can be averaged,
the Reviews-Section is basically useless.

It's obviously a cheap piece of Chinese-Junk,
and was presented as an example, not an endorsement.

I made no claims as to it's quality or value.

I suggested it only as an alternative to a plastic-chain and sprocket setup
for smoothly moving a Camera,
and any Linear-Actuator, junk or not,
certainly has more value in performing that task.

Take a Pill man.
.
.
.
 

MrSalts

Joined Apr 2, 2020
2,617
Having more ideas to choose from is generally better than having tunnel-vision.

A "decent" one will most defiantly cost more than ~$200.oo, no surprise there.
The listing has --> 1 <-- review,
was that review conducted by a reputable testing-facility ?,
or maybe by a clown who had no idea of what he was doing and repeatedly overloaded it ?
Was it mounted out in the Weather?,
Was it run with excessive Voltage ?
Was it run under semi-continuous-duty conditions ?, for an entire year ?,
Was it used to open a ~400-pound Gate at the entrance to a parking-lot ?
Was it installed in an Industrial-Production-Environment ?
Was it subjected to heavy side-loads, or impacts ?,
How many times was the Motor stalled because of excessive loads ?

No one really knows.
So until there's at least ~20 or so reviews, that can be averaged,
the Reviews-Section is basically useless.
do you want me to agree with what you say above ( that I should not base my opinion of the part on only one reviewer of questionable authority and keep an open mind because it might actually be a pretty good device if some competent person judges it)?
Or should my opinion of the part be based on what you say below?
It's obviously a cheap piece of Chinese-Junk,
and was presented as an example, not an endorsement.

I made no claims as to it's quality or value.

[
and, honestly, after working in the illegal "pharmaceutical" industry for nearly 6-years and the regulated pharmaceutical industry for the first half of my professional career, let me assure you that I would never take your advice below - because I know what's in there, I know how they are tested, and I know the motivations of the people marketing the products.
Take a Pill man.
but honestly, on the linear actuator, tell me if you want me to believe the first half (you believe I should give it a chance) or the second half of your post (it's cheap Chinese junk).
 
Top