Page 1 of 1

GCode formula

PostPosted: Sat Dec 31, 2022 5:05 pm
by DavidT
Hi,

The M17 macro set the variable #3 to either 0.0 or 0.5.

I can't figure out how to use it in GCode formula.

Code: Select all
...
#3 = 0.0
M17
...
G00 Z80.000
G00 X10.000 Y10.000
G01 X10.000 Y10.000 Z[8.000+#3] (brackets are not interpretable(they, and everything in it, appear in red in the GCode viewer))
G01 X10.000 Y10.000 Z[#3+8.000] (same as above)
G01 X10.000 Y10.000 Z#3+8.000 (will ignore the +8.000)
G01 X10.000 Y10.000 Z8.000+#3 (will ignore the variable)
...


I fear I have to recalculate the Z value for each and every line.
Something like:
Code: Select all
#103 = Zcoord + #3
G01 X10.000 Y10.000 Z#103

Is that right?

Cheers

Re: GCode formula

PostPosted: Tue Jan 03, 2023 9:56 am
by dezsoe
Yes, you are right.

Re: GCode formula

PostPosted: Sat Jan 07, 2023 9:00 pm
by DavidT
Thank you dezsoe.

So far, everything seems to work properly with this method.
The GCode is a bit harder to read, the file size is practically doubled but hey! if it works!? Let's carry on!

Cheers!

Re: GCode formula

PostPosted: Tue Mar 28, 2023 10:43 pm
by DavidT
Hi!

I've been using the previous solution and it works fine but I know encounter the problem that if I merge various GCode together and separate them by M00 (wait for operator to Cycle Start before continuing), the value of #3 is lost ... from what I can understand, it is set to 0 after the M00.

Is there a more robust way to set a variable?

For now I just ask the question again every time I pause but it's redundant and there's a risk of error (if the operator makes a mistake when retyping in the value).

Thank you

Re: GCode formula

PostPosted: Wed Mar 29, 2023 8:16 am
by dezsoe
M0 (or any other internal command) will not zero any variable, so check your g-code, there must be a line that changes it. Also, if you call macros or you have any macroloop then check them.