GCode alternatives

Janger

(John)
Administrator
Vendor
I got talking about G code and possible alternatives in another thread. I started googling and I see there is something in development called STEP-NC.

There is this example: https://steptools.com/docs/stpython/example/print_process/

It is still fairly difficult and laborious but seems to be tackling a lot of other problems in machining besides just the language format. Quality control, writing software to manipulate NC programs, eliminating many little steps defining arc moves, and other things I don't understand yet. The point of my post. @Alexander, @Degen , @Dan Dubeau you guys are in industrial environments - do you see any movement on upgrading gcode to another standard? Do you see any call for this in your work? Does the cycle of see a problem at the machine in the code, then go back to the CAM software, fix, repost, reload cause slow downs in your work cycles and productivity?
 

Dan Dubeau

Ultra Member
Kinda reminds me of APT, which we learned a great deal about in college In the early 2000's (and have forgotten since). It was a gcode replacement from the 60's? and was supposed to become industry standard, but I've never heard about it in the real world. Aside from joking with people who took the same program......Step.nc Is an interesting project, but I don't exactly see it taking the industrial world by storm (yet). People are slow to change. Our shop still runs on Mechanical desktop 6 (2005 ish?), and Edgecam from 2012. I can't even make a case for buying the high speed look ahead option (@2k last I checked) for our Haas vf6 when all we do is primarily run long 3d surfacing programs in it......Having done the math and presented my case many times over the years about it paying for itself within a couple jobs, 2k (probably double that now, as I stopped trying years ago) for a password is a tough sell. Those are the kinds of roadblocks to new tech like this. As natural selection runs it's course, and shops like this close because they're no longer profitable it might gain ground in new shops that like to compete and need to, to survive.

I can see who people from/with a computer programming/coding background see Gcode as a somewhat broken system that could use a lot of improvement, but the roadblock is an industry that is full of machinists that are NOT computer programmers, and see nothing wrong with the system that works (and are slow and resistant to change). It might gain some ground in the next generation of machinists that grow up with a baseline level of coding knowledge and experience (I have zero, and am 40 for perspective), that can see and understand the merits behind it, and affect change at the MTB level, but until then I think it's going to be a tough slog, and it'll have a small cult like following. I can see this being implemented more behind the GUI as a more efficient conversational programming language, and might be showing my ignorance if it already is. I honestly don't have much real world experience with conversational programming as I've never touched it aside from my Tormach at home. It wouldn't surprise me to know that something like mazatrol is actually just APT or a refinement of, under the covers. The Tormach (pathpilot) conversational just spits out gcode though.

Fixing and modifying Cgode doesn't really slow me down much. While every job I do is different, as I do tooling one offs primarily (they're all the same just different :D ). I approach them with a production mindset, and use the same strategies, cycles and tool for the most part, so I've got a lot of things automated and templated. It helps to speed things up, but most importantly error proof the process somewhat, as I've refined it constantly over the years. I might edit and alter code once or twice a week maybe? It's mostly just T/H numbers too.

Fixing/editing programs to run more efficient is an interesting topic though. It's something I enjoy picking apart when teaching new people, as they'll sit there and spend 10 minutes tweaking a program trying to shave 2 minutes out of a one off cycle.....just let it run, and catch it on the next one. One offs are a different mindset than production. Like steering a container ship, vs a jet boat.
 
I am relatively new to CNC about a 1-1/2 and am self taught and learn as need as time is scarce. I will add I am very very slow understanding G-code (not much effort given) because I have gone the conversational route and this seems the way with Mastercam leading the pack.

Personally I agree that G-Code was designed by someone on drugs, but unfortunately it has so become imbedded into our systems and is open source I don't suspect there is going to be a change anytime soon.

The second issue even though very very simplistic and convoluted it is flexible enough to handle 8-9-10 axis machines with a little customization so why change.

The third item most don't write G-Code directly, but use an intermediate program to do the grunt work, these are call conversational programs which can be dedicated stand alone or part and parcel of the CAD or CAM or both software. As an example currently I import a DXF file into Intercon (Centriods) built in program select tooling and operations in 15 to 40 lines and generate 2,000 to 5,000 or more lines of code, then I use a third party editor/visualizer to tweak and remove, I going to call this conservative G-Code to speed up operational time. If work created and a more sophisticated machine generated enough income I would go the Solidworks/Mastercam route hands down as it is now 3D and tweaked all in two steps.

A typical 3 part program now only takes me about 30 to 60 minutes to create, visualize/tweak and get on the machine into production.

