-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,024
  • 5
  • 73
  • 106
  • 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 '19 at 08: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 '19 at 10:14
  • In case you would like to compare other 28BYJ-48 stepup and programming, you might read the following post: https://raspberrypi.stackexchange.com/questions/97975/controlling-28byj48-bipolar-convert-with-l293d-ic – tlfong01 Oct 11 '19 at 13:23
  • start trubleshooting by moving the motor one step per second – jsotola Oct 12 '19 at 00:01

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,188
  • 2
  • 10
  • 11
  • 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 '19 at 20:56
  • There are 8 states per rotation and 1000 states per second, so (1000/8)=125 RPM. – RalfFriedl Oct 11 '19 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 '19 at 21:42