Post Processor System

The format of the generated Gcode files can be controlled using Post Processor files. These are user changeable XML files located in the \post sub folder in the same location as the CamBam.exe file. This is typically 'C:\Program Files\CamBamPlus\post'. The post processor files use a .cbpp file extension.

The post processor used for a specific drawing is set under the machining options. Select the machining folder in the drawing tree and look in the Post Processor group of the machining properties. If no post processor is specified, an internal post is used, intended to be compatible with the RS274 NIST gcode specification as used many common CNC controllers such as Mach3, EMC and USBCNC.

PostProcessor

This option is a drop down list that contains all the custom post processors found in the post folder.

PostProcessorMacros

This option is used to pass user defined macros from the drawing to the post processor. This is a mult-line text field containing multiple macro definitions in the format $macro=value. Some examples of macros are given below.

If post processor files are modified or new ones created, the post processor list should be refreshed using the Tools - Reload Post Processors menu option.

To make a post processor be used as a default for all new drawings, the PostProcessor machining option should defined in an empty CamBam file and this file used in the DrawingTemplate setting under Tools - Options.

Post Processor File Format

Any text editor can be used to edit the .cbpp files, but an editor that supports XML syntax colouring is helpful and can help avoid errors.

The XML file contains a number of sections. Each section can contain a mixture of literal text, which is output to the destination gcode file directly, and text macros of the format {$macro}. The macro definitions are defined within the .cbpp file, internally by the post processor, or by defining user macros in the PostProcessorMacros machining option within the drawing. The macros are evaluatied and the resulting text values are written to the gcode output.

Post Processor Sections

<PostProcessor>

This is the main parent section that can contain the following sub sections.

<PostFile>

This section defines the general structure of the gcode file. It typically includes three macros that are evaluated internally based on rules defined in further sections in the .cbpp file.

{$header} - This macro is evaluated using the <Header> section described below.
{$mops} - This macro is evaluated to a list of blocks of text, one block per each machining operation. Each block is formatted using the rules in the <MOP> section.
{$footer} - This macro is evaluated using the <Footer> section described below.

Example:

        <PostFile>%
        O{$o}
        ( MY FANUC POST )
        {$header}
        G0 X10Y10Z0
        {$mops}
        {$footer}
        %</PostFile>
        

Note, the value of {$o} macro is passed to the post processor using the drawing's PostProcessorMacros property which may contain a value such as '$o=1234'.

The % characters are output literally and would be omitted if not using an RS232 file transfer program.

<Header>

Defines the text rules used by the {$header} macro.

Example:

        <Header>{$comment} {$cbfile.name} {$date} {$endcomment}
        {$tooltable}
        {$comment} CUTVIEWER {$endcomment}
        {$comment} FROM/0,0,5 {$endcomment}
        {$comment} TOOL/MILL,1,0,20.0,0 {$endcomment}
        {$comment}STOCK/BLOCK,{$stock_width},{$stock_length},
            {$stock_height},{$stock_x},{$stock_y},{$stock_z} {$endcomment}
        {$cbfile.header}
        {$units} {$distancemode} {$velocitymode} {$cuttercomp(off)}
        {$toolchange(first)}
        G54 ( Use fixture 1 )
        {$clearance}
        </Header>
        

Once again, the PostProcessorMacros property is used to pass the {$stock_...} macros to the post processor, which in this example may contain text such as:

        $stock_length=150
        $stock_width=150
        $stock_height=12.7
        $stock_x=75
        $stock_y=75
        $stock_z=12.7
        

<Footer>

Defines the text rules used by the {$footer} macro.

Example:

        <Footer>{$clearance}
        G28 G91 Z0
        G90 G53 X-15.0 Y0.0
        M09
        {$spindle(off)}
        {$endrewind}
        </Footer>
        

<ToolTableItem>

Defines how each item of the {$tooltable} macro is produced. Tool tables are typically inserted in the header of a file and contains commented text describing the list of tools that are used in the gcode file.

Example:

        <ToolTableItem>{$comment} T{$tool.index} : {$tool.diameter} {$endcomment}</ToolTableItem>
        

<ToolChange>

Defines how the {$toolchange} macro is formatted.

Example:

        <ToolChange>{$clearance}
        {$comment} T{$tool.index} : {$tool.diameter} {$endcomment}
        {$comment} Tool Radius and Taper coming soon {$endcomment}
        {$comment} TOOL/MILL, {$tool.diameter}, {$tool.radius}, 
            {$tool.length}, 0 {$endcomment}
        T{$tool.index} M6</ToolChange>
        

<MOP>

Defines how each item of the {$mops} macro is formatted. Each active machining operation in the drawing will have its own <MOP> section.

Example:

        <MOP>{$comment} {$mop.name} {$endcomment}
        {$toolchange}
        {$velocitymode} {$workplane}
        {$mop.header}
        {$spindle} {$s}
        {$blocks}
        {$mop.footer}</MOP>
        

<G0>, <G1>, <G2>, <G3>, <G81>, <G82>, <G83>

These sections define how the commonly used Gcode operators are output.

<Rapid>, <FeedMove>, <ArcCW>, <ArcCCW>, <Drill>, <DrillDwell>, <DrillPeck>

These sections define how the commonly used Gcode move instructions are formatted.

Example:

        <Rapid>{$g0} {$_f} {$_x} {$_y} {$_z} {$_a} {$_b} {$_c}</Rapid>
        <FeedMove>{$_g1} {$_f} {$_x} {$_y} {$_z} {$_a} {$_b} {$_c}</FeedMove>
        <ArcCW>{$g2} {$_f} {$_x} {$_y} {$_z} {$i} {$j}</ArcCW>
        <ArcCCW>{$g3} {$_f} {$_x} {$_y} {$_z} {$i} {$j}</ArcCCW>
        <Drill>{$g81} {$_x} {$_y} {$_z} {$_r} {$_f}</Drill>
        <DrillDwell>{$g82} {$_x} {$_y} {$_z} {$p} {$_r} {$_f}</DrillDwell>
        <DrillPeck>{$g83} {$_x} {$_y} {$_z} {$p} {$_q} {$_r} {$_f}</DrillPeck>
        

Note: The gcode operators {$g...} and their parameters can specified using an underscore (_) prefix. This is to show values that are modal (or sticky). That is they will only be output if the current value has changed. Omitting the underscore will force the parameter to be always output.

<Comment>

Defines the text to be used at the beginning of a comment.

Example 1:

        <Comment>(</Comment>
        <EndComment>)</EndComment>
        

Example 2:

        <Comment>;</Comment>
        <EndComment></EndComment>
        

<EndComment>

Defines the text to use at the end of a comment. Can be left blank for systems that use ; comment characters.

<NumberFormat>

This is a string formatting pattern that controls how floating point numbers are displayed.

