kgoess
Posts: 1
Joined: Sat Oct 26, 2013 11:12 pm

troubleshooting dc motor

Tue May 31, 2016 4:50 am

After a couple experiments successfully getting LEDs and pushbuttons to work, we're working through the adafruit tutorial on the dc motor:
https://learn.adafruit.com/adafruit-ras ... a-dc-motor
We've got everything hooked up exactly like the diagram, though we're using different software since the API seems to have changed since that tutorial.

But the motor isn't spinning. We can hook it up directly to batteries and watch it wizz away, but aren't having any luck getting the GPIO to make it do anything. The script runs without errors, but to no effect. I'm a software guy, not a hardware guy, and I don't know enough here to debug this setup, I don't know what parts I can verify, short of running the whole thing.

How would I go about looking for where we might be going wrong? Any suggested tools? Strategies for verifying which part isn't working? Common mistakes with this kind of setup?

Some configuration information:
P1_REVISION : 2
RAM : 512M
REVISION : 000e
TYPE : Model B
PROCESSOR : BCM2835
MANUFACTURER : Sony
GPIO version is 0.6.2

gpio test shows:
Skipped non-user gpios: 0 1 5 6 12 13 16 19 20 21 26
Tested user gpios: 2 3 4 7 8 9 10 11 14 15 17 18 22 23 24 25 27 28 29 30 31
Failed user gpios: None

and gpio readall shows

Code: Select all

+-----+-----+---------+------+---+-Model B2-+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |     |     |    3.3v |      |   |  1 || 2  |   |      | 5v      |     |     |
 |   2 |   8 |   SDA.1 |   IN | 1 |  3 || 4  |   |      | 5V      |     |     |
 |   3 |   9 |   SCL.1 |   IN | 1 |  5 || 6  |   |      | 0v      |     |     |
 |   4 |   7 | GPIO. 7 |   IN | 0 |  7 || 8  | 1 | ALT0 | TxD     | 15  | 14  |
 |     |     |      0v |      |   |  9 || 10 | 1 | ALT0 | RxD     | 16  | 15  |
 |  17 |   0 | GPIO. 0 |   IN | 0 | 11 || 12 | 0 | IN   | GPIO. 1 | 1   | 18  |
 |  27 |   2 | GPIO. 2 |   IN | 0 | 13 || 14 |   |      | 0v      |     |     |
 |  22 |   3 | GPIO. 3 |   IN | 0 | 15 || 16 | 0 | OUT  | GPIO. 4 | 4   | 23  |
 |     |     |    3.3v |      |   | 17 || 18 | 0 | IN   | GPIO. 5 | 5   | 24  |
 |  10 |  12 |    MOSI |   IN | 0 | 19 || 20 |   |      | 0v      |     |     |
 |   9 |  13 |    MISO |   IN | 0 | 21 || 22 | 0 | IN   | GPIO. 6 | 6   | 25  |
 |  11 |  14 |    SCLK |   IN | 0 | 23 || 24 | 0 | OUT  | CE0     | 10  | 8   |
 |     |     |      0v |      |   | 25 || 26 | 0 | OUT  | CE1     | 11  | 7   |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 |  28 |  17 | GPIO.17 |   IN | 0 | 51 || 52 | 0 | IN   | GPIO.18 | 18  | 29  |
 |  30 |  19 | GPIO.19 |   IN | 0 | 53 || 54 | 0 | IN   | GPIO.20 | 20  | 31  |
 +-----+-----+---------+------+---+----++----+---+------+---------+-----+-----+
 | BCM | wPi |   Name  | Mode | V | Physical | V | Mode | Name    | wPi | BCM |
 +-----+-----+---------+------+---+-Model B2-+---+------+---------+-----+-----+
And this is the python that runs without errors, but without effect

Code: Select all

#!/usr/bin/python
import RPi.GPIO as GPIO
from time import sleep
 
GPIO.setmode(GPIO.BOARD)
 
Motor1A = 7
Motor1B = 11
Motor1E = 12

GPIO.setup(Motor1A,GPIO.OUT)
GPIO.setup(Motor1B,GPIO.OUT)
GPIO.setup(Motor1E,GPIO.OUT)
 
print "Turning motor on"
GPIO.output(Motor1A,GPIO.HIGH)
GPIO.output(Motor1B,GPIO.LOW)
GPIO.output(Motor1E,GPIO.HIGH)
 
sleep(2)
 
print "Stopping motor"
GPIO.output(Motor1E,GPIO.LOW)

User avatar
MarkHaysHarris777
Posts: 1820
Joined: Mon Mar 23, 2015 7:39 am
Location: Rochester, MN
Contact: Website

Re: troubleshooting dc motor

Tue May 31, 2016 7:43 am

I can give you some tips that you can try. The first thing I would do is to remove all power everywhere and check your wiring (the most common problem, by the way). Use a multi-meter and check continuity to all your connections. My meter has a beeper (beeps when continuity exists). Check to make sure the fritzing diagram makes sense, that all the connections are there, and that they actually electrically 'make'. Sometimes the contact points don't 'make' on some bread-boards, and some pluggable wires are notoriously dirty on the ends (and what I mean by that is that there is a slight coating of oily substance or rubber from the manufacturing process that keeps the wires from making contact! Check and clean all connections.

Make a list; all contact points from the fritzing diagram into your notebook... systematically check that all connections are there, that they are clean, and that they electrically 'make' contact. This is hard work, but it is essential if you want the project to work.

Assuming you have good components... things should work. You may have bad components... you'll have so setup tests to determine if they're good... you've already tested the motors (good). Check the driver (without PWM ). Check your PWM with a scope if you have one... with piscope (see pigpio site) and make sure the pwm is working. If you connect a speaker through a small capacitor to the pwm pin you can hear it working (it will be a note something higher than concert A).

Check the continuity of every wire in your circuit 'before' you put the wire in place (actually make sure it is really a wire!! Sometimes there is nothing wrong except that that one wire was bad.

Make sure you have fresh batteries on your motor driver power source.

As you build the project, systematically check it in stages; do hardware checks and debugs a little at a time rather than building the whole project and then trying to figure out what is wrong... make sure it works in stages if you can.
marcus
:ugeek:

Return to “Troubleshooting”