Problem of sepeed of rotation of nema 17 motor

Hello
I am in trouble :frowning:
I am making a device to measure the thickness using arduino board a stepper motor NEMA 17 17HS4401 a driver L298N with a current supply 12v 2A I have used the library AccelStepper to control this motor
My problem is that the speed of rotation of the motor is slow i need to increse it to respond my need
i tried to change parameters in the function SetSpeed SetMaxSpeed and SetAcceleration to increase the RPM of the motor but the motor vibrate without rotating it does not respond to the new speed
Please Can you help me to resolve this problem because i need my motor with higher speed than 200 step by second
this is a part of my code
void setup()
{
Serial.begin(9600);
moteur_cdrom.setMaxSpeed(200);
moteur_cdrom.setAcceleration(200);
moteur_cdrom.setSpeed(200);
moteur_cdrom.runSpeed();
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);

}

void loop() {

if(digitalRead(3)==HIGH)
{
moteur_cdrom.enableOutputs();

while(digitalRead(2)==LOW)
{

moteur_cdrom.moveTo(moteur_cdrom.currentPosition()- 1000);

moteur_cdrom.run();

}
moteur_cdrom.stop();
moteur_cdrom.setCurrentPosition(0);
moteur_cdrom.disableOutputs();
}

You need to post the complete program.

Assuming you are using the AccelStepper library this is completely the wrong way to use it.

while(digitalRead(2)==LOW)
{
    moteur_cdrom.moveTo(moteur_cdrom.currentPosition()- 1000);
    moteur_cdrom.run();
}

Study the library examples carefully.

Also post a link to the datasheet for the Nema 17 stepper motor. I have a sneaking suspicion it did not come from CD Rom mechanism :slight_smile:

You also need to tell us about the load on the motor - maybe that is holding it back.

The L298 is likely to be a poor choice for driving a stepper motor. Stepper motors work better with higher voltages but then you need a specialized stepper driver that can limit the current to protect the motor.

...R
Stepper Motor Basics
Simple Stepper Code

Azzali:
Hello
I am in trouble :frowning:
I am making a device to measure the thickness using arduino board a stepper motor NEMA 17 17HS4401 a driver L298N with a current supply 12v 2A I have used the library AccelStepper to control this motor
My problem is that the speed of rotation of the motor is slow i need to increse it to respond my need

That seems to be a low impedance bipolar motor, which simply cannot be driven from an L298N at 12V
without overheating and damaging the motor and the L298N. Even if it were suitable you wouldn't
get much speed driving a stepper from a dual-H-bridge chip.

If you want speed from a stepper you must use a current-controlling chopper driver like the DRV8825.

If your motor is 1.5ohm as my googling suggests then you simply need to swap out the 298 for a DRV8825
module and set it for about 1.5A (it will struggle above that). The supply will be fine, but a 24V 1A supply
would increase its top speed.

You should modest settings of microstepping with the DRV8825 and see what works OK, full steps will
probably just vibrate and resonate and miss-step unless the mechanical system has a lot of damping.

Thanks for you proposition
My Motor works with 1.7 A that is written on it
I understand from your posts that the the supplly current is not enough to make the motor working with higher speed.SoI am going to change the current supply 12v with an other 24 v i will keep the L298N driver an i will tell you the result observed

Azzali:
am going to change the current supply 12v with an other 24 v i will keep the L298N driver an i will tell you the result observed

I expect smoke and wasted money.

...R