[Home]User Defined Gcodes

LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org

(see also: CannedCycleProposal)

User Defined Gcode (by lerman)

This page contains a proposed mechanism for user/integrator defined gcodes (and mcodes). The term user and integrator are used interchangeably for now as are gcode and mcode.

A user defined gcode is declared in the .ini file by a stanza like (subject to change)

[gcode]
G31
G1
G2.2
G2
M10

Revised by KL

The CUSTOM section will have custom gcodes and mcodes.

[CUSTOM]
DIRECTORY = /path/to/directory/containing/custom/codes 

GCODE = 31
GCODE = 1
GCODE = 2.2
GCODE = 2

MCODE = 10


AJ: maybe have it like "G31=/path/to/g31.ngc" </pre> Each of the above lines declares that the corresponding gcode will be handled by a variabless subroutine of the same name; eg, O<G31>, O<G1>, O<G2.2>, etc. If there is already a "hardwired" gcode with that number, it may be accessed by adding 100 to the gcode. So, the original G1 will be accessed as G101. For mcodes, add 1000 to the original code. So the original M10 will be accessed as M1010, etc.

A Subroutine For User Defined Gcode

Within a user defined gcode subroutine, special named parameters are accessible.

Consider adding:

This would let the programmer write things like [#<__A> OR #<__X>] to create a mask indicating that A and X are required.

AJ: I suggest a different approach:

Additional commodity functions would be present:



(KL) Instead of the above:

The masks could look like: [#<_Mx> OR #<_My>]. The _allow_require subroutine would check the masks against the variable _mask.

Variables _a, _b, ...,_x, _y, _z would contain the values (assuming the proper mask bits were set). Also, variables __a, __b, ..., __x, __y, __Z would be non-zero if the variables were set.

This would let the user test for the presence of variables in a variety of ways.


Order Of Execution

Gcodes (and mcodes) are executed in the same order as they would have been executed if they were hard implemented gcodes or mcodes. The same rules concerning modal groups, etc are enforced.


Some Infrastructure

After a user defined gcode routine determines that some parameters are missing, it should call:

O<GmissingWord> call [1] [#<missing>] [#<extra>]

In this case, 1 is the gcode number (1) and missing is a parameter with mask bits for the missing parameters. This subroutine will print messages describing the problem and then exit. A similar routine MmissingWord? should be called from mcode subroutines detecting errors.


LinuxCNCKnowledgeBase | RecentChanges | PageIndex | Preferences | LinuxCNC.org
This page is read-only. Follow the BasicSteps to edit pages. | View other revisions
Last edited July 30, 2008 10:27 pm by KennethLerman (diff)
Search:
Published under a Creative Commons License