Hello Guest it is March 28, 2024, 07:00:07 PM

Author Topic: Re-useable lists of Parameters for use in G-Code files  (Read 7010 times)

0 Members and 1 Guest are viewing this topic.

Offline birdbrain

*
  •  41 41
  • Stupidity, beyond belief!
    • View Profile
Re-useable lists of Parameters for use in G-Code files
« on: November 01, 2009, 02:22:53 AM »
I have a number of G-Code files that use my own standard lists of parameters. For example, I have a standard set of feed rates, I also have sets of standard parameters for various stock.
When I write a new code file, I include many of these standard parameters at the beginning of the file. This works OK but it's cumbersome. Also, when I change the stock for a job I have to re-write all the files for that job with the new stock parameters, this is tedious and is prone to errors.
How can I put these parameters in external files (macros?) so that I can then call the correct set of parameters from the G-Code file? Is there a way to include an external file within a code file (like the "include" statement in PHP) or must the parameters be set in macros?

Here is a small example of parameter settings that I use in many code files:

(max feed rate)                #2001=200
(feed rate inch 4)            #2101=[#2001*0.03]
(feed rate inch 3)            #2102=[#2001*0.06]
(feed rate inch 2)            #2103=[#2001*0.1]
(feed rate inch 1)            #2104=[#2001*0.2]
(feed rate slow 2)            #2105=[#2001*0.4]
(feed rate slow 1)            #2106=[#2001*0.7]
(feed rate normal)           #2107=[#2001]
(feed rate fast)                #2108=[#2001*1.5]
(feed rate fast 2)             #2109=[#2001*2]


Can anyone give me an example of how I can call the above code (stored in it's own file) from within any G-Code file?
« Last Edit: November 01, 2009, 02:24:24 AM by birdbrain »

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #1 on: November 01, 2009, 05:02:22 AM »
Store each parameter list in a named file in the subprogram folder inside the mach3 folder and then call the file from your g-code with a M98 filename.tap

Graham
Without engineers the world stops

Offline birdbrain

*
  •  41 41
  • Stupidity, beyond belief!
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #2 on: November 01, 2009, 05:44:41 AM »
Hi Graham,

Thanks a lot!  :) I'm going to give that a try later when I fire up my machine.

I knew there had to be an easy way.  ::)

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #3 on: November 01, 2009, 06:28:24 AM »
Just a word of warning :-

#2001 onward are used by Mach3 as data locations for tool offsets, you may get strange results if you use them.  #100 to #149 and #500 to #531 are user variables #1000 and over are system read only use. That said you can write to them to set system values.

Graham


Without engineers the world stops

Offline birdbrain

*
  •  41 41
  • Stupidity, beyond belief!
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #4 on: November 01, 2009, 09:15:45 AM »
I haven't had any problems with the parameter numbers. I use a lot of parameters in my code files.
According to the Mach3 manual the following parameters are "system defined": 5161 - 5326 and 10281-10306 so I don't use parameters in the 5k or 10k ranges.
Is there a list of "system values" that differs from the "system defined" parameter numbers as given in the manual?
By the way, I don't think that #1000 and over are system read only as I always use #1020 to #1030 and #1040 to #1050 in my code files. I also always use #001 to #010 as temporary data storage during code execution.
« Last Edit: November 01, 2009, 10:45:55 AM by birdbrain »

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #5 on: November 01, 2009, 05:50:11 PM »
Set your G54 XY & Z to a known value then read #2501, 2 & 3 see what you get.

Graham
Without engineers the world stops

Offline birdbrain

*
  •  41 41
  • Stupidity, beyond belief!
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #6 on: November 02, 2009, 02:30:12 AM »
How do I read #2501 etc?
Maybe it's not necessary to check this. I have occasionally noticed problems with G54 and was not able to use G52 at all  :(
« Last Edit: November 02, 2009, 03:46:26 AM by birdbrain »

Offline birdbrain

*
  •  41 41
  • Stupidity, beyond belief!
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #7 on: November 02, 2009, 03:44:20 AM »
Just a word of warning :-

#2001 onward are used by Mach3 as data locations for tool offsets, you may get strange results if you use them.  #100 to #149 and #500 to #531 are user variables #1000 and over are system read only use. That said you can write to them to set system values.

Graham




In my g-code part cutting files, I typically use about 100 user variables. Even my simplest files have over 40 user variables From what you say, mach3 shouldn't use files written like this.
I make parts for musical instruments and there are many variations of each part to accommodate different tunings and other preferences. I have generic code files for each part and then change the values of certain user variables to suit the specific part being made. The code files contain various calculations, the results of which are stored as numbered parameters (user variables) for use in cutting the part .
This is the only way I could find so that I can make a small number of generic files that could easily be adapted to suit specific dimensions.
An alternative would be to write a (very long) file for every variation of each part.
Is there another way to do this?
The feed rates, of course, could be written directly into the appropriate blocks.
What I would be looking to do is reduce the number of variables that I am presently using to just the essential ones with part/stock dimensions. Then, perhaps use these variables externally (macro?) to make all the calculations and use the results of these calculations to cut the parts.
All my parts are made from tubes, but the cuts I make in them are not standard holes. I have to machine the sides of any hole cut through the tubes, with various profiles. Cuts that are across the width of the tube can be made with either "a" axis "y" axis or combination of both.
You might wonder why I write all of this code by hand. It's because I can't find an economically priced software program that can do it. Most commercially available software seems to assume that you are cutting solid blocks, sheets or if it's a pipe you are doing conventional pipe fitting.
My CNC mill is a custom K2CNC with a 4th "a" axis concentric to the "x" axis.
Any suggestions would be very welcome.

Offline Graham Waterworth

*
  • *
  •  2,668 2,668
  • Yorkshire Dales, England
    • View Profile
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #8 on: November 02, 2009, 05:49:57 AM »
You can do what you are doing you just need to use the correct sets of variables:-

1 to 33 are local variables, there value can only be used within the current g-code file,

100 to 149 and 500 to 531 are global and can be used over any number of files.

In the later versions of Mach variables 500 to 600 are global variables.

Mach version 4 is much more strict about # values and locks certain blocks to read only.

G52, G92 and all the G54-G59 fixture offsets position data is stored in #2500 range

Tool offset data is stored in the #2000 range.

Graham
Without engineers the world stops
Re: Re-useable lists of Parameters for use in G-Code files
« Reply #9 on: November 14, 2009, 05:33:48 PM »
Hi,

Maybe I was not checking excessively, but where do I find the list of these variables?
In the MACH user manual only a few are mentioned...
A full chart would be handy, with some explanation. (I have just seen you say 1-33 local var, 100-149 global, etc...)

I want to use them on G-code level, no VB or macro and such for the moment :)