So short answer does it take more time, not really as the work you do to setup and plan your manual operations take just as long. One simple piece (one or two operations) may be faster manually, a more complex beyond that CNC hands down mistake because of operator error are virtually eliminated.

For production run as many operation on one setup as possible, sets are a time sink.

I'm going to add based on what @Dan Dubeau posted, I do all my programming on the desk before it even hits the machine, sometimes it take several trips to the mill do/learning something new, but once learned its back to program, visual/tweak into production.
 
Last edited:
Truth be told the more I get into it, the less I look at the manual machine.

Don't get me wrong I think everyone should learn manual machining and do it reasonably well before being allowed to even touch or see a cnc.
 

Susquatch

Ultra Member
Administrator
Moderator
Premium Member
Truth be told the more I get into it, the less I look at the manual machine.

Don't get me wrong I think everyone should learn manual machining and do it reasonably well before being allowed to even touch or see a cnc.

I'm not knocking CNC. Just not willing to spend time at my age setting up the hardware and learning to program it. I'll be dead by the time I can learn enough to do something useful that I will never do again. I'm quite happy stuck in my manual rut. If I was 40 or even 50 I might feel differently. At 77, it's just a waste of precious time. I have no interest in driving hot cars or chasing young women either. My truck and my bride are all I can handle. Doesn't mean I can't appreciate why the younger guys do.

@Tom Kitta wants to go climb a mountain alone without Oxygen. I'd die looking up. I'm happy for him and maybe even jealous. But I ain't doin it. Same goes for G-Code and CNC. Not happening.
 

Matt-Aburg

Ultra Member
I'm not knocking CNC. Just not willing to spend time at my age setting up the hardware and learning to program it. I'll be dead by the time I can learn enough to do something useful that I will never do again. I'm quite happy stuck in my manual rut. If I was 40 or even 50 I might feel differently. At 77, it's just a waste of precious time. I have no interest in driving hot cars or chasing young women either. My truck and my bride are all I can handle. Doesn't mean I can't appreciate why the younger guys do.

@Tom Kitta wants to go climb a mountain alone without Oxygen. I'd die looking up. I'm happy for him and maybe even jealous. But I ain't doin it. Same goes for G-Code and CNC. Not happening.
I tried to retire... but work found me again.. Now I am programming again professionally after 25 years since last doing it for wage.. I am programming Eva foam for Big boats.. I will also be making acrylic signs, bars, and eventually wood Criss Craft style boats. I am paid more than any other has paid me in my life by 7 / hr... Unfortunately, not sure how I will have time to do my own projects anymore.......
 

Attachments

  • 240x5-8cm-6mm-Self-Adhesive-EVA-Foam-Teak-Deck-Sheet-Marine-Boat-Yacht-Synthetic-Teak-Decking....jpg
    240x5-8cm-6mm-Self-Adhesive-EVA-Foam-Teak-Deck-Sheet-Marine-Boat-Yacht-Synthetic-Teak-Decking....jpg
    76.7 KB · Views: 5

Janger

(John)
Administrator
Vendor
I'm still working my ELS install - life and work interfering with getting it done. I've got 6 yards of loam and mulch on the street that I need to shovel for the spouse and her garden project. Anyway ELS is an interesting in-between manual and CNC. I'm quite curious how it is going to work out.
 

Susquatch

Ultra Member
Administrator
Moderator
Premium Member
I am paid more than any other has paid me in my life by 7 / hr...

That's what happened to me when I retired too. I got 4 times my previous pay. Eventually I looked in the mirror and started to say no. Then the pay went up even more. So I started farming. Now I'm guaranteed not to make decent money. I'm gunna do that till I die or go broke.
 
Are you guys saying that in order to actually get a decent wage in this trade I need to retire, then go back? Can't wait to turn in my notice on Monday. You guys better be right.......;)
You know what they say about internet experts, give advice and youtube the train wreck :oops: and the vultures are waiting for the distress sale for money.....
 

Alexander

Ultra Member
Administrator
We have four machines equipped with Mazatrol at MAF, but we've found Fusion 360 to be more beneficial. It offers greater customization and generates industry-standard G-code, eliminating the need for additional staff training. If you're setting up a machine, you're likely already familiar with G-code. That's our experience at MAF. Just my two cents.
 

StevSmar

(Steven)
Premium Member
I think my feeling is that I’m quite happy to model things up in Fusion 360, but once the modelling is done then fun is over and I’d rather send the part to a company for CNC machining.

