How to determine whether the system is in G20 or G21

I need to know whether the system is in G20 or G21 inside a subroutines since I use the #5410 read-only variable for the Tool Diameter which is apparently always stored in “Inches” Units. Is there a read-only variable location that stores the G20/G21 status?

Do you have to read it in and make a decision off of it? Can you just set the g20/ 21 status before running your operation?

That is what I am doing now, I set the G20/G21 parameter at the beginning of the program and then pass to the subroutine the current tool diameter in current units. I just wanted to know if there is a read-only variable location which holds the flag to the G20/G21 status so that I can get the status and if in G21, set the tool diameter to [25.4 * #5410] otherwise set it equal to #5410

Try something like

o100 if [#<_metric> EQ 1]
#<unit_conv> = 25.4
o100 else
#<unit_conv> = 1
o100 endif

Then always multiply by #<unit_conv>

That is exactly what I needed David. The only question is now, who defined #<_metric> since I did not. I would assume that the PathPilot operating system did it. Where in the Tormach documentation is a list of these predefined #<_global_named_parameters>? For ease in reading my code, I use self defined global named parameters all the time, e.g., #<_ToolRadius> = [#5410 / 2] but I always know that I’m in G21. I also knew that Tormach had reserved 10320 numerical parameters of which 5653 can be addressed with a # prefix, however #5654 through #10320 can not be addressed and cause an “array out of bounds error”. This might be where these predefined #<_global_named_parameters> are stored. Is there a list?

Again thanks David, I found the list in the LinuxCNC G Code language reference book.

Jeffrey,

#<_metric> is a Tormach created parameter.

Historically the only place that parameters we’ve created was documented is in the code itself, parameters we’ve made have always been done on an ad hoc basis as a need arises for a particular feature. I started a KB article here that documents most of the parameters, but I haven’t filled out (ie, I don’t know off hand) the function of ~1/2 of them. Working on that page I do in my spare time, so completing it will likely take a while. If there’s a specific 1 or 2 on the list that doesn’t have it’s function listed you think you’d use, let me know and I’ll look it up.

Thank you,
Norman

Thank You Norman,
I’ve had my 1100MX for two years next month and had never found the Tormach KB until you gave me the link (there is no link from the Tormach website that I have found). This knowledge base contains the answer to a lot of questions I’ve had over the last two years. Every new user should be pointed to it on day one.
With regard to the predefined named parameters, now that I know that Tormach modeled the operating system loosely after the LinuxCNC G Code it is simple to use the EXISTS function to determine whether a named parameter has been defined and then use it if defined.

I was just having another look at that list and I know of one that’s missing.

#<_epochtime> returns the current date/time as a Linux epoch time value.

1 Like

I did miss that one. Added to the list.

Thank you,
Norman