Stepper motor 200 step 1.8 deg + Ramp 1.4 + Arduino Mega

187 views
Skip to first unread message

Aymen FODDA

unread,
Dec 8, 2024, 7:41:46 AM12/8/24
to accelstepper
Hello,

Currentl I am working in a project withStepper motor 200 step 1.8 deg + Ramp 1.4 + Arduino Mega and I am looking for a simple Arduino code in order to control 3 steeper motor.

Can someone help ?

Thanks in advance.

Aymen

Jim Larson

unread,
Dec 8, 2024, 6:33:20 PM12/8/24
to accelstepper
Hi Aymen -

Need some basic information:
What are you trying to do?
What have you done so far?
Can you please post your code and tell us what's not working or what your questions are?

       -jim

Aymen FODDA

unread,
Dec 11, 2024, 4:20:47 AM12/11/24
to accelstepper
Hello Jim,

Thanks for your feedback.
Actually, I am working in Robot Arm project and I am tryinig to use Stepper motor 200 step 1.8 deg + Ramp 1.4 ( to control 5 axis) + Arduino Mega.

Currently, I am trying to control just one motor but the problem the motor vibrate without any movement - seems a current or Voltage issue.
Power supply: 12 V - 4.7 A.
StepperMotor: 1.7 A
Driver adjusted A4988 adjusted to Vref 1.2 V (1.5 A) but doesn't help.

Here is the simple code used:

int ledPin =  13;    // LED connected to digital pin 13
int enx = 38;
int stepx = 54;
int dirx = 55;
 
void setup()   {                
  // initialize the digital pin as an output:
  pinMode(ledPin, OUTPUT);    
  pinMode(enx, OUTPUT);    
  pinMode(stepx, OUTPUT);    
  pinMode(dirx, OUTPUT);  
  digitalWrite(enx, HIGH);
  digitalWrite(stepx, LOW);
  digitalWrite(dirx, LOW);
 
}
 
void loop()                    
{
  digitalWrite(enx, LOW);
  digitalWrite(dirx, HIGH);
  digitalWrite(ledPin, HIGH);   // set the LED on
  for (int x = 0; x<800; x++){
    digitalWrite(stepx, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepx, LOW);
    delayMicroseconds(1000);
  }
  delayMicroseconds(500);     // wait for a second
  digitalWrite(ledPin, LOW);    // set the LED off
  delayMicroseconds(1000);    // wait for a second
}

Thanks for your help.
Aymen

Jim Larson

unread,
Dec 12, 2024, 1:38:24 AM12/12/24
to accelstepper
I will try your setup and software tomorrow and try to find out what's wrong.
        -jim

Jim Larson

unread,
Dec 12, 2024, 3:20:01 PM12/12/24
to accelstepper
Good news and bad news, Ayden. I copied your code and ran it on an Uno with the same sort of driver you have on the Ramp1.4. Worked perfectly! Motor runs great. I had only the step and direction connected; Enable was not connected (default level).
I tried turning the drive current up and down.The motor would stop with low current, but never vibrates. That was with no load on the motor. You might try varying the voltage while your sketch is running and see what happens. I've seen cases where the motor will vibrate if the current is either too high or too low. It won't hurt to turn the current control pot while the sketch is running and the motor is connected.
I'm sorry I can't nail down the problem more specifically.But at least you know your code is OK.
    -jim

Ross Waddell

unread,
Dec 12, 2024, 4:25:34 PM12/12/24
to accels...@googlegroups.com
I had similar vibration issues using a A4988 stepper motor driver which disappeared when I switched to the TMC2208 Silent StepStick. Not only did the vibration disappear, but the steppers were almost inaudible. The TMC2208 has the exact same pin outputs as the 4988 so you can just drop it in to the same connections. Adjusting the current limiter using Vref and the pot is key, of course.

--
You received this message because you are subscribed to the Google Groups "accelstepper" group.
To unsubscribe from this group and stop receiving emails from it, send an email to accelstepper...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/accelstepper/38d3a93c-4216-4015-bc6f-eb7e142efa3en%40googlegroups.com.

Jim Larson

unread,
Dec 12, 2024, 6:22:08 PM12/12/24
to accelstepper
One more thought: make sure you have your motor hooked up properly to the driver! And verify the connections for Step and Direction. Make sure they aren't swapped.

Aymen FODDA

unread,
Dec 21, 2024, 3:36:57 PM12/21/24
to accelstepper
Hello,

Jim and Ross, I appreciate your input.
Actually, the driver A4988 was the cause of the problem, and after swapping it out for the DRV8825, the stepper motor began to move.
I am using this code right now, and it seems to be functioning correctly, as seen in this video, but the motor moves very slowly:


Arduino Code:

// defines pins numbers
const int stepPin = 0;
const int dirPin = 1;
 
void setup() {
  // Sets the two pins as Outputs
  pinMode(stepPin,OUTPUT);
  pinMode(dirPin,OUTPUT);
}
void loop() {
  digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction
  // Makes 200 pulses for making one full cycle rotation
  for(int x = 0; x < 200; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000); // One second delay
 
  digitalWrite(dirPin,LOW); //Changes the rotations direction
  // Makes 400 pulses for making two full cycle rotation
  for(int x = 0; x < 400; x++) {
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500);
  }
  delay(1000);
}

Best regards
Aymen

Jim Larson

unread,
Dec 21, 2024, 7:59:30 PM12/21/24
to accelstepper
Try adjusting the drive current. With the motor being stepped continually, slowly adjust the current control (Vref pot). Try increasing and decreasing it while noting the response of the motor. Avoid leaving the current turned up for long periods or the motor will heat up. I can't come up with any other plausible explanation for the behavior in your video.

HTH
                -jim
Reply all
Reply to author
Forward
0 new messages