# Arduino Mega, cnc firmware, and circles! G2+G3!

Hello I'm an architecture masters student, I've been working on a desktop cnc mill(10x8x3) and attempting to keep it arduino controlled, though this is making me bang my head against the wall.

anyhow, I discovered this firmware here

it was written/released in may 2010, and hasn't been updated since, no word from the author, but it's the most friendly I've found and way easier for me to setup and use than the reprap stuff, plus he's implemented a really nice interface that draws gcode in processing. His acceleration seems way smoother than reprap and I can get my steppers moving faster, 60 ipm.

The problem lies in the fact that it seems he has not implemented G2 and G3 gcodes, for arcs/circles. Thats kind of a problem for most gcode I generate at school.

SO, I'm looking for a bit of guidance, I'm not a programmer, but I wanted to learn anyway, so is there somewhere I can be pointed to checkout how implement this within the hydra 1.4 firmware?

I guess basic theory or other examples?

Performing linear interpolation is not terribly difficult. (Thatâ€™s a google search term for you). Respecting some chord height tolerance and maximum step distance for circles and arcs is easy. Doing the same for arbitrary curves is not.

G2 and G3 just define different directions to go around the circle.

Where you perform this interpolation, and how to substitute the string of G0/G1 codes in place of the G2/G3 codes will depend on your setup.

Thanks, hopefully that'll get me started. Are you suggesting to break down the arcs of non circles into segments?

Check out the code at:- http://www.thebox.myzen.co.uk/Hardware/CNC_Conversion.html It implements G2 and G3 commands and was based on an earlier Rep Rap version that did implement it. However, the implementation is just a polygon with a large number of sides, what you want to implement it properly is the Bresenham circle algorithm. http://en.wikipedia.org/wiki/Midpoint_circle_algorithm