# Writing G Code - Newbie



## slow-poke (Nov 19, 2017)

I'm a newbie that recently added CNC capability to an old LC30A mill using Mach3. I have next to no experience other than typing in some simple G0, G1 etc. commands and cutting a few arcs using the Wizard feature. I'm not a machinist, just a guy that likes to tinker.

I now want to attempt machining a fairly simple irregular shaped piece. To start, I just want to cut the perimeter that would be a sequence of straight cuts and 6 arcs. I imagine the mill going around the perimeter several times cutting a bit deeper on each pass until the bit finally cuts through the bottom edge. I suppose I can run the arc wizard 6 times and copy the 6 code segments it generates to a new file and then insert the straight line cuts (G01) in the appropriate locations in the new file, so that the entire perimeter is defined.

Is there a better approach, perhaps with some form of (low cost or free) cad software, or is the method I described above a reasonable approach?

Thanks to all that reply.


----------



## TomS (Nov 19, 2017)

When I first started playing with CNC I bought D2NC.  As I recall it cost about $70.  It doesn't have a lot of features like the high dollar programs but got the job done.  I'm now using CamBam.


----------



## BGHansen (Nov 19, 2017)

I downloaded a free 2.5D (2-axis with the Z-axis being manually controlled) CAD/CAM program called "Techne CAD-CAM".  Frankly, I haven't used it much since my Anilam Crusader II has an RS-232 problem so I can't talk to the box with a laptop.  Google says they have a 3D version also.  A lot of guys here use Fusion 360 which is free (?).

For DNC, my intent was to use a free download of "Cadem NC".  However, the problem with my Anilam has me programming in just conversational mode.  Wish I could help more, but I entered the CNC realm about 2 months ago and hope to progress to just the beginner status soon.

Bruce


----------



## RJSakowski (Nov 19, 2017)

As you get into more complex shapes, CAM software become increasingly more important.  Cam take a CAD model ans with your selection of tooling and machining strategy, creates the necessary toolpaths to make the part. There are several reasons for using CAM to generate the G code.  Programs become so long that it becomes tedious to write them from scratch.  I have created G code programs that had over a quarter of a million lines of code.  Secondly, debugging that code would become nearly impossible and the possibility of undetected errors will increase dramatically.   Finally, CAM G code generated from CAD files can follow some intricate paths that would be otherwise virtually impossible to describe mathematically.   A CNC machine with fourth axis capability can recreate a lifelike replica of a human face.

So what is available in software?  There is a whole spectrum of software ranging from free to kilobucks/year and from some fairly simple 2D to toolpaths to things like adaptive clearing in three or four or five axes.  One that is free for hobby use and is also quite sophuisticated is Fusion 360.  It combines CAD and CAM in a single package and is sophisticated.  There are others out there as well.  My machine is a Tormach and I purchased it with SprutCAM and purchased a seat of SolidWorks for the CAD part.  A little searching will turn up others.


----------



## JimDawson (Nov 19, 2017)

I'm a fan of CamBam.  It does have some limited CAD capability.  A 40 free use trial will really allow you to learn how to use it before you need to think about buying a license for $149.


----------



## RJSakowski (Nov 19, 2017)

Fusion 360 is free for hobbyists.  I asked that question directly of their marketing team and was told that Autodesk has no intention of changing that policy.  Startup companies can also use it providing their annual revenue doesn'tr exceed something like $100K.  Beyond that, they have a monthly or annual subscription which is quite modest compared to other software.  You can rent it for only the months that you need it which is quite unique in the CAD/CAM world.

To access the free annual subscription, you can download the free 30 day trial and as you near the end of the the 30 day period, you can resubscribe as a hobbyist for a year.  You do have to go through the resubscription process annually.   I am in my third year of subscribing.

I should also mention for  those who dabble in electronics that Autodesk acquired Eagle PCB layout software and has integrated it into the software family.  It is capable of creating electronic schematics and PCB layouts and of converting them into 3D CAD files  from which G code for machining can be created.


----------



## T Bredehoft (Nov 19, 2017)

Assuming you've mastered the shape and tool offset, you want to increment z by whatever your depth of cut is, .050 x 6 =.300 depth of cut, running the cycle again until you've hit z. 

10 start
20 go to zn yn z=.1
30 goto 100
40 g1 x whatever
50 run cycle
60 if z =-.300 end

