0
\$\begingroup\$

I am new to these types of projects and mostly program so I don't understand completely the functions so it would help if your answer was thoroughly explained.

What my project is we have a python script that sends commands to adafruit which should turn the motor but doesn't. The lights turn on so the motherboard receives the signal, and it seems to get the proper output but it still won't turn

  • Servo Motor 28BYJ-48
  • Power Supply: 4 X AA BATTERY HOLDER WITH ON/OFF SWITCH
  • Adafruit 16-channel 12-bit pwm/servo driver with rasberry pi

"The four batteries are held in series, for a nominal output of 6V DC for alkaline (6.4V when fresh, 4V when dead), and 4.8V DC for rechargeables (5.2V when fully charged, 4.4V when discharged). Using rechargeables will make this work nicely with nearly any 5V project, with alkalines you may want to put a 1N4001 in series to drop the voltage from 6V down to 5.3V."

We use the following code to attempt to turn the servo

import RPi.GPIO as GPIO
import time


GPIO.setmode(GPIO.BOARD)

ControlPin = [7, 11, 13, 15]

for pin in ControlPin:
    GPIO.setup(pin, GPIO.OUT)
    GPIO.output(pin, 0)

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):
    ### GO THROUGH THE SEQUENCE ONCE ####
    for halfstep in range(8):
        for pin in range(4):
            ###SET EACH PIN###
            GPIO.output(ControlPin[pin], seq[halfstep] [pin])
        time.sleep(.001)

GPIO.cleanup()

All the hardware seems to be correct. Everything is connected and the signal is sent, the lights turn on. The servo motor just doesn't turn

\$\endgroup\$
  • \$\begingroup\$ Adafruit is a company. Which of their products are you using to control the servo? \$\endgroup\$ – JRE Oct 26 '17 at 15:48
  • \$\begingroup\$ I edited and added the bit about "adafruit 16-channel 12-bit pwm/servo driver with rasberry pi" to clear which product I use \$\endgroup\$ – HAMZAH AHMED Oct 26 '17 at 16:03
  • \$\begingroup\$ This is for servo motors where impulse width indicates the position, not for the stepper motors. \$\endgroup\$ – P__J__ Oct 26 '17 at 17:20
  • \$\begingroup\$ A stepper motor is not a servo. The RPi's GPIOs are not powerful enough to drive a stepper motor directly. Do you have a driver board for the stepper motor? \$\endgroup\$ – Bruce Abbott Oct 26 '17 at 17:21
4
\$\begingroup\$

I think the problem is that you are trying to drive a stepper motor with a servo driver.

A stepper motor is turned in small steps by applying momentary voltages to the various windings. Steppers do not "spin" when energized, but instead turn one small step per energized phase. Also, steppers do not utilize positional feedback (usually) because the microcontroller is responsible for counting the number of steps to turn the motor to the desired position.

Servo motors, on the other hand, are regular motors which spin when the windings are energized. The controller uses a positional feedback indicator and some sort of PID algorithm to supply varying amounts of power to the motor's windings, turning/stopping it at the desired position.

Your code looks like it's outputting the steps to rotate a stepper motor, but if you're using a Servo Driver board, it's intended for a different type of motor... so either 1) nothing happens, or 2) white smoke escapes various components rendering them inoperable.

Good luck.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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