INSTRUCTIONS:

To find K40 conversion information use the "INDEX", "SEARCH" or "LABELS" sections in the sidebar.

Sunday, December 18, 2016

Gcode: Getting Started

G-coding K40-S & LaserWeb

Getting started with numerical coding languages ......

G-code (or G programming language) is the street name for the most widely used numerical code programming language.  Utilized mainly in automation, G-code is sometimes called G programming language.  Very simply, G-code tells computerized machine tools - like laser systems - what to do and how to do it. For example, how fast to move, what path to take, etc.

M-code (for 'miscellaneous function') is an auxiliary command; descriptions vary.  Many M-codes call for machine functions like 'open workstation door,' which is why some say "M" stands for "machine", though it was not intended to.


A good starting point: 


Donate:

Please consider donating (button to the right of this post).
Your donations help fund additional research, tools and parts that I will return to the community as information.
For other information on the K40-S build use the  K40-S BUILD INDEX with schematics

CAM

A good starting guide for CAD-CAM:

Gcode references:

Gcode's are somewhat universal in definition but various legitimate flavors exist depending on what software is injesting them and what machine they are controlling.
This post focuses on Gcoding that is compatible with the K40-S + LW configuration


What follows does not attempt to recreate the definitions in the links above, rather to document the differences. Refer to the references for complete treatments other than the changes outlined below.

Gcode Simulators/Editors;

For learning and developing Gcode these tools are useful:

Gcode 

Although Gcode is a standard for talking to CNC devices the implementation and interpretation of these codes can vary. This is clearly a case of "your results may vary". The best approach is to create a series of tests that emulate the Gcodes you plan to employ and see how they react. 
For example and in the case of a laser cutter, the way the laser cuts is different than a mill therefore to control power a parameter for setting the lasers PWM is needed. In the K40-S that parameter is the "S" value.
You must understand the adaptations your machines interface software (LaserWeb) and firmware (Smoothieware) have made to properly control the target machine.

Gcode hand coding:

I have found these conventions to be useful in G-coding in a way that is universally interpreted correctly. This is especially true in LaserWeb.
  • Put each Gcode and its parameters on a separate line
  • Use capital letters for parameters i.e. X,Y,Z,F
  • Use at least one decimal place on numbers I.E. G1 X1.0
  • Absolute positioning (G90) is less confusing than incremental positioning (G91) and less likely to run gantries into the stops.

Special K40-S Gcode formats

Adapted Gcodes for K40-S follow.

The G01 command

G01 <X Y F S>
  • X- x position
  • Y- Y position
  • S- Laser power in decimal from 1(max) - 0(min)

Currently Unsupported LaserWeb Gcodes

G20 will be ignored and all values will be interpreted as metric. Example: 1" will render as 1mm

Mcodes (Machine options)

Coordinate systems:

Coordinate systems in CNC can be very confusing but in 2D laser systems they are the simplest. In fact when using software like LaserWeb the complexity of the coordinate systems is transparent to the user.

However there are advanced times when you want to understand the machines movements within the context of the coordinate systems so here is some information.

WCO: Work coordinate offset.

When using your K40 the WCO and MCO aren't important as LW hides this complexity and describes positions within one system.

There are six user-definable work coordinate systems (WCS) available that are selected with the G54-G59 commands (Note that if using Carbide Motion it seems to store position information in G54 and will over-write any user setting). These are modal, meaning that once you select a WCS all following commands will reference that coordinate system until you select a different one. They are also persistent, meaning that they will be stored between resets and power cycles.

http://www.shapeoko.com/wiki/index.php/G-Code#Using_the_Work_Coordinate_Systems

MCO: Machine coordinate offset.

Machine coordinate system. The systems initial home at power on.

http://wiki.linuxcnc.org/cgi-bin/wiki.pl?CoordinateSystems


-------------
Enjoy and comment,
Maker DON