CNC GM file format help needed

I am looking for information on the most popular [G/M] cnc file
As some of you may remember I am writing a program to convert
HPGL files to cnc files. The reason for using HPGL rather than
dxf for input is that the HPGL files have the actual vectors for
text, including ttf, where the dxf files contain the text
I discovered a free GNU program called hp2xx that will take
regular HPGL and HPGL/2 files for input and generate an output
file using only PU [pen up], PD [pen down], and PA [plot
absolute] commands, with some other extraneous [for my purposes]
commands such as IN [initialize plotter]. This eliminates the
more problematic conversions such as converting AR [arc relative]
because of the difference in the way cnc controllers handle the
arc commands. The downside of this is that a single line for an
AR [arc relative] command is replaced with a huge number of short
absolute G1 moves.
My program called hpgl2cnc is nearing completion. Rather than
attempting to write a complete cnc program, this generates only
the G0/G1 codes that will need to be cut-n-pasted into a complete
program with headers to start the machine and footers to properly
shut it down. The program has the option of either metric or
inch code generation and will run in the "console" [dos box] of
windows xp and 2k. [I had to buy a new compiler (PowerBasic
CC4.01) to do this.]
HPGL plotter units are 1016 to the inch or 40 per m/m. Accuracy
will be 0.001 inch or 0.05 m/m. You will be able to set a
different plunge [z] and lateral [xy] feed rates. You will also
set a "clearance" above the part and a "plunge" distance into the
part in either inch or metric.
Specifically I need to know what is the most common/portable cnc
output file format suitable for cut-n-paste:
Line numbers? - how many places? Sequential or every 5 etc.
Include decimal points? If no decimal points what is assumed
Leading or trailing signs? -0.123 or 0.123- also do you want/need
+ signs?
Spaces between variable name and value, i.e. "X0.123" v "X 0.123"
Comment indicator? "%". " ' ", "*" or what?
==> Is column alignment still important? If so what spacing? I am including range checking on the xy and z feed rates.
What is the min/max in inch and/or metric that you think you
would use? I am using IMP in the inch mode. What is the accepted
metric feed rate unit?
While HPGL2CNC is generally intended for plaques, I can see doing
2 dimensional contouring such as flat cams. With the ability in
most cad programs to turn layers on/off, some elaborate work
should be possible, with the manual insertion of G41/G42 codes
and T specifications.
Thanks for your advice.
I will post the compiled exe program and PowerBasic source on my
website and submit for inclusion on some of the other cnc sites
and the PowerBasic site. This will be freeware under the GPL.
If you would like a copy when it is completed please send me an
email. Most likely not the program to use for high volume
production, but may be just what you need for a one off plaque or
I'll start work on the 'C' axis version for engraving around a
cylinder when this one is up and running.
Uncle George
Reply to
F. George McDuffee
Loading thread data ...
I have to aggree with Cliff. Much to varied. Might I suggest to incorporate a NC formatter for basic things like you mentioned. You don't need anything complex.
F. George McDuffee wrote:
Reply to
================================= Thanks to Cliff and every one else that replied directly [emails] about the output file formats.
I have just about completed coding for the actual conversion of the preprocessed ( using the gpl hp2xx ) HPGL and HPGL/2 files.
Your suggestion to operationally create a simple post appears to be the best solution to the file format question.
Also I am doing range checking [min/max values] and would appreciate advise on the following points, assuming you are using small endmills for sign creation, etc. (1) What are the min/max vertical feedrates and units that you would ever use? (2) What are the min/max horizontal feedrates and units you would ever use? (3) What is the min/max distance above the surface you would ever use? (4) What is the min/max plunge below the surface you would ever use?
Items 1-4 will be input when you convert a processed hpgl file.
If you use a cad program, you can turn layers on/off before plotting, so lettering in the bottom of a pocket is easy. Mirror immage is also simple.
Units [mm/inch] will be determined in the configuration file.
A proforma output configuration file follows. Please review and let me know what variables I have omitted, or other features you would like.
=== possible configuration file for hpgl ==> G-CODE translator == * * « CONFIGURATION FILE » * for hpgl2cnc.exe -- a GPL public domain program. * * by default hpgl2cnc uses the hpgl2cnc.cfg config file. * * you can use different configuration files * by specifying on the command line * for example or * these will need to be in the same directory as * hpgl2cnc.exe unless you specify drive/directory. * * NOTE: hpgl2cnc generates only 2_1/2D moves, i.e. only 1 or 2 axis change in any one block. * * Lines begining with an astrisk are comments. * * All alpha values converted to upper case by the program. * * Settings shown are for an Emco F1 educational machining center, and most and * ==> MOST LIKELY NEED TO BE EDITED FOR YOUR CONTROLLER.only plain ascii text * * ========================================== * I , "unit output -- nch/mperial or etric -- valid values are I/M " * * ========================================== * % , "character used for controller comment line [ignore block] supresses comments" * * ========================================== * P , "decimal point character -- valid values are one, oint for and omma for " * NOTE: cannot input directly * * ========================================== * 3 , "number of digits in line number -- 0 suppresses [no N], valid values are 0,3,4,5,6" * 250 , "max number of lines you can cut-n-paste into your cnc control program at one time" * program will withdraw tool and home, write comment line, reset line number counter to 25 * return tool to previous position and continue. Because hpgl2cnc uses only straight line * moves, cnc programs can be very large when arcs/curves are involved. * * with 3 digit line numbers, max number of lines is 975 in any one sub program * with 4 diget line numbers, max number of lines is 9975 in any one sub program * with 5 digit line numbers, max number of lines is 99975 in any one sub program * with 6 diget line numbers, max number of lines is 999975 in any one sub program * * ========================================== * 1, " number of spaces between line number and 1st parameter? -- valid values are 0,1,2" * * ========================================= * 1 , "number of spaces between parameters? -- valid values are 0 , 1, 2" * 3 , "number of digits in XYZ cordinates -- valid values are 1,2,3,4,5,6" * 4 , "number of decimals in XYZ cordinates -- valid values are 0,1,2,3,4,5,6" * Y , "leading zeros required for XYZ coordinates -- valid values are es/o" * A , "does the minus sign [-] go before or after a negative coordinate value -- efore /fter * N , "include a plus sign [+] for positive coordinate values? -- es / o" * B , "Does the axis designator [XYZ] go efore or fter the axis vlaue?" * N , "space between XYZ axis designator and value? valid values -- es , o" * * ========================================== * A , "show all 3 coordinates or only changed coordinates in cnc block -- ll or hanged only" * * ========================================== * F , "feed rate designator -- generally but any ascii string 255 characters or less" * 2 , "number of digits in feed rates [F] -- valid values are 2,3,4,5" * 1 , "number of decimal places in feed rate [F] -- valid values are 0,1,2,3" * Y , "leading zeros required in feed rate? -- valid values es / o" * N , "space required between F designator and feed rate value? -- valid entries are es / o" * B , "does the F go before or after the feed rate value? -- valid entries are efore / fter" * 1 , "spaces between axis cordinate and feed rate -- valid vaues are ,, * E , "Feed rate specified for ach machining move or odal -- valid values are E & M" * * ========================================== * G00 , "point-to-point straight line rapid traverse command -- generally (G-zero) * or (g-zero-zero) but can be any ascii string 255 characters or less * * G01 , "point-to-point straight line controlled feed command -- generally G-one * or G01 (G-zero-one) but can be any ascii string 255 characters or less * * ========================================== * 0.000 , "granularity or minimum move from X1,Y1,Z1 ==> X2,Y2,Z2" * * units are what ever you selected above nch/mperial or etric * set to zero for best possible resolution. larger values will produce smaller, * faster running programs but detail and smoothness of curves may be degraded. * NOTE: HPGL plotter units are 40 per m/m or 1016 per inch, so best possible * accuracy is 0.001 inches or 0.025 m/m per axis. * * ========= NOTES ================= * * NOTE: HPGL2CNC outputs 2_1/2D moves, i.e. only 2 axis moves in any one block. * * Internally, HPGL2CNC uses PowerBasic long-word [unsigned long integer] * variables for the plotter value storage * and converts to the desired inch/imperial or metric units using double precesion variables * before rounding to your indicated accuracy. * * PowerBasic's website is
formatting link
if you would like more details * Their manual is on-line. * * maximum unsigned long-word PowerBasic value is 4,294,967,295. * * At 1016 plotter units per inch this is a maximum size per side of * 4225361.511 inches, 352113.4592 feet or 66.68815516 miles. * * At 40 plotter units per m/m this is a maximum size per side of 107324182.4 m/m, * 107324.1824 meters or 107.3241824 KM. * * ==========================================

Reply to
F. George McDuffee
Sorry for the confusion in terminology. Range checking limits the max/min feed rate that you can set. For example, 1 ipm to 20 ipm verticle feed rate. You can choose anything you wish in between these values. As not everyone using this program will have extensive experence, it is an effort to minimize tool breakage.
Also I can see turning all the layers in your cad drawing off except the pocket with crosshatching, plotting and macnining (key is to use the offset command) the pocket with a larger tool / feed rate, and then turning the pocket layer off and the lettering layer on to plot the lettering at the bottom of the pocket with a much smaller (possibly ball) end mill and and thus a much smaller feed rate. This is where the clearence above the surface for pen-up [G00] moves, and the maximum plunge below the surface comes in.
With careful attention to tool offsets and using the command in the cad program, you can get very good results in milling cams with this. If anyone is interested I have a lisp [lsp] program I wrote to generate cycloid curves that works with autocad and intellicad.
Uncle George

Uncle George.
Reply to
F. George McDuffee

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.