Arduino CNC Shield library

Hello all! I wrote a lightweight library for the Arduino CNC Shield (Arduino CNC Shield – 100% GRBL Compatable | Protoneer.co.nz) and I want to share it with you, maybe someone else finds it useful. The purpose of the library is to use the CNC Shield without the need of GRBL.

I bought the CNC Shield to use it in a personal project, but I don’t need to use GRBL and I didn’t want to “hack” my way around that so I decided to write a library which suits my needs. I figure it could be useful to others too as it is simple to use and it’s a sort of out of the box solution for driving your motors with the CNC Shield.

Below is a sketch that uses the library and the link to the github repo. Let me know what you think and if there are some features that you’d want to see implemented.

#include <CNCShield.h>

#define NO_OF_STEPS               200
#define SLEEP_BETWEEN_STEPS_MS    15

CNCShield cnc_shield;
StepperMotor *motor = cnc_shield.get_motor(0);

void setup()
{
  cnc_shield.begin();
  cnc_shield.enable();

  motor->set_dir(CLOCKWISE);
  for (int i = 0; i < NO_OF_STEPS; i++) {
    motor->step();
    delay(SLEEP_BETWEEN_STEPS_MS);
  }

  motor->set_dir(COUNTER);
  for (int i = 0; i < NO_OF_STEPS; i++) {
    motor->step();
    delay(SLEEP_BETWEEN_STEPS_MS);
  }

  cnc_shield.disable();
}

void loop()
{
  // put your main code here, to run repeatedly:
}

Github repo: GitHub - CostinV92/CNCShield

victorc92: I bought the CNC Shield to use it in a personal project, but I don't need to use GRBL and I didn't want to "hack" my way around that so I decided to write a library which suits my needs. I figure it could be useful to others too as it is simple to use and it's a sort of out of the box solution for driving your motors with the CNC Shield.

Thanks for sharing.

I'm not clear as to why someone might want to use your library in preference to using GRBL.

...R

I think it's a little bit more beginner friendly as at a first glance GRBL looks kind of overwhelming, especially if you don't plan on using g-code. Of course my library isn't intended as a replacement for GRBL, it's just an easier first step into using the CNC Shield.

victorc92: I think it's a little bit more beginner friendly as at a first glance GRBL looks kind of overwhelming, especially if you don't plan on using g-code. Of course my library isn't intended as a replacement for GRBL, it's just an easier first step into using the CNC Shield.

My brain still seems to be slow tonight.

What would somebody use your library for? If you already have GCode then GRBL is easy to work with.

As your library doesn't use GCode then how is it used? (and I don't mean to imply that it is bad not to use Gcode).

Documentation for a library should start with a good description of what it can be used for and what it is not intended for so the user can easily figure out if the library might be useful to him or her.

...R

We get people using the shields for NON CNC purposes on a semi regular basis so such an approach may be useful for them.

Thanks for adding to the diversity of the shield.

Bob.

ballscrewbob: We get people using the shields for NON CNC purposes on a semi regular basis so such an approach may be useful for them.

That may indeed be what the OP has in mind. I am hoping that he will explain his library.

...R

Sorry for not being more specific! As ballscrewbob has said the library is intended to be used in non CNC projects. For example I plan on using it for a telescope motor drive.

For now, the library can be used to step a motor connected to the CNC shield, in a previously set direction. Nothing too fancy. The idea is to build around it. I chose to share it because I saw people asking for examples using the CNC Shield without GRBL and I figured it could be handy for someone who doesn't want to figure out which pin goes where, what should they do to enable the shield etc. Or maybe they want just to quickly test their shield/driver/motor. Like I've said before, nothing too fancy.

I think that if you took a little care in explaining it with diagrams etc it might make a nice tutorial. Clearly don't rush that if you decide to do so but I think a little more detail etc would be worth the effort.

Bob.

Karma also added.

I am really interested in this, especially with my telescope mount. What commands are in use, and does it move with slow acceleration as well?

At this point I am using this shield, and sending reasonable amount of commands to simple tasks is not not simple enough for me.

Could you document this a bit, it might be a success after all! Thanks!

Cheers, Kari

@GaryP

There is a huge amount of telescope mount projects out there using either stand alone drivers and the CNC shield. Some of those are already documented quite well.

Just as an FYI.

Yes, I know, and I also have three commercial controllers on my mounts. This time it is more like "just another device" to control groundscopes, looking for something faster, but nicely controlled movements. I ahve donr it already, but, still, who knows if there's another way to design a wheel. Thanks anyway!!!

Cheers, Kari