Pages: [1]   Go Down
Author Topic: A4983 stepper driver problems  (Read 3032 times)
0 Members and 1 Guest are viewing this topic.
Overijse, VL
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I posted this on the Pololu support forum but I'm waiting for an answer so I'll just post it here too. I hope some people have a good experience with the A4983 stepper motor driver:

I have problems calibrating and using my A4983 driver with the Arduino UNO. When I connect my 12V DC supply to the driver I smell within 10 seconds solder and see some smoke (melting solder?) from the driver. I cannot see any unwanted solder bridges (that liquid in solder, does it conduct electricity??).
I made following connections (for calibration/current limiting):
- grounded STEP, DIR, MS1, MS2, MS3, and ENABLE
- grounded GND logic supply
- connected SLEEP to RESET
- VDD logic supply to the 5V pin of my arduino
- connected 5V to VDD for selecting 5V logic
- 1A, 1B and 2A connectd to a stepper motor (pololu #1200) to red, blue and black wire respectively.
- 2B is also connected to the stepper motor (with wire green) but got my multimeter between it to measure the current. It measured 0,00mA. So there is current going in but for a reason it can't go to the motor. The grounds are connected to the Arduino's GND pin.

I measured all pins and they are grounded or are high (sleep and reset are high). The used power supply is 12,2 V.
I don't know what I have to do now, hopefully someone can tell me what is wrong. And what can I measure to know if it is still alive? I'm afraid of trying it again cause I may damage the driver even more (if it is still alive).
If you need some extra info ask me please.

Thanks in advance.
« Last Edit: March 02, 2011, 03:34:25 am by Fons1302 » Logged

Overijse, VL
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Wow I feel like a fool. Apparently the problem was that I switched the polarity of the power supply. I was sure it was properly connected so I never checked it! The stepper motor works fine and it is a beauty.
Sorry for posting a unnecessary topic on this forum. How can I delete this topic?

When I was calibrating my motor I heard the local radio station from the motor when I touched the current limit pot on the driver with the screwdriver. Strange to say the least!

**EDIT**
How do you increase the rotation speed of a stepper motor?? I have a 1 microsecond pulse every 2 microseconds at the step pin but with 1 microsecond the shaft turns very sloooow (and can't go below 1 microsecond I think).
« Last Edit: March 05, 2011, 06:56:43 am by Fons1302 » Logged

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10512
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Firstly its not worth deleting the thread - others may come along with the same problem (and same solution) - they search the forum and get a set of possible solutions to their problem!

One microsecond per step?  No no, that's way too fast.  Even with 1/16th microstepping I'd be surprised if you can get to 50kHz without high voltage drivers (32kHz 1/16th steps == 10 revs/second)  But 500kHz?

The limiting speed factor with stepper motors is back-EMF (which increases with speed) and winding inductance (cured with high-current low-resistance windings).
Logged

[ I won't respond to messages, use the forum please ]

Overijse, VL
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Ok thanks,

I thought I could achieve a speed of 1 revolution per second but after some testing with various values the best I achieved was only 1 revolution every 6 seconds. That is too slow for my project (I use pololu's 42x48mm stepper motor).
1 revolution per second means 200 pulses per second (it is a 200 step motor), with full steps this means a time of 5 milliseconds so I was thinking of using a pulse length of 2 millisecond and a time between pulses of 3 millisecond. Is my reasoning correct?
Here is the code I used for testing the optimal pulse:

int stepPin = 2;
int dirPin = 3;
int enablePin = 4;

void setup()
{  
  Serial.begin(9600);  
  pinMode(stepPin, OUTPUT); //STEP output
  pinMode(dirPin, OUTPUT); //DIR output  
}

void loop()
{
  digitalWrite(enablePin, LOW); //enables the driver
  unsigned int lowTime = analogRead(0); //potentiometer for variable low pulse time
  unsigned int highTime = analogRead(1); //potentiometer for variable high pulse time
  lowTime = map(lowTime, 0, 1023, 100, 100000); //from 0,1 millisec to 100 millisec
  highTime = map(highTime, 0, 1023, 100, 100000); //from 0,1 millisec to 100 millisec
  digitalWrite(dirPin, LOW); // direction LOW
  digitalWrite(stepPin, HIGH);
  delayMicroseconds(highTime);
  digitalWrite(stepPin, LOW);
  delayMicroseconds(lowTime);
  Serial.print("lowTime:");
  Serial.print(lowTime, DEC);
  Serial.print(" highTime:");
  Serial.println(highTime, DEC);
}

I hope I don't need another stepper motor for my project. If printers use these motors than something is very wrong here!
« Last Edit: March 05, 2011, 10:34:56 am by Fons1302 » Logged

Overijse, VL
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry that I'm putting the topic back in the spotlights but I'm stuck with my speed control of my stepper motor. I contacted Pololu and my motor should do a few hundred RPM. They told me that the fact I can only reach 10 RPM is due to a bad code. In the post above I posted a code that I used for checking the best pulses. The code below is my code for positioning the motor at a precise angle. I would like to reach 60 RPM which means a pulse every 5 milliseconds (200 step motor) but using 5 milliseconds results in a poor 10 rpm...

If someone as an idea why I can only reach 10RPM please tell me! Could it be due to the use of the delay function? Or maybe my driver is broken (I saw solder smoke a few times because I connected the power supply the other way around)?
I will try another stepper motor and see what it does.
Thank you.

**CODE**

int stepPin = 2;
int dirPin = 3;
int enablePin = 4;

void setup()

  Serial.begin(9600); 
  pinMode(stepPin, OUTPUT); //STEP output
  pinMode(dirPin, OUTPUT); //DIR output 
}

void loop()
{
  int targetValue = analogRead(0); //pot value for the position input
  int actualValue = analogRead(1); // pot value from motor position
  int error = targetValue - actualValue;
  if (error < -3)
  {
    digitalWrite(dirPin, HIGH); // direction HIGH
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(XX); //replace XX with a number (microseconds)
    digitalWrite(stepPin, LOW);
    delayMicroseconds(XX); //replace XX with a number (microseconds)
  }
  if (error > 3)
  {
    digitalWrite(dirPin, LOW); // direction LOW
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(XX); //replace XX with a number (microseconds)
    digitalWrite(stepPin, LOW);
    delayMicroseconds(XX); //replace XX with a number (microseconds)
  }
  if (-3 < error < 3)
  {
  digitalWrite(stepPin, LOW); //when the position is reached stop pulses
  }
  Serial.print("target:");
  Serial.print(analogRead(0));
  Serial.print(" Actual:");
  Serial.print(analogRead(1));
  Serial.print(" Error:");
  Serial.println(error, DEC);
}
Logged

'round the world...
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3115
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Have you got an oscilloscope to verify the timing coming out of your board?

Then, I don't think you'll get an even wave considering you create the pulse to send to the motor after reading the analog pin.

Just as a test, create a simple function like this one:

void loop(){
    digitalWrite(dirPin, LOW); // direction LOW
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(50);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(50);
}

Then, get the load of the shaft, if you have any.
This way there isn't anything that can come in the way of the motor speed control.
According to the manual, the shortest pulse is 1micro second... using 50 should still give you a good response, hopefully better than the current one.

Also, can you define what type of steps you'll be using? I haven't seen any code to see if you'll be using full step, half step, quarter step, etc, etc... maybe you haven't defined these and if they're floating it may "confuse" the driver.

The other thing that may be happening is the current limiting setting that is causing the motor to run slow.

I'm not sure the printer's step motors are the ones that run at high speeds... I need to disassemble one to check it out.

Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Overijse, VL
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Got it!

Used your test code with 500 microseconds and worked very fast and smooth (50 was too fast, the motor made noise but didn't move). The reason why your code worked was because it did not contain serial.print command. It seems that using serial.print is not a good idea. I removed it from my position control code and it worked too. Now I will test the ideal pulse but without using println.

I use full steps cause my position sensors are not accurate enough. I have no load. The motor got warm after some serious stepping exercices but not alarmingly, looks that the current limiting is good.

Thanks for the help. I can go on with my project!
Logged

'round the world...
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3115
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

That sure made my day. smiley LOL

I thought you'd be using half or quarter step or even one sixteenth step. That way you might be able to run with lower intervals... 50 might still be too little, but I think you may achieve less than 500 easily.

I'm not 100% sure about this latest version, but I think the serial port in Arduino is coded to be used by polling. Meaning that the software stops and sends that string and then carries on. Well, serial ports, are normally used by interruption, which doesn't cause the same effect that you've witnessed, but I don't think there's a library for that.
Same goes with the analogPin functions...

So the best, from my point of view, would be for you to check on how to use a timed interruption, set it with the interval you tested to be fit and keep an internal variable to control the movement. Something like this:

Code:

char direction; //0 - Stop, 1 - go left, -1 - go right

void setup(){
    direction = 0;
    create_Timed_Interrupt(); //this function is imaginary.
}

void Timed_Interrupt(){
    if (direction == 1)  DirectionPin = 1;
    if (direction == -1) DirectionPin = 0;
    if (direction !=0)
        PinPulse ~= PinPulse;//change the status of the pin
    else
        Stop_motor();
}

void loop(){

//do whatever you want!!!
}

This way the pulse generation for the speed is always assured. Another idea would be to use a PWM output... that would be even simpler, but you'd have to read a bit about the ATmega328p internal registers.
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

Overijse, VL
Offline Offline
Newbie
*
Karma: 0
Posts: 39
Arduino rocks
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

You're welcome hehe smiley .

Using PWM would be great indeed. I tried using standard PWM (500Mhz) and it works pretty well at quarter and eigth steps. Like you say changing this frequency means I have to understand the ATMega's registers. I want the most efficient result so I will surely give it a try and fine tune as long I can understand what I'm doing. But what I have now is more than enough in fact to start with.
Using home-made PWM, 300 microseconds (thats 1600Mhz pulsing) is still very well and I can use half steps. Don't understand why Arduino's standard PWM doesn't work with full steps (it's slower than the home-made PWM signal).

The fact that the serial part is making it slow is no problem after all. I don't have to use it. But good to know.

I'm not sure if I understand timed interruption. Is it like the BlinkWithoutDelay example? I undrstand that example/technique.
For my project I need to control 3 such stepper motors this means that I will also have to read 6 pots to control them. I don't know if my Arduino UNO can handle all that reading and writing at such a pace without loss in performance. If it can't I will have to find some more exotic/better code.

Thanks.
Logged

'round the world...
Offline Offline
Faraday Member
**
Karma: 41
Posts: 3115
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm not that good with the Arduino programming interface, so I have no idea how to achieve what I said in that fashion. There's plenty of C code around the internet showing how the interrupts work and how to set up the registers to achieve what you want.

If you have a look at Avrfreaks, for example, or even google AVR PWM and I'm sure examples will pop up and maybe even one or two application notes.

If you'll be using 3 stepper motors, maybe the timed interrupt with the code that I presented is the best way. That way you'll be free to connect the stepper motors wherever you want instead of being forced to use the PWM outputs. Although the PWM outputs will give you a better performance as there is no software involved to time the signals.

Reading the AD, can also be made with interrupts... but if the motors are already controlled with timed interrupts or PWM, then it shouldn't be needed.

Again, reading through the manual and checking some examples can teach a few more things about how to get the best of your microcontroller.
Logged

Eu não sou o teu criado. Se respondo no fórum é para ajudar todos mediante a minha disponibilidade e disposição. Responder por mensagem pessoal iria contra o propósito do fórum e por isso evito-o.
Se realmente pretendes que eu te ajude por mensagem pessoal, então podemos chegar a um acordo e contrato onde me pagas pela ajuda que eu fornecer e poderás então definir os termos de confidencialidade do meu serviço. De forma contrária toda e qualquer ajuda que eu der tem de ser visível a todos os participantes do fórum (será boa ideia, veres o significado da palavra fórum).
Nota também que eu não me responsabilizo por parvoíces escritas neste espaço pelo que se vais seguir algo dito por mim, entende que o farás por tua conta e risco.

Dito isto, mensagens pessoais só se forem pessoais, ou seja, se já interagimos de alguma forma no passado ou se me pretendes convidar para uma churrascada com cerveja (paga por ti, obviamente).

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry for digging up an old thread, but I found one thing here that I don't understand:

Quote
I thought I could achieve a speed of 1 revolution per second but after some testing with various values the best I achieved was only 1 revolution every 6 seconds. That is too slow for my project (I use pololu's 42x48mm stepper motor).
and
Quote
I contacted Pololu and my motor should do a few hundred RPM. They told me that the fact I can only reach 10 RPM is due to a bad code. In the post above I posted a code that I used for checking the best pulses. The code below is my code for positioning the motor at a precise angle. I would like to reach 60 RPM which means a pulse every 5 milliseconds (200 step motor) but using 5 milliseconds results in a poor 10 rpm
Wouldn't it be a better idea to switch to full stepping to do, let say 95% of 'turn', and then switch to microstepping to achieve better precision for the final position ?

I would assume that's the way it is done though now that no one suggested it I am a bit lost
Logged

0
Offline Offline
Shannon Member
****
Karma: 162
Posts: 10512
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Microstepping gives much better performance from the motor - more torque, less vibration/noise and less likely to mis-step - probably easier to keep it enabled all the time.
Logged

[ I won't respond to messages, use the forum please ]

Manchester (England England)
Offline Offline
Brattain Member
*****
Karma: 514
Posts: 31553
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Wouldn't it be a better idea to switch to full stepping to do, let say 95% of 'turn', and then switch to microstepping
No that won't work the jump between micro steps and full steps will cause a discontinuity in the motors position.
Logged

0
Offline Offline
Full Member
***
Karma: 5
Posts: 229
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

so if he has to do, let say 1000.125 steps (assuming 200 stp/rev) in one direction he can't use full stepping to get to 1000th step and then cover the remaining 0.125 of step with 1/8 stepping?

Not something I would expect - but thx for your response

I guess I need to learn more    smiley-sad
Logged

Pages: [1]   Go Up
Jump to: