Hello Guest it is March 19, 2024, 05:51:21 AM

Author Topic: Gcode questions pt2  (Read 11401 times)

0 Members and 1 Guest are viewing this topic.

Offline alenz

*
  •  137 137
    • View Profile
Re: Gcode questions pt2
« Reply #20 on: October 19, 2009, 02:11:49 AM »
put the revised # value in square brackets -

#100 =[#100+0.010]

this should work now ;)
Thank you! I wonder how many others besides me puzzled over this one? I vaguely remember years ago dabbling in GW-BASIC and the # declared a double-precision variable, a $ was a string etc.  But arithmetic operations used parentheses not square brackets.
So just out of curiosity, where does the square bracket come from?
al
Re: Gcode questions pt2
« Reply #21 on: October 19, 2009, 03:49:43 PM »
no idea where it comes from. It just makes Mach calcualte the value of what's in the brackets before it does anything with it. Brackets can be nested for more complex functions, of course.

G40 G21 G15

G0 X0 Y10 Z10

M3 M8

#1= 1.5
#2= 2.5

G0 Z1.0

G0 Y[#1]
M98 P1 L20

G0 Z10
M30

O1
G03 X0 Y[#1] Z[#1*[#2*0.01]] I0 J0 F500
#1= [#1+0.2]
#2= [#2*1.2]
M99
%

This is a complete nonsense program that doesn't make anything useful, but it does at least show a little of what can be done with comparatively simple parametrics. If you know the maths behind a particular shape, you can get Mach to do all the work. It can also form the basis of an internal (or at least alternate) offsetting system for ball-ended tools, radiused tools and other strange shapes. Just get it to re-calculate where it needs to be again and again. Effectively what you're doing is the same that a CAM program would do, except you miss out the messy bit in the middle where you generate 4 or 5 megs of ugly code. I'm quite evangelical about hand-coding, as you've found out it becomes very easy after a while to start fine-tuning it, and you rapidly get to understand exactly what's going on.  :)
Re: Gcode questions pt2
« Reply #22 on: October 19, 2009, 03:55:36 PM »
put the revised # value in square brackets -

#100 =[#100+0.010]

this should work now ;)
Thank you! I wonder how many others besides me puzzled over this one? I vaguely remember years ago dabbling in GW-BASIC and the # declared a double-precision variable, a $ was a string etc.  But arithmetic operations used parentheses not square brackets.
So just out of curiosity, where does the square bracket come from?
al


My guess is parameters and doing arithmetic operations on them, came along after the first version of G-code was created.  Parens could not be used, since they were already allocated to enclosing comments.  So, square brackets were used instead.  I'm sure G-code, like most languages, evolved over time, rather than being all planned out in advance, which always leads to such minor syntactical oddities.

Regards,
Ray L.
Regards,
Ray L.

Offline alenz

*
  •  137 137
    • View Profile
Re: Gcode questions pt2
« Reply #23 on: October 19, 2009, 04:10:23 PM »
Thanks fellows for the feedback. Makes sense.
al