Posts: 4
Joined: Sun Sep 30, 2018 8:12 pm

stepper motors rattling

Tue Apr 16, 2019 2:25 pm

Hey everyone, I am controlling a nema 17 stepper driver with a TB67S109 thats a stepper driver similar to the A4988. To control the stepper driver I need to send pulses to the STEP pin. Then the motor should make one step per pulse. I can make my stepper turn beautifully with a delay of 0.000408 in between the pulses, but if I increase that delay to slow down my stepper motor, the motor starts to rattle and he does not move the way I wanted to. He skips steps etc.

Code: Select all

from time import sleep
import RPi.GPIO as GPIO

DIR = 35  # Direction GPIO Pin
STEP = 33  # Step GPIO Pin
EN = 31     # enable GPIO pin
power = 37  # power GPIO pin
MS3 = 29    #set_mode GPIO pin
CW = 1     # Clockwise Rotation
CCW = 0    # Counterclockwise Rotation
SPR = 200   # Steps per Revolution (360 / 7.5)

GPIO.setup(power, GPIO.OUT)

GPIO.output(power, GPIO.HIGH)
GPIO.output(DIR, CCW)

delay = .000408
for y in range(20000):
    for x in range(1, 200):
        GPIO.output(STEP, GPIO.HIGH)
        GPIO.output(STEP, GPIO.LOW)

Is there anyone who knows what my mistake/problem is?

User avatar
Posts: 120
Joined: Tue Feb 28, 2017 1:13 pm
Location: Sydney, Australia

Re: stepper motors rattling

Tue May 14, 2019 8:08 am

A quick guess would be as you increase the duration of the step pulse, you may be exceeding the controllers timing requirements. I had a quick look at the datasheet for the TB67S109AFTG, and its a complex little beastie. The min/max step rate timing appears to be a function of the system clock, etc.

I would thoroughly review the timing requirements for the step pulse, and then review your code. An oscilloscope is invaluable for these sorts of software PWM pulse train routines.
..the only thing worse than a stupid question is a question not asked.

Posts: 224
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: stepper motors rattling

Tue May 14, 2019 8:40 am

Can you drive the motor at a much lower speed? Stepper motors sometimes have a resonant frequency range that is harder to drive, although half- or micro-stepping can help.

Posts: 66
Joined: Sun Jun 10, 2012 7:25 pm

Re: stepper motors rattling

Tue May 14, 2019 10:30 pm

The symptoms you describe looks like supply rail noise problem. The noise is actually caused by the stepper motor. It occurs with varying intensity related to the stepper speed (pulse rate - frequency )
A solution for this problem would be to put a capacitor between Gnd and Vmot as close as possible to the stepper driver. A value of ~ 100uF would be a good start. Prob want to check the app notes for your driver for more info ( I don't see a capacitor on your diagram?)

Posts: 224
Joined: Wed Jun 20, 2012 2:51 pm
Location: Southampton, England

Re: stepper motors rattling

Wed May 15, 2019 4:06 pm

Looking at your code, you are sending high and low signals for equal times. Many stepper motor controls only need a short pulse (1-2 microseconds) at the required rate. Whether this should be high pulses from a low background or low pulses from a high background may depend on the stepper controller. The A4988 and DRV8825 need short high pulses, but I do not know about the one you are using.
Try changing your first sleep(delay) to sleep(0.000005) for short high pulses, or the second one for short low pulses.

Return to “Other projects”