stepper motor or driver problem or i don't know what is happening anymore..

I am trying to build a laser engraver with the arduino nano, the cnc shield V4, and the A4988 drivers and i have reached a point where i have everything and i am testing out the stepper motors. The motors are nema17, and i have watched EVERY youtube video and i have read every forum post related to this topic especially Stepper Motor Basics by Robin2, who i thank for a lot of info, but still, my motors are not working and are only making a humming noise and stop. I adjusted the pot on the driver board to 0.952V, i have uploaded the grbl firmware on the arduino nano, i have connected with laserGRBL and it all works fine, but when i try to move with the arrows from the laserGRBL software the motors are just screaming and then stop... i do not know what to check, and what to test anymore, i tried removing the jumpers, tried every combination of micro stepping, i am out of ideas...please help me.

Please ...

  • Post the program YOU have uploaded to your Arduino
  • Post a link to the datasheet for your stepper motor
  • Post details of your motor power supply (volts and amps)
  • Make a pencil drawing showing how you have everything connected and post a photo of the drawing. See this Simple Image Posting Guide

Do you have a spare A4988 in case one of them is faulty?

...R

Hi,
When you say scream then stop, do they actually move?
Are you sure you have the steppers connected the correct way?

Tom... :slight_smile:

From the zip folder i added the grbl as a library and then from examples i added the "upload" example.
I did not find the exact datasheet for my motors, so i posted the specifications from the shop.
The power supply is my CV CC lab bench power supply and can do up to 30V and 5A.
The connections for now are only the power supply and the motors.

They just stand still and "scream". I have tried switching between the phases, and also flipping the phases, but nothing worked.

grbl-master.zip (295 KB)

If you want to explore GRBL you should try the Univeral Gcode Sender program. It has worked for me without any issues.

I don't know if you have tried testing the motors individually with my Simple Stepper Code. If you did, what was the result?

...R

Hi,
Can you please post the code you are using?
I hope at this stage you just have code that is trying to make the steppers work and no other hardware.
If not then write some code that should JUST drive the steppers as suggested by @Robin2 in post #4.

Tom... :slight_smile:

I have tried testing them individually, i have tested it with your code, and others, and nothing. I have tested the arduino with an oscilloscope and i see nothing on the outputs, currently i have uploaded this code, on the stepPin i see absolutely nothing, and the dirPin goes high, and then low, and then it just stops…i don’t understand anymore what is happening.

const int stepPin = 12;
const int dirPin = 11;

void setup() {
  pinMode(stepPin, OUTPUT);
  pinMode(dirPin, OUTPUT);
}
void loop() {

  digitalWrite(dirPin, HIGH);
  for (int x = 0; x < 200; x++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(1000);
    digitalWrite(stepPin, LOW);
    delayMicroseconds(1000);
    delay(2000);

    digitalWrite(dirPin, LOW);
    for (int x = 0; x < 200; x++) {
      digitalWrite(stepPin, HIGH);
      delayMicroseconds(1000);
      digitalWrite(stepPin, LOW);
      delayMicroseconds(1000);
      delay(2000);

    }
  }
}

The second for loop is contained within the first. I doubt that that was what you intended.

bogdan666:
I have tried testing them individually, i have tested it with your code, and others, and nothing. I have tested the arduino with an oscilloscope and i see nothing on the outputs,

Let's go back to basics. Try the first example from my with no changes other than for the step and direction pins.

If it does not work, please post the program that YOU have uploaded to the Arduino.

Also please post a link to the specifications for the exact CNC shield that you have. I found this link about a V4 shield and it suggests that the pins are 2 to 8 whereas you seem to be using 11 and 12.

Also, note that you probably need to set the EN pin LOW to get any of the motors to work.

...R

Finally i got some movement, the pinout of my shield for the X axis dir is D2 and step is D5, for Y axis dir is D3 and step is D6, the code that i am using is your code, but i changed the pins and the pause to make the motor a little faster, after each stop the motor holds the torque. So, it seems like my motors and drivers are ok? Is there a problem in the grbl library ? or??
You can find the grbl-master that i use in post #3. Also, there are a bunch of settings for the laser engraver software, maybe you can spot something wrong.

// testing a stepper motor with a Pololu A4988 driver board or equivalent
// on an Uno the onboard led will flash with each step
// this version uses delay() to manage timing

byte directionPin = 2;
byte stepPin = 5;
int numberOfSteps = 200;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 40; // milliseconds - or try 1000 for slower steps


