-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

joan
  • 71,852
  • 5
  • 76
  • 108

1 Answers1

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.

RalfFriedl
  • 2,180
  • 2
  • 11
  • 12