Gear cutting 4th Axis

locomobile

locomobile
Hi

I make clocks as a hobby and have found a simple G-code for gear cutting (found on the net years ago) to have served me well with Mach4: copy attached

The code uses two sub routines, I have altered it the use 2 sub programs for Masso: Main and sub programs attached

I get almost infinite X and Y values displayed and think it is probably the divisions within the brackets but can find no guide to what expressions, brackets etc are permissible

I would value a quick look to see where I have gone wrong and how to correct matters

Thanks

David
 

Attachments

  • Gear-cutting-simple-Original.nc
    917 bytes · Views: 26
  • Gear-cutting-simple.nc
    652 bytes · Views: 30
  • 10.nc
    111 bytes · Views: 32
  • 20.nc
    86 bytes · Views: 27

cncnutz

CNCnutz
Staff member
Hi @locomobile

You Gcode files is using unsupported Gcode

G0 Y[#105 + 1]
#109 = [#109 + #111]
G0 A#109
G0 Y#105

Your Gcode looks like some form of scripting language with variables.
MASSO does not use scripting or variables.

I'm sure you can use subroutines to carry out your machining but not in this format.

Cheers Peter
 

zombieengineer

ZombieEngineer
I had a quick look at the ISO standard that defines G-Code (ISO 6893-1, preview of the standard available here) and numerical expressions do not appear to be defined in the standard.

Numerical expressions within such a standard take up a significant amount of space in such documents (I had to write an interpreter for IEC 61131-3 standard which is a programing language for PLC devices).

It is possible to write a processor which will take a Mach 4 or similar syntax and "unroll" the code to have all the statements explicitly calculated. The techniques used borrow from software compiler development techniques (specifically YACC where you feed individual words, once it recognizes the structure it spits out the equivalent statement - implicitly handles "order of precedence" for expression calculations).

Your G-Code is only using brackets, multiply / divide, addition / subtraction so it is a very small subset of the code required for a typical computer language (no variable declaration, if-then-else statements, etc). Should only take a couple of days to knock out - except I am running in "zombie mode" where I am double booked with engineering projects at my day job (all the 2020 projects got deferred to 2021 plus the stuff people wanted done in 2021).
 
Top