void setup() {

  Serial.begin(9600);
  Serial.println("Starting StepperTest");
  digitalWrite(ledPin, LOW);
  
  delay(2000);

  pinMode(directionPin, OUTPUT);
  pinMode(stepPin, OUTPUT);
  pinMode(ledPin, OUTPUT);
  
 
  digitalWrite(directionPin, HIGH);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    delayMicroseconds(pulseWidthMicros); // this line is probably unnecessary
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
  
  delay(3000);
  

  digitalWrite(directionPin, LOW);
  for(int n = 0; n < numberOfSteps; n++) {
    digitalWrite(stepPin, HIGH);
    // delayMicroseconds(pulseWidthMicros); // probably not needed
    digitalWrite(stepPin, LOW);
    
    delay(millisbetweenSteps);
    
    digitalWrite(ledPin, !digitalRead(ledPin));
  }
}

void loop() {
}

bogdan666:
Is there a problem in the grbl library ? or??
You can find the grbl-master that i use in post #3. Also, there are a bunch of settings for the laser engraver software, maybe you can spot something wrong.

Life is too short to take the time to study the GRBL program :slight_smile:

I can't read the picture of your settings in Reply #9. Please just copy and paste it as text within code tags (as if it was program code).

Have you tried using Universal Gcode Sender as I suggested in Reply #4?

...R

i will try it with universal gcode sender, here are the settings for the one i am trying to use

	$0	Step pulse time	20	microseconds	Sets time length per step. Minimum 3usec.
	$1	Step idle delay	25	milliseconds	Sets a short hold delay when stopping to let dynamics settle before disabling steppers. Value 255 keeps motors enabled with no delay.
	$2	Step pulse invert	0	mask	Inverts the step signal. Set axis bit to invert (00000ZYX).
	$3	Step direction invert	0	mask	Inverts the direction signal. Set axis bit to invert (00000ZYX).
	$4	Invert step enable pin	0	boolean	Inverts the stepper driver enable pin signal.
	$5	Invert limit pins	0	boolean	Inverts the all of the limit input pins.
	$6	Invert probe pin	0	boolean	Inverts the probe input pin signal.
	$10	Status report options	1	mask	Alters data included in status reports.
	$11	Junction deviation	0.010	millimeters	Sets how fast Grbl travels through consecutive motions. Lower value slows it down.
	$12	Arc tolerance	0.002	millimeters	Sets the G2 and G3 arc tracing accuracy based on radial error. Beware: A very small value may effect performance.
	$13	Report in inches	0	boolean	Enables inch units when returning any position and rate value that is not a settings value.
	$20	Soft limits enable	0	boolean	Enables soft limits checks within machine travel and sets alarm when exceeded. Requires homing.
	$21	Hard limits enable	0	boolean	Enables hard limits. Immediately halts motion and throws an alarm when switch is triggered.
	$22	Homing cycle enable	0	boolean	Enables homing cycle. Requires limit switches on all axes.
	$23	Homing direction invert	0	mask	Homing searches for a switch in the positive direction. Set axis bit (00000ZYX) to search in negative direction.
	$24	Homing locate feed rate	25.000	mm/min	Feed rate to slowly engage limit switch to determine its location accurately.
	$25	Homing search seek rate	500.000	mm/min	Seek rate to quickly find the limit switch before the slower locating phase.
	$26	Homing switch debounce delay	250	milliseconds	Sets a short delay between phases of homing cycle to let a switch debounce.
	$27	Homing switch pull-off distance	1.000	millimeters	Retract distance after triggering switch to disengage it. Homing will fail if switch isn't cleared.
	$30	Maximum spindle speed	1000	RPM	Maximum spindle speed. Sets PWM to 100% duty cycle.
	$31	Minimum spindle speed	0	RPM	Minimum spindle speed. Sets PWM to 0.4% or lowest duty cycle.
	$32	Laser-mode enable	1	boolean	Enables laser mode. Consecutive G1/2/3 commands will not halt when spindle speed is changed.
	$100	X-axis travel resolution	200.000	step/mm	X-axis travel resolution in steps per millimeter.
	$101	Y-axis travel resolution	200.000	step/mm	Y-axis travel resolution in steps per millimeter.
	$102	Z-axis travel resolution	200.000	step/mm	Z-axis travel resolution in steps per millimeter.
	$110	X-axis maximum rate	10.000	mm/min	X-axis maximum rate. Used as G0 rapid rate.
	$111	Y-axis maximum rate	10.000	mm/min	Y-axis maximum rate. Used as G0 rapid rate.
	$112	Z-axis maximum rate	10.000	mm/min	Z-axis maximum rate. Used as G0 rapid rate.
	$120	X-axis acceleration	2.000	mm/sec^2	X-axis acceleration. Used for motion planning to not exceed motor torque and lose steps.
	$121	Y-axis acceleration	2.000	mm/sec^2	Y-axis acceleration. Used for motion planning to not exceed motor torque and lose steps.
	$122	Z-axis acceleration	2.000	mm/sec^2	Z-axis acceleration. Used for motion planning to not exceed motor torque and lose steps.
	$130	X-axis maximum travel	500.000	millimeters	Maximum X-axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances.
	$131	Y-axis maximum travel	500.000	millimeters	Maximum Y-axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances.
	$132	Z-axis maximum travel	500.000	millimeters	Maximum Z-axis travel distance from homing switch. Determines valid machine space for soft-limits and homing search distances.

