Use cnc shield without grbl

Hi everybody! This is my first post and I’m a rookie in this.

I’m gonna use two 0,4 A steppers, so I got a cnc shield and a a4988 driver for each stepper. I’m not gonna make a cnc. But I bought the shield so the steppers can be powered up easily.

My questiones are the following, do I have to use the grbl software to make my running code for the steppers? (if so, I hope it to be available for MacOS because I have no computer with windows os)

If not, then how do I control them from the IDE without using grbl?

Thanks!

No. You can write an Arduino sketch to move the steppers. Your sketch can set the Direction and Enable pins and pulse the Step pins to cause the steppers to move one step in the chosen direction. Your sketch can use the AccelStepper library to do the stepping for you. It will keep track of current position and your sketch can ask the library to move smoothly to a new position, either absolute or relative.

What kind of control does your sketch need?

1 Like

If we are talking about the CNC shield that attaches on top of an Uno, you can certainly use the CNC shield without grbl.

The pins are:
X step, pin 2 X dir, pin 5
Y step, pin 3 Y dir, pin 6
Z step, pin 4 Z dir, pin 7

Pin 8 is the stepper enable pin. On the CNC shield, pin 8 is held HIGH so the steppers are disabled by default. So set the pinMode for pin 8 to OUTPUT and set it to LOW to enable the steppers.

And the PC operating system is not relevant to grbl. grbl loads onto the Uno. The PC then sends gcode that grbl will interpret.

1 Like

Thanks for answering.

For my project I only need to, let's say, a letter obtained from the serial monitor, move x mm. I'm thinking of coding a function for each letter. To sum up, I would love to make it simple.

So I don't know if it's easier with grbl. Or what's the purpose of using it. So if it doesn't bring something useful, I would rather avoid it.

What you want to do is easy enough to do without grbl. grbl is a gcode interpreter. It would not difficult to write gcode to make the movements, but you could code the movements yourself, too.

1 Like

what do you recommend If I don't want to break my back, to use it or not? I'm kinda confused what grbl is for.
Sorry, I'm a begginer :frowning:

Read here to see what grbl is for.

Robin2's simple stepper code tutorial.

Robin2's stepper basics tutorial.

1 Like

It is very important that you set the coil current limit on the A4988 stepper driver module properly. Failure to do so can result in damage to the stepper motor or the driver.

You must know the value of the sense resistors on the module in order to plug the right values into the equation to calculate the value to set Vref. The Pololu A4988 page has instructions for setting the coil current (make sure to use the right value for Rcs).

1 Like

thank u so much!!

If you describe what you want the steppers to do I may be able to help you with the code. I do have some experience with the CNC shield V3 (AKA the grbl shield).

Which, exact, CNC shield do you have? Can you post a photo?

1 Like

sure. I have another question, I want to use a solenoid controlled by the arduino uno. But all the arduino pins are used by the cnc shield. However, I will only use two drivers ( each for a stepper) as seen on the pic. So how can I connect the solenoid to the arduino? On the cnc shield, too?

See those black and white headers on the right? Those pins connect to pins on the Uno that you can control. Here is an Uno with the pins marked.
cnc shield Uno pins

So, if you have a solenoid you could connect it to the white SpnEn header pin and then write to pin 12 to turn the solenoid on and off as an example.

Does that make sense?

The yellow and blue headers break out things like the I2C pins (for a display, maybe) and the hardware serial pins.

Can I use any digital pin from 9 to 13 as an output to control the solenoid? I get that pin 8 is used for enabling the steppers.

I have another question, why the white header and not the black one? or both?

Sorry for my begginer questions.

Yes, plus the "analog inputs" (A0-A3) , those are digital pins by default.

The black header is grounds. All the black pins are connected together and to ground.

1 Like

Thanks, I think all my answers have been answered but one.

I checked the article you posted about "what grbl is for" and I understand how it works. But I still don't get if I should use it or not. I mean, when should I use it?

Because I would like to make it simple, so If I had to use it, no problem. But I would know when to use it and when not to.

Thanks again, you saved my hide!

Whether or not to use grbl is not a question that I can answer with the available information. Describe what you want to do.

I want the serial monitor to show number characters from a file, and depending on the number, the fist stepper has to spin around the same number of whole turns.
So if in the monitor we get: 1 2 3 4 5 6 7 8
The first stepper has to turn once (360deg), wait, turn twice(720deg), wait and so on. Then when 4 characters are read, the second stepper will spin 2 whole turns and then again, the first stepper will turn, now beginning in 5,wait,6,wait...

I don't know if I explained it well...

So, something like this?

#include <Stepper.h>
const int StepsPerRevolution = 200;

Stepper stepper1(StepsPerRevolution, 2, 3, 4, 5);
Stepper stepper2(StepsPerRevolution, 6, 7, 8, 9);

void setup()
{
  stepper1.setSpeed(60);  // Revolutions per minute
  stepper2.setSpeed(60);  // Revolutions per minute
}

void loop()
{
  static int count = 0;

  int ch = Serial.read();
  
  if (isdigit(ch))
  {
    int turns = ch - '0';

    stepper1.step(StepsPerRevolution * turns);
    delay(1000);
    
    count++;
    if (count >= 4)
    {
      stepper2.step(StepsPerRevolution * 2);
      count = 0;
    }
  }
}
1 Like

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