Need help controlling my CNC, hardware is ready

Hi there, I always put effort on research before asking, but I'm lost and the readings are taking me in diff directions that seem a dead end. I'm a computer software programmer, yes I built basic Arduino stuff before.

So, just built my CNC hardware. Arduino Uno + L293d shield, two stepper motors + 1 servo + 2 limit switches (for X & Y axis each one). It works, I can use the Arduino IDE and and code to make the motor turn and draw like a plotter: lines, boxes, rectangles and stairs/shapes. Only 2 limit switches? I thought just needed the inner/home position for 0,0, the incremental on code is easy for me to figure the outer limit, I can expand this but this is not the matter, just the context and description.

So the hardware is ready, long story short I have the "motors" on code as objects: motor1, motor2, servo. But just can't figure out how to send gcodes/shapes, etc to it. I thought there was some general sketches around, even so I'm think I can write a listener. Found stuff on grbl, LinuxCNC, etc but still confused. I thought I could manage an Arduino Sketch for moving the motors and then just having something sending signals (XY) etc.

Problem? just like many tutorials around, they describe the set up (hardware), then "use the code from X place and it's done" but there is no detail. I'm finding "upload firmware", etc but nothing else. I see abundance of tutorials lacking specifics in this area except for two, but they are not complete (one guy talks about drawing lines only, and the other states exactly what I'm describing but the thread was abandoned). Grbl wiki says is not compatible with H-bridges and regarding documentation it seems using the L293D is a dead end there.

Thanks in advance. Perhaps I'm seeing lots of trouble when this is actually easy.

You need a G code interpreter.

You need a G code interpreter.

Unless I got something wrong...
Oh really? that's obvious and your short-one-line sure comes rude, sorry there is no value on that.

I was not sure if you were using the correct search terms.

The github and scourceforge would appear to be the best bet.

The reprap forums are another possibility.

I do not know of a reliable g code interpreter for a uno though one i use will not fit on it

This thread seems to discuss the problem

Discussion on cnc has been relatively quiet for the last couple of years

FWIW i use the tinyg board which has a fairly active forum.

This link

Has a download zip button which i think is what you need

This explains how to get the ide to accept the hex file.


Just a thought, are you looking for an arduino ide sketch for this ?

If so i think you are out of luck.

Grbl is written in visual C so if you want to tinker with the code you will have to get a copy.

This won't give you everything - you'll have to "flesh it out" - but it seems like it might be a decent start:

How to build an 2-axis arduino CNC gcode interpreter

Then you have the RepRap interpreter:

RepRap G-code Interpreter

...but it is likely too big for an Uno - but it will have code you can look at, which might help.

There's also GRBL - which is made for the ATMega328 based boards (Uno, etc):

What you probably should do is go through the RepRap interpreter, and take note of which codes you want or need for your machine. You will not need all of them; probably just a few, like:

  1. Basic initialization codes - (G20 - set units to inches, G21 - set units to millimeters, G28 - move to origin (home), G90 - set to absolute positioning, G91 - set to relative positioning) - there might be a few others you might want (maybe M17 and M18 to control power to the steppers) - or you might pare down the list (ie - G20/21 could be eliminated if you wanted to use a fixed unit system of some sort, G90 and 91 could go, too - if you do that on the PC side, etc).

  2. Codes to move to an arbitrary point - (G0 & G1)

  3. Pen up/down codes (which might have to re-purpose other codes - like M3 & M5, or M401 & M402)

  4. Maybe M0 - unconditional stop, M1 - conditional stop, and M2 - program end

Note that some/most codes assume a Z-axis involvement; you can just ignore that, pass 0s, whatever.