A hash character (#) denotes an optional digit place holder and a 0 character denotes a digit that is always displayed, adding padding zeros if required.

It can also change the gcode instructions that are required. For example, if a toolpath contains a move from X=1.234 to X=1.233 and a number format of #.#0 is used, no move instruction will be written to the gcode as the coordinates are identical when formatted to 2 decimal places.

<UpperCase>

If set to True, the post processor converts all text written to the gcode file to upper case. This is particularly useful for Fanuc posts that do not support lower case characters.

Example:

<UpperCase>true</UpperCase>

<MinimumArcLength>

A numerical value that controls the precision limits used for outputting arc moves (G2, G3). If the length of an arc is less than the MinimumArcLength value then a straight move (G1) is used instead. This is useful for TurboCNC users where very small arcs can cause glitches that may appear as dimples in the toolpath.

Example:

<MinimumArcLength>1e-4</MinimumArcLength>

<MaximumArcRadius>

A numerical value that controls the maximum radius allowed for arc moves. If an arcs radius exceeds this value, a straight line move (G1) is used.

Example:

<MaximumArcRadius>1e6</MaximumArcRadius>

Post Processor Macros

$blocks

This macro is generated internally and contains all the move instructions required by the current machine operation (MOP)'s.

$comment

Inserts the text defined in the <Comment> section of the .cbpp file.

$cbfile.footer

Inserts the drawing’s Machining option CustomFileFooter property.

$cbfile.header

Inserts the drawing’s Machining option CustomFileHeader property.

$cbfile.name

Inserts the drawing’s Name property.

$check(x,y,z)

Generated internal, this macro checks the x,y,z coordinate parameters against the current tool location. If different a sequence of moves will be inserted to move to the new position using the clearance plane and plunge feed rates where necessary.

$clearance

Rapids to the clearance plane.

$cuttercomp(off|L|R)

Cutter radius compensation. Note: CamBam does not currently calculate radius compensation codes for toolpaths.

off = G40, L=G41, R=G42

$date

Inserts the current date time stamp

$distancemode

Currently this always equates to G90

$endcomment

Inserts the text defined in the <EndComment> section of the .cbpp file.

$endrewind

Currently hard coded to: M30.

$footer

Evaluates the text in the .cbpp <Footer> section of the .cbpp file.

$g0, $g1, $g2, $g3, $g81, $g82, $g83
$_g0, $_g1, $_g2, $_g3, $_g81, $_g82, $_g83

These Gcode macros control how the gcodes are output. The format of each code is taken from the <G...> definitions in the .cbpp file. This may be useful to control zero padding (eg G1 vs G01), or to use alternative G codes.

If the underscore (_) prefix is used, these instructions are assumed to be modal (or sticky). That is the first occurrence of the code will be written but omitted if following blocks use the same instruction.

$header

Evaluates the text in the <Header> section of the .cbpp file.

$mop.footer

Inserts the current machining operation's CustomMOPFooter property.

$mop.header

Inserts the current machining operation's CustomMOPHeader property.

$mop.name

Inserts the current machining operation's Name property.

$mops

Inserts a list of objects, one item for each enable machining operation. Each list item is defined using the <MOP> section definition of the .cbpp file.

$repeat

Currently hard coded to: M47

$s

Inserts the current machining operation's SpindleSpeed property.

$spindle

Inserts a macro depending on the current machine operation's SpindleDirection property (cw=M3, ccw=M4, off=M5).

$spindle(off|cw|ccw)

cw=M3, ccw=M4, off=M5

$stop

Currently hard coded to: M0

$tool.diameter

Inserts the current machining operation's ToolDiameter property.

$tool.index

Inserts the current machining operation's ToolNumber property.

$tool.radius

Uses the current machining operation's ToolProfile property to determine a radius. 0 for EndMills and Diameter / 2 for bullnose.

$tool.length

Currently inserts 0. Future releases will get this information from a tool database.

$toolchange

Inserts a tool change instruction, based on the <ToolChange> definition in the .cbpp file. If the tool number has not changed, no tool change code is inserted.

$toolchange(first)

Inserts a tool change instruction using the first tool in the current drawing's tool table.

$tooltable

Inserts a list of objects for each tool that is referenced in the current drawing. Each item in the list is formatted using the <ToolTableItem> definition in the .cbpp file.

$units

Uses the drawing's Units property. Inches = G20, Millimeters=G21

$velocitymode

Inserts the current machining operation's VelocityMode property

ExactStop=G61, ConstantVelocity=G64

$workplane

Inserts the current machining operation's WorkPlane property.

XY=G17, XZ=G18, YZ=G19

$x, $y, $z, $a, $b, $c, $i, $j, $f, $r, $p, $q
$_x, $_y, $_z, $_a, $_b, $_c, $_i, $_j, $_f, $_r, $_p, $_q

These macros insert the parameters used in common Gcode move operations. If an underscore (_) prefix is used, these parameters are treated as modal. That is they will only be output if the current value has changed. Omitting the underscore will force the parameter to be always output.

Copyright (c) 2017 HexRay Ltd