G-code and M-code are systemic methods for computer numerical control (CNC) of axial motors.
Today I wrote my first G-code file from scratch. This is an automation-assisted z-axis leveling sequence for my 3D printer:
;Printer Bed Calibration, with user feedback. JOSBORNE 27Jul2015
G21 ; set units to millimeters
G28 ;home all axes
T0 ;select tool 0 (extruder 1)
G1 Z10 F1000 ;move to Z 10mm, set Feedrate 1000
G1 X100 Y100 F1000 ;move to X 100mm and Y 100mm, set Feedrate 1000
M104 S0 ;set extruder temp to 0C and return control to host immediately
G90 ;use absolute coordinates, realative to origin of machine
M71 (Select to continue...) ;display message and wait for button push
;first iteration
;back right corner
G1 Z10 F1000
G1 X104 Y110 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;back left corner
G1 Z10 F1000
G1 X30 Y110 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;front left corner
G1 Z10 F1000
G1 X30 Y0 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;front right corner
G1 Z10 F1000
G1 X104 Y0 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;center
G1 Z10 F1000
G1 X70 Y55 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;second iteration
;back right corner
G1 Z10 F1000
G1 X104 Y110 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;back left corner
G1 Z10 F1000
G1 X30 Y110 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;front left corner
G1 Z10 F1000
G1 X30 Y0 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;front right corner
G1 Z10 F1000
G1 X104 Y0 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
;center
G1 Z10 F1000
G1 X70 Y55 F3000
G1 Z0.300 F1000
M71 (Select to continue...) ;display message and wait for button push
M70 P200 (Calibration Complete.) ;display message for 200 seconds (or ms?)
G1 Z10 F1000
G1 X140 Y110 Z50 F3000
M84 ;stop idle hold




