Hello Guest it is July 21, 2019, 03:37:16 AM

Author Topic: Negatating variables in G-code.  (Read 7480 times)

0 Members and 1 Guest are viewing this topic.

Negatating variables in G-code.
« on: January 26, 2010, 06:38:56 PM »
Minor irritation.

I use variables to make reusable G-Code modules without using unportable Macros.

When porting them over to Mach, I have to find and edit any location that wants to use the negative of a stored variable. Literally hundreds of locations.

For example:

M98 P30
#141 = [#141-#506]
#142 = [#142-#506]
X[-#141]Y[-#142]
M98 P30

fails with the message: "No digits found where real number should be"

While:

M98 P30
#141 = [#141-#506]
#142 = [#142-#506]
X[0-#141]Y[0-#142]
M98 P30

Works.

You should be able to negate a variable without subtracting it from a real number.

Offline stirling

*
  • *
  •  2,188 2,188
  • UK
    • View Profile
    • www.razordance.co.uk
Re: Negatating variables in G-code.
« Reply #1 on: January 27, 2010, 06:08:00 AM »
Hi

are you saying you can do this in another dialect of gcode? Certainly a cursory look at the NIST RS274/NGC Interpreter syntax (which I believe Mach conforms to) suggests that it doesn't support simple negation of parameters. Looks like you're stuck with either 0- or -1*. Not very satisfactory I agree.

Cheers

Ian
Re: Negatating variables in G-code.
« Reply #2 on: January 27, 2010, 11:30:51 AM »
Lots of silliness in the g-code syntax.  Would be an easy thing to upgrade in Mach3, and if Fanuc does it (or even EMC), Mach3 should too.

With all that said, can't you find and fix them with a few search and replaces?

Doesn't seem like there are all that many cases.

    Search '[-' Replace '[0-'

Would cover the example given.  There are others that could be done with a canned search and replace, and probably some you just have to look at.

I'm curious which controls allow this if anyone knows?

Best,

BW
Try G-Wizard Machinist's Calculator for free:

http://www.cnccookbook.com/CCGWizard.html

Offline Graham Waterworth

*
  • *
  •  1,863 1,863
  • Yorkshire Dales, England
    • View Profile
Re: Negatating variables in G-code.
« Reply #3 on: January 27, 2010, 11:58:52 AM »
Version 4 can do it  :)

Graham
Never give up, time will pass, the cloud will clear, the sun will shine once more.
Re: Negatating variables in G-code.
« Reply #4 on: January 27, 2010, 02:11:09 PM »
Version 4 can do it  :)

Graham


Looking forward to it...
Re: Negatating variables in G-code.
« Reply #5 on: January 30, 2010, 01:07:29 PM »
Wow, there's a G code standard that states that expressiions like #1 = [-#2] aren't legal?

I've reported that as bug in Mach several times over the past couple of years and I thought it just never made it high enough up on the priority to get fixed, I didn't know there was actually a spec somewhere saying it shouldn't be legal.

Having to do #1=[0 - #2] sure makes macros look ugly, I'd be really surprised of most of the modern CNC controllers (Fanuc, Haas, Fadal, Siemens, etc.) still adhered to that part of the spec.

Paul T.
Re: Negatating variables in G-code.
« Reply #6 on: January 30, 2010, 02:18:38 PM »
Wow, there's a G code standard that states that expressiions like #1 = [-#2] aren't legal?

It appears from reading the specifications there are several cases where the committee had it's head buried where the sun doesn't shine.

My pet peeve at this time is not allowing L0 on canned cycles. Other machines I have programmed do allow this, but the spec does not.

It is very useful to separate the definition of the canned cycle and the locations it is to be executed...
Re: Negatating variables in G-code.
« Reply #7 on: January 30, 2010, 06:02:51 PM »
Flyer, I'm assuming you mean that you would like L0 as a subroutine argument to mean that the subroutine does not get executed-

If so, this interpretation was implemented in Mach a year ago or so. Its very useful as it allows conditional execution, which otherwise can't be implemented in Mach as it doesn't support If Then statements.

Paul T.
Re: Negatating variables in G-code.
« Reply #8 on: January 30, 2010, 06:22:16 PM »
Wow, there's a G code standard that states that expressiions like #1 = [-#2] aren't legal?

I've reported that as bug in Mach several times over the past couple of years and I thought it just never made it high enough up on the priority to get fixed, I didn't know there was actually a spec somewhere saying it shouldn't be legal.

Having to do #1=[0 - #2] sure makes macros look ugly, I'd be really surprised of most of the modern CNC controllers (Fanuc, Haas, Fadal, Siemens, etc.) still adhered to that part of the spec.

Paul T.

G-code is largely defined by the NIST RS-274D standard:  http://www.isd.mel.nist.gov/documents/kramer/RS274NGC_3.pdf

Keep in mind, G-code was defined in the 60s, when computing power was *extremely* limited, which is why it's so simple, and, in some cases, seemingly brain-dead.  However, while most G-code interpreters are based on the spec, almost all have taken liberties with the definition in some areas as well, so there really is no "standard".  Fanuc seems to be about the most common variant.

Regards,
Ray L.
Regards,
Ray L.
Re: Negatating variables in G-code.
« Reply #9 on: January 30, 2010, 11:41:40 PM »
Flyer, I'm assuming you mean that you would like L0 as a subroutine argument to mean that the subroutine does not get executed-

If so, this interpretation was implemented in Mach a year ago or so. Its very useful as it allows conditional execution, which otherwise can't be implemented in Mach as it doesn't support If Then statements.

Paul T.

It does work to cause the canned cycle to not execute when given. However, it modified the Q word. I had 0.1 in the Q word, it applied 0.01. the program took ages when I tried it. Sped back up after setting L1 and giving it a safe X and Y Location to drill.