Lars van der Niet
Lars van der Niet

Reputation: 31

Stepper Motor with ULN2003 drivers only vibrates and does not turn

I've been trying to get the Stepper Motor to work for over a week now. It's not been responding to my python script for a while now.

When I just bought the Stepper Motor everything worked fine and I had zero problems. Now, a few weeks later, it does not seem to respond. The lights on the ULN2003-board are lighting up but the motor itself is not turning, just vibrating. This made me thinks that it was a wire or script problem, but it does not seem like it. I've tried some other scripts and changed the wires a couple of times, to no avail.

This is the code that used to work:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BOARD)


# 7=A, 11=B, 13=C, 15=D 
control_pins = [7,11,13,15] 

while 1:
  for pin in control_pins:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.output(pin, 0)

  halfstep_seq = [
    [1,0,0,0], # Step 1
    [1,1,0,0], # Step 2
    [0,1,0,0], # Step 3
    [0,1,1,0], # Step 4
    [0,0,1,0], # Step 5
    [0,0,1,1], # Step 6
    [0,0,0,1], # Step 7
    [1,0,0,1]  # Step 8
  ]

  for i in range(512):
    for halfstep in range(8):
      for pin in range(4):
        GPIO.output(control_pins[pin], halfstep_seq[halfstep][pin])
      time.sleep(0.001)

And yes, I know GPIO.cleanup() should be in there. I deleted it on purpose so the loop would keep running. This way it was easier for me to detect any mistakes instead of the motor just making 1 circle and stopping everytime.

I honestly expect the motor to just be broken for some reason. Don't know how, don't know when, but it probably hit something that broke the motor on the inside.

If there's anyone with more experience who could tell me what to do in this situation, please help me.

Upvotes: 2

Views: 849

Answers (1)

Tom Dalton
Tom Dalton

Reputation: 6190

So my guess would be that the step time you are using (the sleep time) is just too short, the motor doesnt have enough time to turn to the new position before you are trying to drive it to the next one. Effectively the program is getting ahead of what the motor is capable of. It may be that the physical bearings in the motor have degraded slightly, or the driving circuit isn't able to drive the motor as hard (lower voltage/power than when it worked). Does the motor's tech spec provide a maximum theoretical RPM that it could be driven at? Does it provide a minimum step-time or similar information that could guide this?

As an aside, if you say something crashed, it's really helpful to provide the stack trace or other error output so people can try to help understand why and what exactly isn't working.

Upvotes: 0

Related Questions