Can't Get My A4983 Set Up Again

http://www.youtube.com/watch?v=HljKA6N88uc&feature=youtu.be

I bought a couple of A4983 replacement boards and hooked one up to my 1205 motor. I had this running quite well a few months ago when I last had it all set up. I can’t get it to run right. I don’t know what I have done wrong.

The motor runs smoothly but slowly and it won’t stop. I tried different sets of code and get the same results. I set the for loop to only run 10 steps. I added different delays but they are ignored. I thought that the Arduino wasn’t getting updated so I took out the code void loop except for one integer. The motor reacted by not running and locking up like I thought that it would. When I put the write code back in, it runs as before.

What can I do to fix this?

This is one of the sets of code that I used.

[code]#define stepPin 42
#define dirPin 44
#define enablePin 46

void setup()
{
// We set the enable pin to be an output
pinMode(enablePin, OUTPUT);
// then we set it HIGH so that the board is disabled until we
// get into a known state.
digitalWrite(enablePin, HIGH);
Serial.begin(9600);
Serial.println(“Starting stepper exerciser.”);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
}

void loop()
{
int j;
digitalWrite(enablePin, LOW);
delayMicroseconds(2);
digitalWrite(dirPin, HIGH);

for(j=0; j<=10; j++)
{
digitalWrite(stepPin, LOW);
delayMicroseconds(2);
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
Serial.println(j);
}
digitalWrite(enablePin, HIGH);
delayMicroseconds(10000);
//delay(3000);
Serial.println(j);
Serial.println(“Loop”);[/code]

Hello.

The loop section of your sketch will loop through all of the code that is contained inside of it. So, even though your for loop terminates after j reaches a value of 10, the entire routine will begin again after all of the code inside has finished executing. I suspect that your stepper motor looks like it is continuously moving because the first and last few lines of code in void loop don’t take very long to execute. To fix this, you can insert a “while(1)” at the end of your loop routine. For example:

[code]void loop()
{
int j;
digitalWrite(enablePin, LOW);
delayMicroseconds(2);
digitalWrite(dirPin, HIGH);

for(j=0; j<=10; j++)
{
digitalWrite(stepPin, LOW);
delayMicroseconds(2);
digitalWrite(stepPin, HIGH);
delayMicroseconds(1000);
Serial.println(j);
}
digitalWrite(enablePin, HIGH);
delayMicroseconds(10000);
//delay(3000);
Serial.println(j);
Serial.println(“Loop”);

while(1);
}[/code]

-Jon

Thank you for writing back. I tried the code but it didn’t change anything. I tried changing to for(j=0; j<=50; j++) but that didn’t help either.

Can you try moving “while(1);” to the top of loop() and tell me what happens when you run the sketch?

If you are still having problems, it would be useful to know more about your setup. How are you supplying power? Can you post a picture of your setup that clearly shows how you have everything connected? To make your code a little simpler to troubleshoot, you might also try removing non-essential statements like Serial.println() commands.

-Jon

Hmmmm,

I put it above the variables and it rans for 3 seconds and then stops. When I hit the rest button I got the same 3 seconds over and over again. Then I changed the for(j=0; j<10; j++) to different values and the time that it ran didn’t change.

Next I took the while(1); out and put it back in just about the for and the motor just ran without stopping like before.

This is my setup only with a standard wire for ground.

When it comes to troubleshooting, whenever possible, simplify. Once you establish working and predictable behavior from your stepper motor, you can gradually build your sketch and connections into something more complex. For now, I recommend connecting your hardware minimally. The ENABLE pin is tied to ground internally, so you can remove that connection to the Arduino, and you can tie the DIR pin to GND or VDD and connect a single wire to toggle the STEP pin (make sure your Arduino and driver have a common ground, though). Then, you can write a minimal sketch that toggles the STEP pin and then does nothing (i.e. uses “while(1);”).

As I mentioned in my last post, if you are still having trouble, posting a picture that shows exactly how you have connected everything will allow me to check if everything looks fine.

By the way, we have not sold boards with the A4983 chip on them for almost 2 years. Can you verify whether you are using the A4988 carrier with voltage regulators or the A4983 carrier with voltage regulators? Where did you get the boards from?

-Jon

Thank you for your help. I believe that I found the problem.

http://www.youtube.com/watch?v=dK4hXVRhH2k

I think that I have a problem with my pin 44 on the Arduino. When I move the three pin connector from 42, 44 and 46 to 32, 34, and 36, it runs just like before. It also works on 43, 45 and 47.

Thanks again.

I am glad you figured out the problem. Thanks for letting us know!

-Jon

I am getting funny results that I can’t figure out. I do have the A4988 after all.
http://youtu.be/QXFonV0ueiY
http://youtu.be/8bcW0TYHw5g
This is the code that I am using.

[code]#include <Stepper.h>

#define stepPin 23
#define dirPin 25
#define enablePin 27
int raiseTheBoomSteps = 620;

void setup()
{
Serial.begin(9600);
pinMode(stepPin, OUTPUT);
pinMode(dirPin, OUTPUT);
digitalWrite(enablePin, HIGH);
}

void loop()
{
int j;
int accelerate = 5000;
digitalWrite(enablePin, LOW);
delayMicroseconds(2);
digitalWrite(dirPin, LOW);

for(j=0; j<=raiseTheBoomSteps; j++)
{
digitalWrite(stepPin, LOW);
delayMicroseconds(2);
digitalWrite(stepPin, HIGH);
delayMicroseconds(accelerate);
if(accelerate >= 1024)
{
accelerate = (accelerate - (accelerate/199));
}
}
while(1);
//delay(5000);
// digitalWrite(enablePin, HIGH);
}
[/code]
I tried using the while(1) as well as commenting that out and using the last two lines instead. I get the same results.

Perhaps I miss-connectted the board and fried something. I just ordered another pair of them but I will continue to work on this one. I have checked and re-checked my connections as much as I can.

I am not exactly sure I know what you mean when you say “funny results”. What are you expecting your system to do and what results are you getting?

It looks like your rack gear is straining to move when you hold it vertically in your second video, which could be because the rack gear is working against gravity. It could also just not be getting enough torque from your stepper motor. You could take a look at the pull-out torque curve for that stepper motor to see what kind of torque it would produce at the speeds you are making it step to get a good idea of whether or not the behavior you are seeing makes sense. (Note that the stepper motor will lose torque as you command it to rotate faster.)

I am also not sure what you mean by “miss-connectted the board and fried something” in your follow-up post. Did something happen that makes you think the board is damaged?

-Jon

I have simplified the code above to isolate this new problem. This new behaviour manifested itself abruptly after taking it out of service and then hooking it back up again. It did not come on slowly, which might point to overheating, bad bearings or a boom slide that has gotten stiffer.

As you look at the video, you will notice that I get the boom to climb at a pretty good pace by using the acceleration code. This is just as I want it to act, although it now falls short of the 620 steps that I tuned it to so that it doesn’t hit the hard stop.

This stepper motor used to hold the boom with no problem for the entire delay period, no matter how long I made it. I never held it long enough to overheat …no more than 10 seconds.

The while(1) which is just there for a test after your suggestion. I normally use the delay instead. Then I reverse the code, in the larger program, to get it the drop or I just shut off the motor so that it can fall (delay(5000); and digitalWrite(enablePin, HIGH);).

The motor should find it much easier to hold its position than to quickly raise the boom, right? Instead it now waits for a short time and then starts to drop and then stop and chatter and drop and so on. That is the funny behaviour that I am talking about.

I think that this simplified code should make the boom shoot up, then stop and hold for whatever period of time that I ask it to and then just drop. That’s it.

It sounds like you are either not getting enough torque (the current limit is set too low) or that the motor driver is overheating (the current limit is set too high). Can you check your current limit again and let me know what you have it set to? Has anything else about your setup changed (e.g. removal of a heat sink, different air flow, etc)?

-Jon

If you mean the current limit pot, I have tuned it several times, both up and down to try and find the sweat spot but no luck. I get this problem right away so I hope that it is not overheating. I haven’t changed anything else that I can think of.

It’s definitely not just torque. When it freezes at the top, it locks. I grabbed the boom at different points in the cycle to test how it feels. The hold force is a lot stronger than the acceleration force. Of course I could overcome it but it held like a rock and then let go and held and let go again. It didn’t just slip from lack of torque.

The movement was also not completely consistent so I’m thinking that something is damaged or badly connected. As you look at the behavior in the video, does it make you think of anything? Have you seen this before?

Turning the pot back and forth to its extremes like that without checking to see what the current limit is actually set to is not a good way of setting the current limit and might damage your stepper motor (i.e. you could potentially allow too much current to pass through the driver to the stepper motor and damage its windings).

If the stepper motor provides enough torque for your project, it seems like the stepper motor driver is overheating. Can you set the current limit to an appropriate value for your stepper motor? (If you are still using our #1205, that should be around 670mA.) Instructions for measuring and adjusting the current limit using the Vref via can be found under the “Current limiting” section of the driver’s product page.

-Jon

I went looking through some notes and though I would try to measure the Vref voltage directly so I hooking the DIR and STEP pins to ground. Then I hooked the black lead of the analog meter to the ground and the red to the REF pin.

Is that right?

What do I turn the indicator to? DVC? Then I am looking for 270 mV? On which scale?

It sounds like you are correctly setting up to read the Vref via. A reference voltage of 270mV would correspond to a current limit of around 670 mA, which is appropriate for that stepper motor; you should adjust the board’s potentiometer until you measure this DC voltage with your multimeter.

Unfortunately, I cannot give you specific advice on how to use your multimeter, but there should also be plenty of resources online to help you figure out how to correctly use it, especially now that you have a good idea of what you want to measure.

-Jon

http://www.youtube.com/watch?v=eM0pB1mqLMA
This is a youtube video that I posted for another purpose. Can you tell what I sould do to set it?

Unfortunately, I don’t know anything about this stuff.
I have DCV 300, 250, 50, 10, 2.5
and DC mA 0.5, 10, 250

My guess is that you would want to set your multimeter to DCV 2.5, but as I said before, I really cannot help you figure out how to use your multimeter. Multimeters are essential tools when working with electronics like this, and I strongly suggest you invest the time in learning how to use one. You might find it easier to buy an inexpensive digital multimeter and read through its user’s manual.

-Jon