-1
\$\begingroup\$

I want to develop a simple C# application to control a self-made CNC machine using Arduino Uno. I want to use G-code to accomplish that. Now what I don't understand is how G-code is interpreted in Arduino? and how does it determine at which pin (GPIO) I set the spindle motor for example, or any other motor? I am sure that my understanding of the G-code working process is not very good, and here where I add the question: are there standards that force me to choose specific pins to control the CNC motors? or the G-code interpreter itself determines the pins in which the motors are set at? Thanks in advance..

\$\endgroup\$

closed as too broad by clabacchio Dec 27 '18 at 14:40

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

  • \$\begingroup\$ By the sound of things you are out of your depth. Have a look for GRBL 1.1 which can be loaded on an Uno and converts gcode into stepper pulses. It might save you a lot of trouble. \$\endgroup\$ – Transistor Dec 27 '18 at 13:16
  • \$\begingroup\$ Indeed, an Arduino cannot understand G-code without being loaded with a program to do so. Multi-motor sequencing is non-trivial to implement. The answer to this question will be entirely dependent on the program chosen or written. \$\endgroup\$ – Chris Stratton Dec 27 '18 at 13:20
  • \$\begingroup\$ @Yuri: When you write a program for a microcontroller such as that in the Arduino you are free to assign any function to any suitable pin. If you use someone else's code then they may have made that decision for you. Have a look at GRBL 1.1's pinout, for example. Expect to spend some time figuring out how to control it but the basic idea is that you will send gCodes to GRBL and it will generate the pulse and direction signals for the motor drivers based on the configuration details you have saved in it. \$\endgroup\$ – Transistor Dec 27 '18 at 15:12
1
\$\begingroup\$

G code only knows the axis that you are commanding. The interpreter (which you should list but did not) then takes the G code commands and translates them to Motor commands. In the general style of Arduino, there is usually some sets of #defines that will set the pin assignments. Something like

#define Y_axis pin3

\$\endgroup\$
  • \$\begingroup\$ The interpreter is the Arduino itself (Atmega MCU), isn't that true? another thing, are you saying that the interpreter itself translates my #define commands to know which pins I assigned to motors? \$\endgroup\$ – Yuri Dec 27 '18 at 14:32
  • \$\begingroup\$ @Yuri No, the Arduino is a microcontroller, not an interpreter. The microcontroller gets loaded with code, that code is the interpreter. The code accepts some type of data stream that sends G code commands. These commands get received, interpreted, and then commands get sent to motors. The code is a library. As part of setting up the library #defines are used to establish parameters. \$\endgroup\$ – vini_i Dec 27 '18 at 14:51
  • \$\begingroup\$ Thank you, now I really understand the situation. \$\endgroup\$ – Yuri Dec 28 '18 at 11:22

Not the answer you're looking for? Browse other questions tagged or ask your own question.