Help Trouble Shooting CNC Shield V3

I am attempting to control a Nema 17 step motor using the Arduino Uno through the stop motion software Dragonframe, and cannot get any motors to move.

I have the Arduino Uno loaded up with the the sketch provided through Dragonframe located at the bottom.
Attached to that I have the CNC V3 shield you see in tutorials all over the internet. I have an A4988 driver and Nema 17 motor all running through that.

When I run the program, the green light on the Arduino comes on, and when I run a move, the orange light flashes so I'm sure I'm sending signal. I've tried swapping out the shield, drivers, and motor, as well as trying multiple channels both on the shield and in the software. I've double checked the polarity on the polarity and voltage to the motor, and the voltage through the driver potentiometer. When everything is powered, the motor holds firm to a light touch so I know the motor is receiving power, but I can't get anything to move. I've tried using another simple motor move sketch that I found on another thread on here, but that doesn't work either...

Any thoughts? Is there a step I'm missing or a piece I'm not troubleshooting?
Much Thanks

// 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 = 9;
byte stepPin = 8;
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20; // microseconds
int millisbetweenSteps = 250; // 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() {
}

forest88:
void loop() {
}

Hi
why loop() is empty?

I have the Arduino Uno loaded up with the the sketch provided through Dragonframe located at the bottom.

where is the link to the original site?

The CNC shield assigns certain pins to certain functions. The step pins are x=2, y=3, z=4. The dir pins are x=5, y=6, z=7.

The CNC shield V3 seems to hold the stepper enable pin HIGH. You must pull the enable low in software to enable the steppers. Pin 8 is connected to the stepper enable pins. In your software, set pin 8 to and OUTPUT and digitalWrite it LOW to enable the steppers.

Here is how the CNC shield is connected to the Uno.

cnc shield Uno pins.jpg

cnc shield Uno pins.jpg

Connect a stepper to the X axis driver and try this code. It works with my Uno, CNC shield and stepper.

byte directionPin = 5;  // ************** cnc shield x direction
byte stepPin = 2;                 // ***************cnc shield x step
byte enablePin = 8;              // ***************  cnc shield enable pin
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 250; // milliseconds - or try 1000 for slower steps


void setup()
{

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

   delay(2000);
   pinMode(enablePin, OUTPUT);  //******* enable pin
   pinMode(directionPin, OUTPUT);
   pinMode(stepPin, OUTPUT);
   pinMode(ledPin, OUTPUT);

   digitalWrite(enablePin, LOW); // ********** enable motors
   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()
{
}

Have you set the coil current on your stepper driver. It is important that the setting is done properly. Pololu has instructions on how to do the setting (with video).

In the future, please post code using code tags (</> in the menu).

Thanks a ton groundFungus. That code you sent me showed the system was working, and through a thread you posted on 3 years ago, I was able to modify my sketch to work in the Dragonframe software. you're a true hero

Hello, I have the same problem so I want to know if the code provided by user groundFungus in message #3 solved the problem or what solved the problem exactly. What exactly are the model and manufacturer motors you are using? (or at least the specifications).

Now a silly question for experienced users, but important for me: Does the code of message #3 need any headers not posted there? I am surprised it does not include any library

Many thanks. Regards. Marcelo

@lw3eov

AT the very least you need to tell us what YOU are using for motors ?

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

I will look into this when I can.

Now a silly question for experienced users, but important for me: Does the code of message #3 need any headers not posted there? I am surprised it does not include any library

The code is complete. You do not need a library for steppers. If connected correctly to a step/dir type driver this code should test X axis stepper installed on a CNC V3 shield. All the stepper needs, to move, are pulses. This is Robin2's simple stepper code.

byte directionPin = 5;  // ************** cnc shield x direction
byte stepPin = 2;                 // ***************cnc shield x step
byte enablePin = 8;              // ***************  cnc shield enable pin
int numberOfSteps = 100;
byte ledPin = 13;
int pulseWidthMicros = 20;  // microseconds
int millisbetweenSteps = 250; // milliseconds - or try 1000 for slower steps


void setup()
{

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

   delay(2000);
   pinMode(enablePin, OUTPUT);  //******* enable pin
   pinMode(directionPin, OUTPUT);
   pinMode(stepPin, OUTPUT);
   pinMode(ledPin, OUTPUT);

   digitalWrite(enablePin, LOW); // ********** enable motors
   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()
{
}

Thanks for the replies. At the moment I am only looking into the subject of stepper motors to see how far I can go. My intention is to make a 2-axis rotor for antennas and a 3-axis CNC machine to mill and drill PCBs, but I am not sure if I will achieve that.

Today I discovered that my CNC shield has different pinout to some others. I corrected that in the code and now I get the motor to go in one direction, then in the other and then stops. I suppose that is what is meant to do but I need to understand the code line by line and that will take me some time. I used a few programming languages as Qbasic, Dbase III plus, Pascal, Assembler (for microcontrollers), but I find C++ difficult, in my humble opinion it is not that intuitive.

Thanks
Regards

Marcelo

Clearly to need to let us see the shield with a link to it so we know what you are dealing with.

Also the chances are very good that somebody else has already done what you want to do so often finding a sketch with which to start is often easy. That often just leaves some minor tweaking to do.

As for actual CNC usage that becomes a lot easier because the basis for that is simply loading up the Arduino with GRBL which accepts common G-Code commands.

Generating G-code is also quite an easy process with lots of programs that can take care of that for you.

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