100 Sub, set Z
110 g81 g1z-.05
120 g80 
130 goto 40

This assumes g81 still does incremental, g80 does absolute. 

Its been 15 years, I'm rusty, but this should work. 

Tom


----------



## slow-poke (Nov 22, 2017)

Thanks to everyone, I'm up and running (one miner crash ooops)

I searched but have not found.......

1) Is there a way to display a loop counter value, If I'm making 10 passes, it would be nice to see what pass is in progress?
2) Is there a way within mach3 to break out of  a loop, for example I wrote the progam to make 10 loops, but by increasing the cut depth I'm able to do it in say 7 passes and now want to jump out of the loop.


----------



## T Bredehoft (Nov 22, 2017)

DRO should show z values as  you run, When it gets where you want it, let it finish the cycle then hit E-stop.

There's probably another way, I no longer have access to the machines I once ran.


----------



## Groundhog (Nov 22, 2017)

Since you have the CNC and Mach3 you will most likely (eventually) end up with a cad program and a cam program. If you don't have full featured programs there will always be one more feature you will want or need.
Since Fusion 360 is free for hobbyists (and said to stay that way) and fairly full featured enough, it only makes sense to go directly there. At least explore the modeling and cam portions of the program.
I have TurboCad Pro and VisualMill for my CNC mill (several thousand dollars worth - and upgrades are expensive), but have been using Fusion 360 almost exclusively for the last year or so. It (so far) has worked flawlessly with my Syil X4+ mill and controller running Mach3. The only trouble I've had is occasional crashes with my old (and borderline capable) Windows 7 computer.
The learning curve isn't any steeper than learning a cad program and a cam program. There are lots and lots of online resources for learning and help. Autodesk and Lars Christensen being 2 of the best I've seen.


----------



## T Bredehoft (Nov 22, 2017)

CAD software will help a great deal. I was used to programming from blue prints, before software was available.


----------



## JerryK (Nov 22, 2017)

Groundhog said:


> Since you have the CNC and Mach3 you will most likely (eventually) end up with a cad program and a cam program. If you don't have full featured programs there will always be one more feature you will want or need.
> Since Fusion 360 is free for hobbyists (and said to stay that way) and fairly full featured enough, it only makes sense to go directly there. At least explore the modeling and cam portions of the program.
> I have TurboCad Pro and VisualMill for my CNC mill (several thousand dollars worth - and upgrades are expensive), but have been using Fusion 360 almost exclusively for the last year or so. It (so far) has worked flawlessly with my Syil X4+ mill and controller running Mach3. The only trouble I've had is occasional crashes with my old (and borderline capable) Windows 7 computer.
> The learning curve isn't any steeper than learning a cad program and a cam program. There are lots and lots of online resources for learning and help. Autodesk and Lars Christensen being 2 of the best I've seen.



I have the exact machine Syil X4 plus bought in 2010, with Mach 3
I've been very surprised and happy with if.
No problems in 7 years.
I use Surfcam, I kept the software when I retired in 2006


----------



## JerryK (Nov 22, 2017)

slow-poke said:


> I'm a newbie that recently added CNC capability to an old LC30A mill using Mach3. I have next to no experience other than typing in some simple G0, G1 etc. commands and cutting a few arcs using the Wizard feature. I'm not a machinist, just a guy that likes to tinker.
> 
> I now want to attempt machining a fairly simple irregular shaped piece. To start, I just want to cut the perimeter that would be a sequence of straight cuts and 6 arcs. I imagine the mill going around the perimeter several times cutting a bit deeper on each pass until the bit finally cuts through the bottom edge. I suppose I can run the arc wizard 6 times and copy the 6 code segments it generates to a new file and then insert the straight line cuts (G01) in the appropriate locations in the new file, so that the entire perimeter is defined.
> 
> ...


Mr. Poke,
In the mean time , if you need any G-code, I would be glad to help
It's only a hobby


----------



## Boswell (Nov 22, 2017)

You probably found that you can create and update a variable. I have not found a reliable way to output the variable value in Mach3. for the routines that I have hand coded the one I use the most is a generic facing program. I have a section at the top of the code where I enter in values for total depth to cut, Increment value, length of cut and the diameter of my facing tool. then I just start with the tool zeroed to the top of the part and just off the part to left and press go. It has a pause at each iteration so I can press the stop key if I want to step out before the full depth is achived.


----------

