Hello Pythagoras

A place to discuss and ask questions about all things Machining for Mills, Lathes, Laser, and Routers

Moderator: cnckeith

Post Reply
Gerral
Posts: 26
Joined: Fri Nov 22, 2024 4:25 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: B4107B77A373-0905248481
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Hello Pythagoras

Post by Gerral »

Our work depends on values that are taken from probing... in this case the Pythagoras theorem.

#31509 = #31501- [ #31502 - SQRT[ [ #31502 ^ 2 ]-[ 19.0000 ^ 2 ]]]

When this runs I get an undefined variable error.

I deconstructed the formula to simplify it for the controller and still have an issue.

Here you see where there is a value in #31502
IMG_5036.jpg
When taking the square root of the of the sum of the square of the sides.
IMG_5037.jpg
I'm still getting the undefined variable error

I am missing what I'm doing wrong.

Thanks in advance for your help and opinions. Sorry the images show sideways.
Attachments
report_80F5B5295763-1116215369_2025-01-07_16-28-04.zip
(1.16 MiB) Not downloaded yet


cncsnw
Posts: 4266
Joined: Wed Mar 24, 2010 5:48 pm

Re: Hello Pythagoras

Post by cncsnw »

It looks like the "^" operator (exponentiation) binds with higher precedence than the "#" operator (variable dereferencing).

As a result, "#2 ^ 2" evaluates as "#[2 ^ 2]" and returns the value of variable #4.

"#31502 ^ 2" tries to access variable #992376004, which is invalid.

To get around this, you have to write "[#31502] ^ 2" instead.


Gerral
Posts: 26
Joined: Fri Nov 22, 2024 4:25 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: B4107B77A373-0905248481
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Hello Pythagoras

Post by Gerral »

You're exactly right. Great catch.

How do I report this bug?

Thanks again!


suntravel
Posts: 3086
Joined: Thu Sep 23, 2021 3:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 6433DB0446C1-08115074
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Germany

Re: Hello Pythagoras

Post by suntravel »

Gerral wrote: Wed Jan 08, 2025 8:07 am You're exactly right. Great catch.

How do I report this bug?

Thanks again!
It is not a bug, it is a feature ;)

8.2.14 [ ] – Numerical Expression
The left bracket ‘[’ and right bracket ‘]’ are used to delimit a numerical expression. Numerical expressions can contain
floating-point numbers or user/system variables in combination with mathematical operators and functions. The left
parenthesis ‘(’ or bracket ‘[’ and right parenthesis ‘)’ or bracket ‘]’ can be used between the first left bracket and last
right bracket to force operator precedence or associatively. A bracketed numerical expression can be used anywhere
a number would be used. Comparison operators (‘eq’, ‘ne’, etc.) have built-in rounding specified by Parameter 144.
Without this rounding, ‘eq’ would usually return “false‘’ when comparing two numbers calculated in different ways.
Comparison operators and logical operators (‘!’, ‘&&’, ‘||’) return 1.0 for “true” and 0.0 for “false”.

Example:
G91 X [13/64] Z [1+3/8] ; Move the X axis 13/64 (0.2031) units and the Z axis 1 3/8 (1.375) units incrementally
X[ SQRT [ABS[SIN [#101] - COS [#102]]]] ; Move X as a function of #101 and #102

Uwe


Gerral
Posts: 26
Joined: Fri Nov 22, 2024 4:25 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: B4107B77A373-0905248481
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Hello Pythagoras

Post by Gerral »

I love features! So does Microsoft :lol:


cncsnw
Posts: 4266
Joined: Wed Mar 24, 2010 5:48 pm

Re: Hello Pythagoras

Post by cncsnw »

I think a better feature would be to give the "#" operator higher precedence than the "^" operator, but that is just my opinion.


suntravel
Posts: 3086
Joined: Thu Sep 23, 2021 3:49 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 6433DB0446C1-08115074
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Germany

Re: Hello Pythagoras

Post by suntravel »

cncsnw wrote: Wed Jan 08, 2025 12:07 pm I think a better feature would be to give the "#" operator higher precedence than the "^" operator, but that is just my opinion.
Yes, this would save some typing...

Uwe


Gerral
Posts: 26
Joined: Fri Nov 22, 2024 4:25 pm
Acorn CNC Controller: Yes
Plasma CNC Controller: No
AcornSix CNC Controller: No
Allin1DC CNC Controller: No
Hickory CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: B4107B77A373-0905248481
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Hello Pythagoras

Post by Gerral »

It would make it behave like other GCode interpreters as well as all other languages too.


Post Reply