Having Trouble Controlling Stepper Motor with TB67S128FTG Driver

I am having trouble driving this stepper motor with my TB67S128FTG. I’ve ensured there is voltage at V_in (~12.2V) and VCC (~5V). Are there any other pins I should expect to have a voltage
that could help diagnose the issue? The code I’ve written is below (all of the print statements are executing):

from time import sleep
import RPi.GPIO as GPIO

DIR = 24
STEP = 25
CW = 1
CCW = 0
SPR = 200 # steps per revolution: 360 / 1.8

def main():
    print("DIR = " + str(DIR))
    print("STEP = " + str(STEP))

    GPIO.setup(DIR, GPIO.OUT)
    GPIO.setup(STEP, GPIO.OUT)
    GPIO.output(DIR, CW)
    step_count = SPR # 1 full rotation
    delay = 0.0208
    for i in range(step_count):
        GPIO.output(STEP, GPIO.HIGH)
        GPIO.output(STEP, GPIO.LOW)

if _name_ == "_main_":

Is there something I’m overlooking in this code?

Below, I have attached a diagram of how I have wired my Raspberry Pi to my driver along with some photos of my soldering connections.

I can see two potential issues with your code. First, I suspect you should be using double underscores in your if statement at the end of the program, like so:

if __name__ == "__main__":

As opposed to:

if _name_ == "_main_":

So, your program might not be running.

Second, once you factor in the 50.9:1 gearbox on your motor, the steps per revolution value should be 10,180 steps, not 200. Moving the motor 200 steps would only move the output shaft about 7ׄ°.

If making those changes does not change the results please post more details about what is happening versus what you expect to happen. For example, are there any signs of life from the motor or voltages applied across the driver’s output pins when you power the system and run this program? Also, can you check the voltage on the VREF pin and post some pictures of your wiring?

- Patrick

Hi Patrick. The underscores seem to be a bug with copy and pasting code blocks. The program was running.

It turns out that the problem was that the ENABLE and nSTANDBY pins were driven LOW. Driving them HIGH instead allows me to control the motor as expected! Thanks for the help.

By the way, is there any way to allow the motor to be rotated completely freely, meaning the motor will not resist at all when rotated by hand?

I am glad to hear you got it working!

If you disable the stepper motor driver, such as by using the ENABLE or nSTANDBY, that should deenergize the motor which will make the output shaft easy to turn by hand. However, keep in mind that your stepper motor’s gearbox adds inertia and amplifies the friction, so that might make it harder to turn by hand.

- Patrick