-
Notifications
You must be signed in to change notification settings - Fork 55
Anatomy of output of the Post Processor
Let me explain the anatomy of the output of this post-processor:
First there is a 'header' section which initializes the G-Code parser in the CNC Controller to the right state. This section could be extended with more initializations if needed, but for the time being it seems this contains all that is needed for GRBL. In fact GRBL already defaults to most of these settings, but could be in a different state after a previous program, so its safe to set them anyway.
% // This is not really G-Code but some controllers use it to switch from manual-command-mode into file-mode
G90 G94 // Set coordinates in absolute mode (not relative) and set feedrates in units/min
G17 // Set the plane for ARCs as XY
G21 // Set units to your units, mm in this example, so the remained of this example will use mm
Then at the beginning of each operation we move the Z-Axis (Spindle) all the way UP to its machine top - 2 mm. This is done to ensure that when we don't hit anything when moving to the starting position of the operation. We move UP to top - 2 mm io of just top, because on some machines moving up to top ( Z = 0) may trigger the limit switch. The G53 in the command makes this move in machine coordinates, instead of work coordinates.
G53 G0 Z-2
Then we set the Work Coordinate System
G54
Activate the spindle : M3, spindle speed 30000 rpm
S30000 M3
Wait some time (0.8 s in this example) for the spindle to get up to speed
G4 P0.8
From here on the output is the toolpath as generated from Fusion360. Fusion360 first moves in XY, then moves down, usually in several steps : In this example the job starts at X = -142.25, Y = -142.25 then it moves down to Z = 80, (to what is set as clearance or retract height in Fusion360) then Z = 60, (to what is set as Feed height in Fusion360) finally it moves down to Z = 54 at feedrate speed 500 mm/min (now it is at the Z to start the toolpath)
X-142.25 Y-142.25
Z80
Z60
G1 Z54 F500
... more toolpath G-Code here ...
At the end of the operation, Fusion360 does the reverse operations: Move back up to Feed Height (Z = 60 in this example), then move back up to Clearance or Retract Height (Z = 80 in this example)
G0 Z60
Z80
This is the end of the toolpath. In order to properly end the operation, the post-processor now adds a trailing section: Move the spindle up to machine coordinates (top - 2), for the same reason as above : we are about to move the spindle home, but want to avoid hitting anything, so we move it up. We only move to 'top - 2' io. 'top' in order to not hit any limit switches. Then we stop the spindle (M5), We wait 0.8 s for the spindle top come to a stop. Reason is if the spindle is still running, it will 'blow' the chips all over the machine while going home. To avoid this we stop the spindle before the home move. Then we move to machine coordinates X = -5, Y = -5 (whatever you set as a home location in the settings), Then we send a 'program end', this resets the controller to a predefined state for the next job. Finally the % sends the 'end of file'. This is not really G-Code, but some controllers use it to go from file-mode back into manual command mode.
G53 Z-2
M5
G4 P0.8
G53 X-5 Y-5
M30
%