2

I am following the tutorial: But I am using a pi t-cobbler and a Pi 2. I am also using the ULN2803 driver.

When plugging a button into the appropriate gpio spots on the breadboard, I am able to run a different program fine, which means there is communication between the pi and the breadboard. But there is no output that I can see to the 5V DC motor. The python code I am using from the tutorial is here:

import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)

enable_pin = 18
coil_A_1_pin = 4
coil_A_2_pin = 17
coil_B_1_pin = 23
coil_B_2_pin = 24

GPIO.setup(enable_pin, GPIO.OUT)
GPIO.setup(coil_A_1_pin, GPIO.OUT)
GPIO.setup(coil_A_2_pin, GPIO.OUT)
GPIO.setup(coil_B_1_pin, GPIO.OUT)
GPIO.setup(coil_B_2_pin, GPIO.OUT)

GPIO.output(enable_pin, 1)

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 backwards(delay, steps):
  for i in range(0, steps):
    setStep(1, 0, 0, 1)
    time.sleep(delay)
    setStep(0, 1, 0, 1)
    time.sleep(delay)
    setStep(0, 1, 1, 0)
    time.sleep(delay)
    setStep(1, 0, 1, 0)
    time.sleep(delay)


def setStep(w1, w2, w3, w4):
  GPIO.output(coil_A_1_pin, w1)
  GPIO.output(coil_A_2_pin, w2)
  GPIO.output(coil_B_1_pin, w3)
  GPIO.output(coil_B_2_pin, w4)

while True:
  delay = raw_input("Delay between steps (milliseconds)?")
  steps = raw_input("How many steps forward? ")
  forward(int(delay) / 1000.0, int(steps))
  steps = raw_input("How many steps backwards? ")
  backwards(int(delay) / 1000.0, int(steps))

Here is a photo of my wiring:

breadboard wiring

2
  • Make sure the cable between the cobbler and the Pi is not on back to front.
    – joan
    Dec 5, 2015 at 8:33
  • Is the driver chip fully enabled? LEDs on the phase outputs, with suitably-large resistors may help debug; better done with motor unplugged (because of inductive kickback could kill LEDs.) Also note that sharing Pwr supply between motors and CPUs is a dicey proposition. Generous bypass caps may help (suggest tantalum if you have.)
    – Catalyst
    Sep 22, 2019 at 20:48

2 Answers 2

0

Nope. Not wiring issue. Double check if you got the exact same chip in the tutorial. If so, it's probably a software problem. Try running the program as root.

0

Since I do not have all the needed information I will take a SWAG and say it probably will not work. Assuming the software is OK the ULN2803 is for 5V, TTL/CMOS devices as its input source. It can take up to 3v on the input to drive a 300 mA load. Check the data sheet for the particular device you have, not all are the same. Also check and see if the output of the micro gets at least this high. Try a ULN2801 it should work if the software is correct.

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.