This is my first thread and my first DIY router (for a college project).
I'm using the Grbl and RepRap software controllers (not at the same time of course). I intend to modify the code of any of them.
What I need to do is to understand how the program transforms alphanumerical data (g code) into pulses for the stepper drivers. This will give some extra value to my otherwise "copy+paste" project. I'd like to know where are the files I should rewrite.
Is this too difficult to do? What else am I missing?
The short answer is "interpolation". Each G-code command tells the tool to move from the current point to another point using a certain trajectory. This trajectory is interpolated - that is, broken into the stepper steps - using the following information:
- The shape of the trajectory - straight line (G0, G1) or arc (G2, G3).
- The feed speed commanded by the G-code.
- The maximum acceleration/deceleration rate of the machine.
- The speed and direction of the next moves (G-code lookahead).
- And much, much more.
In other words, yes, this is difficult and not the right place to start with DIY CNC.
Hi....I didn't quite understand what you meant, but with my limited knowledge of G code programming......you have a G code program that is compiled from a CAD drawing that gets converted to G code by the CAM software............or you hand write it yourself........this is saved on a flash drive and gets loaded to the computer (attached to the CNC machine) via the USB port.
When you hit the "load G code" box in the Mach 3 program you see the code listed in a window.......there is also a function that says "edit G code" in that window too.
If you have the G code on a flash drive you can also open the G code listing file on your computer in Notepad and do an edit for whatever you want........then saving it to the same flash drive as ANOTHER DIFFERENT G code listing with a different name, so that the original is kept for reference and further development ....whatever.
My opinion is....it's better to edit the G code on a separate computer and save it to a flash drive or whatever, and then load it to the CNC machine's computer via USB........the CNC machine's computer should not have anything on it apart from the operating system and Mach 3 ......AND DEFINATELY NOT ONLINE OR CONNECTED TO THE INTERNET.
I believe the original poster did not mean editing the G-code, he meant changing the algorithm that converts G-code into the actual axis movements. Which is a hugely complex issue and definitely not the place for a CNC amateur to start.
Indeed, tearing into something like GRBL is no where near trivial. I expect there are many thousands of hours of development time in it with very intricate knowledge of the AVR processor it is running on.
The source code on GITHUB is pretty nicely laid out to see how the bits work. GCODE.C handles parsing the actual received text. PLANNER.C works to link moves together. STEPPER.C has code for generating the actual pulses.