Stepper behaviour with A4988

Hello,

I have a project with arduino nano, stepper NEMA17 and driver A4988. It works fine, but there is a problem at starting. Motor turns a little then stops and then motor behave properly accordind to software. I have found out that this is happening during the setup loop (different times of delay(3500) in setup loop helped me to find out).

A4988 datasheet mentions something about home position of stepper. Should be this the problem that on start up the driver turns motor to the specific angle which is defined by "something in the driver"? If so this is pretty bad behaviour.

Note: Arduino board and the numbers of the ports in the picture do not agree with ports in the code. This is because of I took over this picture and edited it.



#define pinSTEP 10 
#define pinMS1 2 
#define pinKoncZp 3 //limit switch

int rychlost = 10; 


void setup() {

  pinMode(pinSTEP, OUTPUT);  
  pinMode(pinKoncZp,INPUT_PULLUP);
  pinMode(pinMS1, OUTPUT); 

  digitalWrite(pinMS1,HIGH);
 
  delay(3500);
}

void loop() {
  
  for (int i=0; i<=20; i++)     //makes 20 steps to go out of the limit switch
    {
    digitalWrite(pinSTEP,HIGH);
    delay(rychlost);
    digitalWrite(pinSTEP,LOW);
    delay(rychlost);
  }
  
  while(digitalRead(pinKoncZp)==HIGH) //keeps turning until the limit switch is closed
  {
    digitalWrite(pinSTEP,HIGH);
    delay(rychlost);
    digitalWrite(pinSTEP,LOW);
    delay(rychlost);
  }
  delay(300);
    
  
}

Datasheet

Each stepper motor needs a known starting position. You have to provide a switch or readable mark for that position and wait until the motor has reached it during setup().

No, the a4988 emits no steps to the stepper on startup. The 'home position' of the stepper stepperdriver is its microstep position when resetted or at startup. It's a microstep position that is common to all types of microstepping and refers to the coil current.
This has nothing to do with the 'homing' of the stepper via an endswitch.

Yes that doesn't nothing to do with homing of stepper via end switch. My problem is the "homing" of the driver (it is not homing but I now I do not know better word). I can do my homing via swith after this starup but imagine you have e.g. machine with carousel with products on it and in the end the product is thrown away. If you restart the machine the driver is "homing", so stepper is turning and your product can be thrown away. It is impossible to control the process at startup.It is pretty bad. I am not aware that e.g. my 3D printer with steppers do something like this on startup. Should be the solution changing the driver?

This is simply the motor turning to the initial phase. Most stepper drivers initialize at 45 (electrical) degrees. This means both windings get equal current.

Standard steppers with 200 steps per rotation have 50 cycles per rotation (each step is 90 electrical degrees). Thus on power up the motor moves to the nearest of the 50 possible 45-degree points, ie upto 2 steps-worth of movement in either direction.

If you want the system to remember the position setting to a more fine-grained precision you'll have to find some other method (there may be some driver chips that store the last position - but I've never looked for one, so maybe not).

So after searching for this issue on the internet I have now the solution. On the startup of the arduino (before setup loop) the pins are probably floating and it causes some pulses on the pin connected to step pin on A4988. The solution is 10K pull-up resistor on this pin. In this case the stepper motor make one pulse (step) in this arduino start up phase which is ok. After that the motor can safely find the first nearest home position on the limit switch.

The driver also has an Enable pin...
Leo..

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.