A4988 problems

I’m not sure if there’s something wrong with my setup, or if there is something wrong with my A4988. I have it connected to my stepper driver, 19V coming in from VMOT, 3.3v coming into vdd from a Raspberry Pi. I have a bipolar NEMA17 stepper connected to the A4988 with green, black, red, and blue wires connected to 1B, 1A, 2A, and 2B. I can get the motor to step, but only after pulling step high twice (ie, low/high/low/high results in one step). The other odd thing is that while it steps, it steps in the opposite direction of the last step, regardless of how direction is pulled. I have even tried connecting direction directly to 3.3v and ground, but it still exhibits the same behavior. I have tried pulling sleep and reset high and low, as well as connecting them together, all with the same results. Does this sound like a hardware issue, or something with my setup?

Are you sure that you are connecting one motor coil to the 1A/B terminals and the other to the 2A/B terminals? Stating the colors of the motor wires doesn’t help. Also, is there a common ground for everything?

When I unplug the motor and cross the wires from either of the terminals, there’s much more resistance, so I believe they are connected correctly. The ground from VMOT is separate from everything else (which grounds to the rpi), but both share the same power strip.

It is hard to understand your reply. In a properly functioning bipolar motor, there should be no connection (infinite resistance) between the coils, so you can use an ohmmeter to tell which leads belong to the two coils without ambiguity. Is this a 5- or more lead motor? Note: when you “unplug the motor” be sure everything is powered down. You can easily destroy the motor driver otherwise.

VMOT ground MUST be connected to the microprocessor power supply ground, similar to what is shown in the wiring diagram here: pololu.com/catalog/product/1182

Sorry, I shouldn’t have said resistance - when two of the wires are crossed from either 1 or 2, the shaft is harder to turn. However, I plugged in my ohmmeter and verified I have the proper wires for the coils. The motor has just the four leads mentioned.

As in the wiring diagram, I have two power sources; one, 3.3v, from the Raspberry Pi, which powers VDD and GND. I also have a second 19v DC power brick, which is connected to VMOT and GND. If I understand DC correctly, the two cannot share the same ground; however, both separate power sources have the +v and the ground connected to the a4988 board.

All grounds must be connected together. It would be best if you posted a picture and/or wiring diagram of your setup.

I connected the grounds together, still the same issue. Using my multimeter, I have checked all the voltages, and 19v is going to the motor driver on VMOT, and 3.3v is going to VDD. I can watch step get pulled high (3.3v), but a step only occurs after it is drawn low, then high again a second time. Each time it steps, it will step in the opposite direction of the last step, regardless of the voltage across direction. Just to try and make sure I’m not getting an incorrect voltage from the Pi GPIO, I have also tried connecting direction to both ground and 3.3v. No matter what, the result is the step going the opposite direction of the last step. I have included the code I have on the Raspberry Pi, as well as a picture of either side of my breadboard. Using the code attached, it will step once every two seconds, in the opposite direction of the last step.

#!/usr/bin/python
import RPi.GPIO as GPIO
import time

GPIO.setmode(GPIO.BCM)
 
step = 23
direction = 24
         
GPIO.setup(step, GPIO.OUT)
GPIO.setup(direction, GPIO.OUT) 
        
while True:  
    time.sleep(2)
    GPIO.output(direction, 0)
    GPIO.output(step, 0)[/url]
    GPIO.output(step, 1)
    GPIO.output(step, 0)
    GPIO.output(step, 1)

http://picpaste.com/pics/image__1_-GQMmpVPP.1377577802.jpeg
http://picpaste.com/pics/image-4nLOSUYR.1377577708.jpeg

Hello.

I do not see a Pololu stepper motor driver in those pictures. Which product, specifically, are you having trouble with?

Also, I don’t see any delays between your step pin state changes. If you really are using an A4988 driver, for each step cycle, the pin needs to be high for at least one microsecond and low for at least one microsecond. Is your Raspberry Pi actually conforming to these requirements?

- Ben

It’s an A4988 stepper driver from botronicz, but is a direct replacement for a pololu.

There were sleeps in my python code, but I removed them for the sake of brevity. Even so, without the sleeps it still does the same thing. In debugging I have stepped though my code using pdb, watching the voltages present with my multimeter. The time between stepping down and back up again can be fractions of a second or multiple seconds, it still will only step after two low/high cycles.

Perhaps botronicz could help figure this out. I noticed that their product blurb says “Tested!”, which is certainly reassuring.

Since this is not about a Pololu product, I have moved this thread to the general electronics forum. Further discussion here is still welcome.

- Ben

I’ve been debating buying a new driver for awhile, since this one has been nothing but problems (thanks botronicz!), so I just ordered a DRV8825.

Thanks for your order; I certainly hope it works better for you. If you continue to have trouble, we can take a deeper look at your setup for problems. Don’t forget to set an appropriate current limit.

- Ben