bogdan666:
i will try it with universal gcode sender, here are the settings for the one i am trying to use

I don't see anything in that which would give rise to the "screaming" that you mention ... but ...

The speed of 10mm/minute seems extremely slow - I wonder if it is really mm/second

Which also makes me wonder if the 500mm/min is also mm/second - which would be very fast and could give rise to your screaming.

...R

I tried it with UGS, the problem is exactly the same, the motor lock up and make a humming noise and that’s it. I have also modify the settings you pointed out, nothing changed. With your code, i went down until these settings:

int pulseWidthMicros = 1;
int millisbetweenSteps = 1;
to see if my motors skip steps, or tthere is a problem with the power supply or something, but everything is ok…except that it does not work with grbl library.

LE: i finally found the problem, the pins in the shield are inverted for the grbl library, so i have 2 options in my mind, can i invert the pins in the library, and will it have a negative effect over the functionality or do i have to make my own pcb from scratch ?

Change it in software. Hopefully it's just constants to adjust in one place.

bogdan666:
LE: i finally found the problem, the pins in the shield are inverted for the grbl library,

What exactly do you mean?

I think GRBL has a setting that allows things to be inverted.

…R

In the shield, for X axis, step is D5 and direction is D2, but the signal from arduino is step for D2 and dir for D5. I flipped them on a breadboard and it works great. i will search if there is a possibility to invert things, i will post here if i find something.

AFAIK GRBL was specifically written for the GRBL shield and the pinout was designed to be efficient for low level (i.e. fast-working) code so I suspect it cannot easily be changed to work with different I/O pins.

However it would be worth Googling to see if someone has created a version that will work with your nano shield.

I have a small CNC mill that came with a PCB that included a nano and it runs GRBL. The PCB is not at all like yours and I have no idea what pinouts it uses. I'm using a Mega with a RAMPS shield and my own software. The RAMPS shield is not compatible with standard GRBL though there is a version of GRBL for it.

When you used the word "inverted" I thought you meant a swap between HIGH and LOW.

...R

So, a custom pcb it is then, from what i have searched you can only invert the directions of axis. i need only 2 drivers and a diferent pin for the laser, so some modification is needed anyways. English is not my native language, sorry for the confusion, and thank you for all the help :slight_smile:

Hello, I have a similar problem, using Arduino Uno + CNC shield (connected to 12V)+ A4988 + nema 17 bipolar stepper motor (0,7A, 7V, 200 steps, 1,8 deg) this code from the examples I only get my motors to vibrate. I tried 4 units of A4988 thinking of the possibility of a failed module and I moved their potentiometer all the way up and down. (I commented the last part of the code so my motor can turn only in one direction):

#include <Stepper.h>

const int stepsPerRevolution = 200;  // change this to fit the number of steps per revolution
// for your motor

// initialize the stepper library on pins 8 through 11:
Stepper myStepper(stepsPerRevolution, 8, 9, 10, 11);

void setup() {
  // set the speed at 60 rpm:
  myStepper.setSpeed(60);
  // initialize the serial port:
  Serial.begin(9600);
}

void loop() {
  // step one revolution  in one direction:
  Serial.println("clockwise");
  myStepper.step(stepsPerRevolution);
  delay(500);

  // step one revolution in the other direction:
  // Serial.println("counterclockwise");
  // myStepper.step(-stepsPerRevolution);
  // delay(500);
}

Reading message #16 of this thread I am thinking that can be the problem, however I don’t see anything in my code to change that. I searched my hard drive for the stepper.h file and I couldn’t find it! I read the contents of that file on the web but also there I cannot see how to do the swap of pins. Will I need to cut the pins in the board and solder some wires?

Perhaps I can try the code suggested in message #3 of this thread:

https://forum.arduino.cc/?topic=712399#msg4786419

My motors work fine with the L293N module + same arduino + same code.

Many thanks
Best Regards

Marcelo