I say this is from the point of view of not having a CNC machine of course. Perhaps once I’ve made more parts I’ll look forward to eliminating the tedium of making multiple parts.

3D printing seems more intriguing to me.
 

jcdammeyer

John
Premium Member
I can't speak about the other CNC systems out there since I only use MACH3 in it's simplest form on my CNC router.
However on the mill it's LinuxCNC and that has been an interesting adventure mostly because LCNC is open source and therefore lots of different 'programmers' have input and many of them couldn't write a user manual (or internal) documentation if their life depended on it.
Even the add on documents often are written more like a glossary/dictionary rather than a description of how it works so it's been a bit of a tough slog.

For example. I'm working on the tool change. Not for the lathe but for the mill and not for one that has a tool changer with numbered pockets and numbered tools.

The G-Code command for changing a tool is Tx M06 and by default LCNC stops the machine, throws up a dialog asking you to install Tool x and press OK when it's done. MACH3 isn't much different. Same command. It's also programmed to move to a tool change position. You can write BASIC language gode to add automatic tool changing in MACH3.

LCNC has a document:
which sort of explains how to remap the M codes, M6 particularly with either more G-Code or a combination of G-Code and the Python Language.

The G-Code you see in the large files generated by the CAM software are a small subset of what can actually be done. On the subject of tool changes for example all you might see in this code which I've written off the top of my head)

M5 (stop the spindle)
G53 G0 Z0 (furthest point from spindle in machine co-ordinates at full speed)
G53 G0 X1 Y1 (tool changer position)
T3 M6 G43 (throw up change tool dialog and set the current workspace offset for Z tip of tool matches same Z position as the last tool)
M3 S250 (turn on the spindle again at new speed for this tool)
G0 Xn Ym (go to the xy position for the next milling operation)
G0 Zp (go to the first Z position just above the work)
( Start milling with G1 Fs and X,Y,Z) variables for slower speed motion )

But even MACH3 has some simple features for repetitive milling.

For example I put in a number of holes into a plastic front panel using my CNC router. This is a fragment of the G-Code I wrote by hand. I've added comments that aren't in the actual program to make this more readable:

G90 (Absolute motion rather than G91 relative motion)
G0 Z0 F5 ( Go up to the previously Z0 point (0.1 above the part) at full speed and set the G1 speed to 5 IPM)
M3 ( Turn on the relay for the Bosch Colt router power which has a dial for speed)
G0 X0 Y0 F90 (Go to the corner of the jig that holds the plastic part. The F90 is redundant and not needed)
G1 X0.709 Y-0.205 F60 (Move to the first hole location at 60 IPM)
M98 P4000 ( and this is what would be known in programming language as a subroutine call)
X0.909
M98 P4000

