A4983 stepper motor driver and arduino mega

hello
i’m new with this and i needed some help connecting and writing the code for the pololu A4983 stepper motor driver and the arduino mega… any halp will be greatly appreciated

Hello.

Have you read the web page and datasheet for the A4983? That should give you a general idea on how to connect to the carrier. If you draw up what you think the wiring should be and post it here, we can take a look at it.

- Ryan

i know the basic operation of the driver but i’m confused where i connect to step, direction, and enable to?
do i connect it to digital, analog or PWM?

Step, direction, and enable are all digital inputs. When you say “connect” do you mean in software? Because, in hardware on the ATmega1280, you can use the pins with PWM output and analog input features as general purpose IO.

- Ryan

So the only ones I need to get it running is step, direction, and enable? These are wired to the PWN part of the arduino, right? This is what I am doing and I am still having problems.The voltage and ground seem to be connected fine and the correct power source is connected to the motor. I don’t understand what is wrong. I can hear the motor doing something… please help…
thanks!

Hello.

Can you be more specific about the trouble you’re having? What is the current rating of your stepper motor and what is your driver’s current limit set to? What is your power source?

Instead of using a PWM signal to step the motor, can you see what happens if you just toggle the I/O line at some slow rate (e.g. ten times per second)?

- Ben

I have a Vexta Stepper motor (model PK266-02A) that i want to control using the Arduino Mega. I have the STEP pin connected to Pin PWN # 13, DIR pin connected to Pin PWN # 12, ENABLE pin connected to Pin PWN # 11. Eveything else seems to be connected fine. When I run my program, which is to simply cause the motor to move any number of steps, the motor doesn’t do this. Instead it just makes stepping noise but doesn’t actually move. If i disconnect the ENABLE Pin, it does exactly the same thing.

If you want my help, please answer all of my questions and try what I’ve suggested. By ignoring most of my previous post you are wasting my time by making me ask the same questions over again. Also, if you’re too lazy to look up the specs for your stepper motor or don’t know what to look for, at least provide a link to the product; don’t expect others to google your product for you to search for relevant infomation.

- Ben

ok… there is no need to be rude… i’m just not sure what you are asking…

the current per phase is 1.4 (bipolar)…
the power supply for the motor is a 14 volt camera battery…
i don’t know what the driver current limit is set to…

here is a site of the motor:
catalog.orientalmotor.com/item/s … 3&seo=110#

by the way…
i don’t know what you mean when you say:
toggle the I/O line at some slow rate

Hello.

There is indeed no need to be rude, which I why Ben is trying to help you be less rude. It’s unreasonable of you to ignore Ben’s questions and then get offended when he points out that you’re wasting everyone’s time by not answering the questions.

If you don’t understand what he’s asking for, it’s fine to ask for clarification; it’s not fine to ignore the question.

- Jan

It’s possible the PWM signal you have connected to the STEP input is trying to step your motor faster than it can go, which would cause it to hum at the the frequency of the PWM but not turn. Instead of using a PWM, I suggest you manually step your motor using the pin as a digital output. Set the pin high, delay for 100 ms, set the pin low, delay for 100 ms, and repeat. If your motor turns in response to this low-frequency signal, you know you have things connected properly and that your PWM output is just using too high a frequency for your motor.

Also, I recommend you figure out what your current limit is set to following the instructions on the product page and adjust it to an appropriate value for your motor:

- Ben

look… i’m not here to pick a fight…
i obviously am not trying to be rude… i just came here for help
if i seemed rude… i’m sorry… i guess i just need more time to figure this out on my own…

thanks ben…
i’m going to try that right now…
sorry for all the confusion

Hopefully this will get things working for you, but if you’re still having problems please post your code.

- Ben

I tried toggling the i/o and it didn’t seem to work…
i now think i may have the wires not connected properly…
right now i’m going to double check that and figure out the current limit is set to. I moved the potentiometer from different ranges to see if anything changed and it did not.

I’ll post my code just in case:

#define stepPin 24
#define dirPin 22
#define enablePin 26





void setup()
{
  Serial.begin(9600);
  Serial.println("Starting stepper exerciser.");

  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  
}

void loop()
{
  
    int j;
  
  digitalWrite(dirPin, HIGH);
 
    
    for(j=0; j<=10000; j++) {
     
      digitalWrite(enablePin, LOW);   
      digitalWrite(stepPin, LOW);
      
      delayMicroseconds(2);
      
      digitalWrite(stepPin, HIGH);
      digitalWrite(enablePin, HIGH); 
      delayMicroseconds(1000);     
       
    
    }
    
    
      
    }

thanks for all your help

oh, and i also tried with the delays at 100ms as you said.

Why are you toggling the enable pin every time you toggle the step pin? Did anything in my instructions to you or on the product page make it seem like you should be doing anything with the enable pin other than keeping the device enabled? I apologize if I’m wrong, but it really seems like you haven’t read the datasheet at all for the A4983 and are rather just making guesses about what the various inputs do; this is a very bad way to approach electronics! The enable pin is pulled low on the board, which means that the device outputs are enabled and the board is ready to be used. If you’re having trouble getting the board working, this is definitely the state you want it to be in. I suggest you remove your connection to the enable pin and remove all references to it in your code. Right now your code is disabling the device (and hence turning off the outputs) immediately after every step, so it’s no surprise that things aren’t working for you as expected.

Also, did you take care to verify that the 1A and 1B outputs are connected to one stepper motor coil and the 2A and 2B outputs are connected to the other stepper motor coil? If your stepper motor is not connected to the outputs correctly, it will not work. You can use a multimeter to find the two coil lead pairs for your stepper motor. Please let me know if you need help with this.

Finally, if you have the driver without regulators, you should ground the MS1 pin. You can do this by connecting it directly to ground or by connecting it to one of your Arduino I/O lines that is configured as a driving-low output. If you have the driver with regulators, you can leave MS1 disconnected as it is pulled low on the board.

Once you have it set up properly, just make your main loop simple:

while (1)
{
  digitalWrite(stepPin, LOW);
  delay(100);
  digitalWrite(stepPin, HIGH);
  delay(100);
}

- Ben

Hi Ben
I understand what you are saying. Your instructions did not state anything of the sort with the enable. I initially programmed the enable pin as you said but I’m not sure why or how it evolved to what is there. Someone at school advised me to the enable this way… but my fault for listening to the wrong advice.
I read the data sheet for the motor and I am 100% that the coils are connected properly.
I am going to run by everything and test it.
Thanks for your patience and help

hi guys
i ended up ordering a new pololu driver and it works great…
i used the same code as with the other driver but now it works…
so thanks for all your help