Stepper motor suddenly acting weird.
Posted: Sun Sep 21, 2014 1:03 am
For a long time the step motor is working fine but suddenly today instead of making complete turns it stuttered; central axle seems turning but rest of gears are stuttering and unable to make complete turn. What's wrong?
Code: Select all
# Imports
import webiopi
import time
GPIO = webiopi.GPIO
# -------------------------------------------------- #
# Constants definition #
# -------------------------------------------------- #
# Left motor GPIOs
L1=22 # H-Bridge 1
L2=17 # H-Bridge 2
# Right motor GPIOs
R1=23 # H-Bridge 3
R2=24 # H-Bridge 4
# -------------------------------------------------- #
# Macro definition part #
# -------------------------------------------------- #
def turn_left():
forward(0.01,260)
def forward(delay, steps):
for i in range(0, steps):
setStep(1, 0, 1, 0)
time.sleep(delay)
setStep(0, 1, 1, 0)
time.sleep(delay)
setStep(0, 1, 0, 1)
time.sleep(delay)
setStep(1, 0, 0, 1)
time.sleep(delay)
def setStep(w1, w2, w3, w4):
GPIO.output(L1, w1)
GPIO.output(L2, w2)
GPIO.output(R1, w3)
GPIO.output(R2, w4)
# -------------------------------------------------- #
# Initialization part #
# -------------------------------------------------- #
# Setup GPIOs
GPIO.setFunction(L1, GPIO.OUT)
GPIO.setFunction(L2, GPIO.OUT)
GPIO.setFunction(R1, GPIO.OUT)
GPIO.setFunction(R2, GPIO.OUT)
turn_left()