The subroutine is located like this:
O4000 ( The O makes this a label. The 4000 is just the subroutine #)
z-0.25 F20 ( Move at 20 IPM down to the -0.25" position which with the 0.125" diameter router bit is just through the plastic.
Z0 F30 ( Move out of the hole back 0.1" above the plastic and ... )
m99 ( return )

I usually make 25 at a time.

Now back to LinuxCNC. The G-Code is interpreted by a standard called RS274NGC so the interpreter reads those G0 M6 G43 statements and creates output for the CNC hardware to do the motion. What you usually don't see in the CAM generated code is this sort of G-Code.

The name of the subroutine for M6 Tool Remapping and automatic probing to a touch sensor. The Python interpreter reads in the G-Code file "m6remap.ngc" which is identified on the first line with:
o<m6remap> sub

Let's initialize some local variables used inside this subroutine. Note this even takes into account if the measurement system is G20 or G21 for Imperial or Metric.

o300 if[#<_imperial>]
#2001=.1 (Z up distance between probes)
#2002=25 (Fast probe feed rate)
#2003=1 (Slow probe feed rate)
#2004=40 (Z up feed rate.)
o300 endif

o310 if[#<_metric>]
#2001=2.5 (Z up distance between probes)
#2002=635 (Fast probe feed rate)
#2003=25 (Slow probe feed rate)
#2004=1000 (Z up feed rate.)
o310 endif


Here's an example line
G53 G0 Z[#<_ini[AXIS_Z]MAX_LIMIT>+#<_ini[PROBE_SCREEN]Z_SAFE_TRAVEL_OFFSET>]

Yikes eh? What the heck does that mean and is it portable to other systems. The answer is yes if they are running LinuxCNC and have the .ini file set correctly.

Let's take it apart.
G53 says don't use the current workspace co-ordinates but use the physical machine co-ordinates relative to the home switches.
G0 says move at full speed which in my machine for Z is 180 IPM which is scary fast.

As usual in G-Code the Z has a numeric argument for where to go and in this case it's a numerical expression defined inside the [ ] and the parameters are from the LCNC ".ini" file which on my machine is G3616-MESA-7i92.ini.

Inside the ini file are sections that in Pascal or C would be called Records or Structures and comments start with '#'.

For example the X axis:

[AXIS_X]
MIN_LIMIT = -0.04
MAX_LIMIT = 13.5
MAX_VELOCITY = 3.0
MAX_ACCELERATION = 15

and for the Probe Screen
# begin Touch Probe
[PROBE_SCREEN]
# Offset from [AXIS_Z]MAX_LIMIT for performing moves during various probe
# screen movements. This must be a negative number.
Z_SAFE_TRAVEL_OFFSET = -0.1
# Absolute distance from table to bottom of spindle
WORK_HEIGHT = 12.718

From within the RS274NGC interpreter the
[#< ini[AXIS_X]MAX_LIMIT>+
says use the machine ini file record structure [AXIS_X] with MAX_LIMIT field which is 13.5 in this case and add it to the number #<_ini[PROBE_SCREEN]Z_SAFE_TRAVEL_OFFSET>]
in the ini file record [PROBE_SCREEN Z] with SAFE_TRAVEL_OFFSET field which in this case is -0.1

The end result of that statement in interpreted G-Code is:
G53 G0 Z13.4

So G-Code does have a programming language feel to it. And this could all have been done in the Python Language too. Just simpler here with G-Code.

Confusing? Yes. But most programming languages are.
 
Last edited:
I can't speak about the other CNC systems out there since I only use MACH3 in it's simplest form on my CNC router.
However on the mill it's LinuxCNC and that has been an interesting adventure mostly because LCNC is open source and therefore lots of different 'programmers' have input and many of them couldn't write a user manual (or internal) documentation if their life depended on it.
Even the add on documents often are written more like a glossary/dictionary rather than a description of how it works so it's been a bit of a tough slog.

For example. I'm working on the tool change. Not for the lathe but for the mill and not for one that has a tool changer with numbered pockets and numbered tools.

The G-Code command for changing a tool is Tx M06 and by default LCNC stops the machine, throws up a dialog asking you to install Tool x and press OK when it's done. MACH3 isn't much different. Same command. It's also programmed to move to a tool change position. You can write BASIC language gode to add automatic tool changing in MACH3.

LCNC has a document:
which sort of explains how to remap the M codes, M6 particularly with either more G-Code or a combination of G-Code and the Python Language.

The G-Code you see in the large files generated by the CAM software are a small subset of what can actually be done. On the subject of tool changes for example all you might see in this code which I've written off the top of my head)

M5 (stop the spindle)
G53 G0 Z0 (furthest point from spindle in machine co-ordinates at full speed)
G53 G0 X1 Y1 (tool changer position)
T3 M6 G43 (throw up change tool dialog and set the current workspace offset for Z tip of tool matches same Z position as the last tool)
M3 S250 (turn on the spindle again at new speed for this tool)
G0 Xn Ym (go to the xy position for the next milling operation)
G0 Zp (go to the first Z position just above the work)
( Start milling with G1 Fs and X,Y,Z) variables for slower speed motion )

But even MACH3 has some simple features for repetitive milling.

For example I put in a number of holes into a plastic front panel using my CNC router. This is a fragment of the G-Code I wrote by hand. I've added comments that aren't in the actual program to make this more readable:

G90 (Absolute motion rather than G91 relative motion)
G0 Z0 F5 ( Go up to the previously Z0 point (0.1 above the part) at full speed and set the G1 speed to 5 IPM)
M3 ( Turn on the relay for the Bosch Colt router power which has a dial for speed)
G0 X0 Y0 F90 (Go to the corner of the jig that holds the plastic part. The F90 is redundant and not needed)
G1 X0.709 Y-0.205 F60 (Move to the first hole location at 60 IPM)
M98 P4000 ( and this is what would be known in programming language as a subroutine call)
X0.909
M98 P4000

The subroutine is located like this:
O4000 ( The O makes this a label. The 4000 is just the subroutine #)
z-0.25 F20 ( Move at 20 IPM down to the -0.25" position which with the 0.125" diameter router bit is just through the plastic.
Z0 F30 ( Move out of the hole back 0.1" above the plastic and ... )
m99 ( return )

I usually make 25 at a time.

Now back to LinuxCNC. The G-Code is interpreted by a standard called RS274NGC so the interpreter reads those G0 M6 G43 statements and creates output for the CNC hardware to do the motion. What you usually don't see in the CAM generated code is this sort of G-Code.

The name of the subroutine for M6 Tool Remapping and automatic probing to a touch sensor. The Python interpreter reads in the G-Code file "m6remap.ngc" which is identified on the first line with:
o<m6remap> sub

Let's initialize some local variables used inside this subroutine. Note this even takes into account if the measurement system is G20 or G21 for Imperial or Metric.

o300 if[#<_imperial>]
#2001=.1 (Z up distance between probes)
#2002=25 (Fast probe feed rate)
#2003=1 (Slow probe feed rate)
#2004=40 (Z up feed rate.)
o300 endif

o310 if[#<_metric>]
#2001=2.5 (Z up distance between probes)
#2002=635 (Fast probe feed rate)
#2003=25 (Slow probe feed rate)
#2004=1000 (Z up feed rate.)
o310 endif


Here's an example line
G53 G0 Z[#<_ini[AXIS_Z]MAX_LIMIT>+#<_ini[PROBE_SCREEN]Z_SAFE_TRAVEL_OFFSET>]

Yikes eh? What the heck does that mean and is it portable to other systems. The answer is yes if they are running LinuxCNC and have the .ini file set correctly.

Let's take it apart.
G53 says don't use the current workspace co-ordinates but use the physical machine co-ordinates relative to the home switches.
G0 says move at full speed which in my machine for Z is 180 IPM which is scary fast.

As usual in G-Code the Z has a numeric argument for where to go and in this case it's a numerical expression defined inside the [ ] and the parameters are from the LCNC ".ini" file which on my machine is G3616-MESA-7i92.ini.

Inside the ini file are sections that in Pascal or C would be called Records or Structures and comments start with '#'.

For example the X axis:

[AXIS_X]
MIN_LIMIT = -0.04
MAX_LIMIT = 13.5
MAX_VELOCITY = 3.0
MAX_ACCELERATION = 15

and for the Probe Screen
# begin Touch Probe
[PROBE_SCREEN]
# Offset from [AXIS_Z]MAX_LIMIT for performing moves during various probe
# screen movements. This must be a negative number.
Z_SAFE_TRAVEL_OFFSET = -0.1
# Absolute distance from table to bottom of spindle
WORK_HEIGHT = 12.718

From within the RS274NGC interpreter the
[#< ini[AXIS_X]MAX_LIMIT>+
says use the machine ini file record structure [AXIS_X] with MAX_LIMIT field which is 13.5 in this case and add it to the number #<_ini[PROBE_SCREEN]Z_SAFE_TRAVEL_OFFSET>]
in the ini file record [PROBE_SCREEN Z] with SAFE_TRAVEL_OFFSET field which in this case is -0.1

The end result of that statement in interpreted G-Code is:
G53 G0 Z13.4

So G-Code does have a programming language feel to it. And this could all have been done in the Python Language too. Just simpler here with G-Code.

Confusing? Yes. But most programming languages are.
I'm so freaking dizzy trying to wrap my head around all of that...... I might be done in for the day. o_O
I wish I could swim in those circles, but alas, I am best suited to stone hammers and bronze chisles...... My wheels however are mostly roundish with the exception of the odd knot that wears a little slower....:rolleyes:
 

jcdammeyer

John
Premium Member
I'm so freaking dizzy trying to wrap my head around all of that...... I might be done in for the day. o_O
I wish I could swim in those circles, but alas, I am best suited to stone hammers and bronze chisles...... My wheels however are mostly roundish with the exception of the odd knot that wears a little slower....:rolleyes:
Please don't make the assumption that I figured this all out in an hour or two.
I've spent weeks trying to relearn what I thought I knew in January.
A couple years slowly learning how to configure a CNC system.
And I still prefer that the CAM creates the G-Code
 
Oh no, I fully realize that none of this comes overnight, and I applaud all of you that can think that way. My mind works in a much more visual manner that seems to miss fire alot.... Pretty sure I got the hit-n-miss variety.......:rolleyes:
 
My understanding is M-codes are Macros, which in a lot of cases can become machine application specific. While there are standards, the more I see both G and M codes vary with machine and application.

If you note Fusion, SW, Mastercam and others have options to specify the machine to tweak the conversational language to write machine specific code. Generic is a good starting point, but machine specific is what is required.
 
Top