-1

I´m working on a simple project for school now and I have to use a stepper motor, but it doesn´t turn. The LEDs go on, the motor gets hot and the motor vibrates. When I adjust the sleep/function, the vibration pulses go quicker or slower. Yet the motor doesn´t turn. What can I do?

This is the script I use in Python on my Raspberry Pi. I'm not receiving any error.

import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BOARD)
control_pins = [7,11,13,15]
for pin in control_pins:
  GPIO.setup(pin, GPIO.OUT)
  GPIO.output(pin, 0)
halfstep_seq = [
  [1,0,0,0],
  [1,1,0,0],
  [0,1,0,0],
  [0,1,1,0],
  [0,0,1,0],
  [0,0,1,1],
  [0,0,0,1],
  [1,0,0,1],
]
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)
GPIO.cleanup()
GPIO BOARD pin goes to the minus
pin 4 to plus
ln4 to 17
ln3 to 15
ln2 to 13
ln1 to 7

The stepper motor is ROHS 28BYJ-48 5Voltage DC

4
  • You make no mention of a driver board. We need a clear photo of the connections between the Pi and the stepper.
    – joan
    Oct 11, 2019 at 8:15
  • There is a discrepancy in the GPIO you claim to be using (7, 11, 13, 15 versus 7, 13, 15, 17).
    – joan
    Oct 11, 2019 at 10:14
  • In case you would like to compare other 28BYJ-48 stepup and programming, you might read the following post: raspberrypi.stackexchange.com/questions/97975/…
    – tlfong01
    Oct 11, 2019 at 13:23
  • start trubleshooting by moving the motor one step per second
    – jsotola
    Oct 12, 2019 at 0:01

1 Answer 1

1

You should use a larger value for sleep. Start with a really large value, then reduce it to find the minimum value, then add some safety margin. Or consult the documentation for the stepper motor.

The motor needs time to turn. If your delay is too short, the current causes the motor to go back before it had time to move forward, hence the vibration. Not only doesn't that cause a rotation, it draws more current and generates more heat.

It may be possible to use higher speed once the motor has accelerated, than the speed at which you turn the motor from its initial position.

3
  • I doubt the delay is the problem. A step delay of a millisecond should be fine for this stepper, and should result in something like 13 RPM.
    – joan
    Oct 11, 2019 at 20:56
  • There are 8 states per rotation and 1000 states per second, so (1000/8)=125 RPM.
    – RalfFriedl
    Oct 11, 2019 at 21:21
  • Not quite. There are 64 steps per rotation, but there is also an internal 64 step gearing, giving 4096 steps per revolution.
    – joan
    Oct 11, 2019 at 21:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.