So - on the PC side of things, you'll also need to write something that can convert your drawings (vector art or whatever) into your custom g-code scheme. You might be able to find such a converter that you can customize or configure - so look for it - but don't be surprised if you don't find anything, either. In that case, you'll have to create your own conversion software specific to your g-code needs. This software would take a file and render it to move the pen up and down, move to points, and draw as needed - lines and boxes (and other simple geometric shapes) are easy, circles are moderately difficult (you'll have to break them up into small line segments), and curves will be much harder. You'll see on the RepRap codes there is one to move in an arc - which is used for circles and curves. Likely, though, you won't be able to get that code in place on an Uno due to lack of code space - so you'll need to do it on the PC side, and turn it into line segments.

Another possibility is to find a postscript to g-code translator - like this:

I can't vouch for that code - it's just something I found while googling. Alternatively - you can find the specs to postscript - and try to implement a custom postscript translator - for custom commands or whatnot on the Arduino controlling your CNC; ie - don't make a g-code interpreter on the arduino - make something custom - though in all likelyhood, it might not be any simpler than a g-code interpreter.

Here's a couple of other Arduino Uno g-code interpreter things I found:

Let's Make a 4-axis CNC Gcode Interpreter for Arduino - YouTube - there's a link to the github with the code in the video explanation

So - you have plenty of options to at least try out. Good luck!

Thinking on i think the best idea would be to get grbl as all the complicated work is done for you, then modify it for your motor controller.

For CNC work most driver boards use the step/direction method which is why the software out there is written this way.

As i mentioned you will need visual studio or similar (its free).

Problem? just like many tutorials around, they describe the set up (hardware), then “use the code from X place and it’s done” but there is no detail.

Like every computer programming problem you need to approach the problem in small steps (forgive the pun).

  • It seems that you have an Arduino board that can make your motors move in an orderly manner.
  • What instructions does it need in order to do that?
  • Where do the instructions come from
  • Perhaps they are just entered manually in the Serial Monitor. If so you could write a PC program to send the same instructions from a file on the PC.
  • Quite separate from all of that there is the business of getting the correct set of instructions to replicate a drawing.
  • The usual way to do that is with other (PC) software that produces GCode. GCode is pretty much the standard way to define moves by CNC machines.
  • When you have the GCode file you also need software to convert the GCode into the instructions that your machine actually uses to make the motors move to X or Y.
  • One option is to write your own converter program (either for your PC or your Arduino) that will convert the GCode into commands for your machine.
  • The Arduino program GRBL includes a GCode interpreter and code to control stepper motors. However it is a complex piece of code and adapting it to work with your hardware may not be simple.

I have three stepper motors on my small lathe and I have written a Python program (on my PC) to convert GCode to the instructions needed by my Arduino Uno.
I also wrote a Python program to convert simple 2-D black and white images into GCode.


An L293D shield and two stepper motors?

Can you convince me you have the right hardware? Which stepper motors? Why not
using stepper drivers? Does the shield have 2 L293D's? What torque and speed are
you expecting from the motors? What power supply?

It seems a "misunderstanding" created a gap, felt it didn't make sense to "feed" what seemed a troll. So I had abandoned the thread until today, but the cnc is working fine since two days ago, and using a DIY laser engraver, thanks for writing the long kind texts, my software developer mind says things can be done in a very diff ways and approaches.

Was familiar with most references and links as I said "I take time to research before asking". So, thanks for the time.

didn't make sense to "feed" what seemed a troll.

What gave you that idea? (serious question)

my software developer mind says things can be done in a very diff ways and approaches.

If that means you have a different approach to the replies you received here I would appreciate it if you would share your approach.


What gave you that idea? (serious question)
If that means you have a different approach to the replies you received here I would appreciate it if you would share your approach.


Translate the thread into needing a constant voltage and constant current: "you need a driver"
translate the thread into can't remove macintosh weird screws: "you need a screwdriver"
and in the same style I could answer your question, but it would be rude, right?
I just didn't think it was logical at the moment

I find difficult to post on this forum at this point, bad start I should say compared to stackoverflow just to say something, perhaps that's what happens when reading at 1am, but to me it was "get out of here", just checked the thread before deleting from bookmarks, well, things are done, it works, that's what matters. Thanks for asking.

I just didn't think it was logical at the moment

I'm not sure what you mean by "it"

If you are referring to my Reply #7 then perhaps the problem is the imbalance of information between us. Everyone who asks questions here starts off knowing a great deal more about his/her own project than we do. But if we are to make sensible suggestions we need to share a lot of that knowledge.