Creating A Laser Post Processor
Virtually all CAM systems allow you to target different CNC machines through the use of a Post Processors (post). Post Processors tailor the ouptut to the target machine. While most machines can handle G-Code, each machine has it’s own requirements. Many Post Processors are so flexible that you can even get them to output HPLG, DXF, and other vector based file formats.
Post Processor formats and rules vary between manufacturers, but the general procedure of creating a custom one is basically the same. I will detail how I created a basic Mach3 E1P1 style post processor for my Vectric Aspire CAM program. Aspire is way overkill for a laser, but this Post Processor will work for all the Vectric products including the more affordable CUT2D which is perfect for a laser. Most CAM vendors will produce a guide for the post processor format. I got the one for Vectric from their forum.
Most programs ship with many Post Processors. Start with one that is closest to what you want. In my case I picked a Mach2/3 Arcs (inch) post. This targets Mach3, and uses arcs for curves instead of multiple line segments. You should also create a simple CAM file to test. I created one with a 1″ x 2″ rectangle and a 1″ diameter circle. Both items are offset from home. Locate the items on a simple grid so it is easy to find the items in the resulting G-Code.
Study the existing post’s output.
I started by creating a G-Code file from the existing post. To simplify the resulting g-code, do a profile cut on the lines with a single pass. My file had a home position of 0,0,1 and did a single pass cut at Z = -1. The rapid clearance gap was 0.5″. A snippet of the resulting G-Code file is here.
N100G00G20G17G90G40G49G80N110G70G91.1N120T1M06N130 (Tool: End Mill {0.25 inch})N140G00G43Z1.0000H1N150S12000M03N160(Toolpath:- out)N170()N180G94N190X0.0000Y0.0000F100.0N200G00X1.0000Y1.0000Z0.5000N210G00X1.0000Y1.0000Z0.2000……N360G00Z1.0000N370G00X0.0000Y0.0000N380M09N390M30
So what the heck does all this mean? Well, me to the rescue (again). I created this G-Code Commenter. You paste G-Code on one side and it copies it to the other with comments explaining the code.
By looking at the resulting file I created a list of things I need and want to change.
- Remove spindle control commands, M03 (on) near the beginning and M05 (off) near the end.
- Remove any spindle speed commands like the S1200 in the file above.
- Remove any tool change commands T1M06, tool offsets, compensation, etc.
- Remove any mist coolant type commands like M07,M08,M09. (Later you may want to re-purpose these for assist air).
- Remove any references to the Z axis. For this cutter application, we only want 2D motion.
- Add in the beam on, E1P1 and beam off, E1P0 commands before and after each cut.
- Readability. G-Code does not care where spaces and line feeds are, so adding a few of these can make the code a lot easier to read.
Create the new post.
The post processor file is divided into sections, like HEADER, FOOTER, RAPID_MOVE, FIRST_FEED_MOVE, etc. When the CAM program is creating the output file, it follows the format in these sections. Below is the section for RAPID_MOVE.
+—————————————————
+ Commands output for rapid moves
+—————————————————
begin RAPID_MOVE
“[N]G00[X][Y][Z]”
The letters in square brackets are variables. In this case, N is an incrementing line number, XYZ are the desired XYZ destination for the rapid move. All we need to do to this line is remove the [Z]. I also added spaces between all the commands and variables for readability.
+—————————————————
+ Commands output for rapid moves
+—————————————————
begin RAPID_MOVE
“[N] G00 [X] [Y]”
Leaving the E1P0/E1P0 issue for later we go through each section and apply the desired changes from the list above. In the HEADER section I also split up the commands onto their own lines. You may want to try creating G-Code from your post a few times along the way to see it is is doing what you want. I also ran my on my laser a few times to see if it was doing what I intended. Be sure to lockout the beam during your initial tests.
The last task is to apply the E1P1/E1P0 Beam On/Off commands to the file. The post file has a FIRST_FEED_MOVE section. This was a good place to turn my beam on. I put “[N] E1P1” as the first line of the section. To turn off the beam, I put “[N] E1P0” at the beginning of the RAPID_MOVE section and just for safety, I also put it at the beginning of the FOOTER section.
Here is the G-code from my post.
( t3 ) ( File created: Saturday, July 10, 2010 - 01:34 PM) ( for Mach2/3 from Vectric/bdring ) ( Material Size) ( X= 2.000, Y= 2.000, Z= 0.234) () (Toolpaths used in this file:) (t3) (Tools used in this file: ) (1 = Laser Mill {0.005 inches}) N100 G00 N110 G20 N120 G17 N130 G90 N140 G80 N150 G70 N160 G91.1 N170 (Laser Mill {0.005 inches}) N180 G00 N190 (Toolpath:- t3) N200 () N210 G94 N220 X0.0000 Y0.0000 F150.0 N230 E1P0 N240 G00 X0.0000 Y0.0000 N250 E1P1 N260 G1 F30.0 N270 E1P1 N280 G1 X1.0000 F150.0 N290 G1 Y1.0000 N300 G1 X0.0000 N310 G1 Y0.0000 N320 E1P0 N330 G00 N340 E1P0 N350 G00 X0.03 Y0.03 (Insure a move before end) N360 G00 X0.0000 Y0.0000 N370 M30 %
it was very interesting to read.
I want to quote your post in my blog. It can?
And you et an account on Twitter?
Sure feel free…no Twitter yet.
I’ve recently started a blog, the information you provide on this site has helped me tremendously. Thank you for all of your time & work.
[…] created one for Aspire last year and found that it worked perfectly for Cut2D as well. I wrote a blog post about it and the file is available here. All Z movement is removed from the post processor, so […]
amazing
Thanks!
I’m working on a lasersaur and this will be very helpful.
i TRIED TO MODIFY MY POST BUT AFTER i SAVE IT IN THE POST P FOLDER…i DON’T SEE IT IN MY POST PROCESSOR SELECTION LIST WHEN i TRY TO OUTPUT THE g_code. i AM USING VCARVE PRO 4.6.
Any suggestions???
Thanks