CNC

Okay so i'm a little new but i'm working on making a program for the arduino to run the MPCNC. I know the general concept code but i'm really having a trouble with getting the arduino to listen for a command through the serial monitor and then i need to split the command into parts depending on what arguments are passed.

So G Code a basic movement has the function call which is the G0 or G01 etc. then it has arguments to pass how far along the x y z axis and also a speed function to determine how fast its gonna trigger steps. anyone able to help with my issue. just need some help being able to listen for a command and then splitting said command into variables to process the G Code.

There are at least two high quality G code engines for Arduino boards (Marlin appears to be the choice for Mostly Printed CNC {MPCNC}; grbl is the other choice).

Is there a reason you want to create your own instead of contributing to an existing project?

but they are all for 4 wire nema motors we currently dont have the finances to buy new motors and are using what we had available to us which are a 5 wire stepper.

Unless I'm missing something obvious that would mean you have to alter the final output stage of an existing G code engine. Which has nothing to do with your original question.

So, back to my question. Is there a reason you want to create your own G code interpreter instead of contributing to an existing project?

We aren't using a breakout board to run the motors we have a quad driver that came with the motors to run the steppers, all of the pre-made programs are made to run a breakout board which we currently don't have and probably won't be able to get because of funding.

Interprering GCode is not too difficult, especially if you limit yourself to a small number of commands. However it is something that I would much prefer to do on a PC, and then get the PC to send the Arduino suitable data for the speed, direction and number of steps for each movement.

If you do want to interpret the GCode on your Arduino the first requirement is to know exactly what is contained in each message that goes to the Arduino. (You should read the following in the context of the 3rd example in Serial Input Basics).

Suppose each GCode command is sent individually as <G01,3,5> (made up values) then the parse example in that link can separate it into three parts. You then need to examine the chars in the first part and match them against the list of commands that you plan to decode.

Hope that gives you some insight into the process.

For my own small CNC lathe I interpret the GCode in Python on my PC.

...R

Robin2:
Interprering GCode is not too difficult, especially if you limit yourself to a small number of commands. However it is something that I would much prefer to do on a PC, and then get the PC to send the Arduino suitable data for the speed, direction and number of steps for each movement.

If you do want to interpret the GCode on your Arduino the first requirement is to know exactly what is contained in each message that goes to the Arduino. (You should read the following in the context of the 3rd example in Serial Input Basics).

Suppose each GCode command is sent individually as <G01,3,5> (made up values) then the parse example in that link can separate it into three parts. You then need to examine the chars in the first part and match them against the list of commands that you plan to decode.

Hope that gives you some insight into the process.

For my own small CNC lathe I interpret the GCode in Python on my PC.

...R

Exactly what I was looking for thank you, for yours tho you have to be able to accept the commands through the serial monitor and then be able to process them with your arduino. But cool, I will take a look at more along that process later on after I get the interpretation figured out.

GRBL has a mod that allows it to do 5 wire unipolar. A little digging will find it.

dcjrracing11:
Exactly what I was looking for thank you, for yours tho you have to be able to accept the commands through the serial monitor and then be able to process them with your arduino.

The data for each move is sent to the Arduino by the Python program.

The data is the number of microsecs for the complete move and the interval between steps for each motor so the Arduino has very little work to do to implement the move. As I have a perfectly good laptop (or three) I reckon it should do the hard work and make life easy for my Arduino.

...R

justone:
GRBL has a mod that allows it to do 5 wire unipolar. A little digging will find it.

but you have to use one of the GBRL motor control boards to tap into the arduin to run a 5 wire what im doing it taking 4 digital pins for my motors and telling one pin at a time to go high and then back low and move on to the next and thoes four pins pass to a quad driver to use the external power for the uinipolar motors.

Robin2:
The data for each move is sent to the Arduino by the Python program.

The data is the number of microsecs for the complete move and the interval between steps for each motor so the Arduino has very little work to do to implement the move. As I have a perfectly good laptop (or three) I reckon it should do the hard work and make life easy for my Arduino.

...R

so your using a basic program on the arduino it listens to when it needs to set a pin high and then low? python is your code runner your just using pyton to tell the arduino to force a pinout?

dcjrracing11:
so your using a basic program on the arduino it listens to when it needs to set a pin high and then low? python is your code runner your just using pyton to tell the arduino to force a pinout?

Not quite.

You cannot send individual pulses over USB with any timing reliability. My Python program gives the Arduino the data for a complete move and the Arduino produces the individual step pulses at the correct times. A complete move might be 100 steps by one motor, 87 by another and 433 by the third. But to simplify things for the Arduino code the PC calculates the total time for the complete move and the intervals between steps for each motor. This ensures that all those strange numbers of steps are completed in the exact same time.

...R