How does the G-code Interpreter interpret?[SOLVED]

More
14 Jan 2014 11:56 - 17 Jan 2014 05:22 #42744 by clunc
When I try to load--not run--a G-code program with this line:

#2002=ACOS[#2000/[2.0*#1002]]

Axis complains with the error message:

"Argument for acos out of range"

I've added a DEBUG statement and M2 just before the ACOS line, and determined that the program will then load, and running it provides a valid value for the argument (-1<= arg <=+1).

It is probably worth noting that the params from which the arg is calculated are the result of probing.

I'll try to do it with an ASIN or ATAN (with its wacky 2-argument syntax) if clarity isn't forthcoming with the ACOS.

I'm just very surprised that the compiler/interpreter is complaining about the argument even before the program runs so it can find out what it is!

Thanks for any insights.
clunc
Last edit: 17 Jan 2014 05:22 by clunc.

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 12:37 #42745 by Todd Zuercher
Maybe you need to preload your variables with dummy values (that would be valid in your acos expression) that will then be over written once the probing occurs.
The following user(s) said Thank You: clunc

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 21:18 - 14 Jan 2014 21:55 #42764 by clunc
Todd,

In fact, I had set all vars to -9999 before I ever use them (so I can tell when they've been set later, and to increase the likelihood that any crash will be Spec-Tacular...).

...AND, now you cause me to think of it--I just wonder what those dummy values mean if, in fact, they are being plugged in on loading.

Thanks, it's something to check. All I could think of was "changing the font in the editor" because it seemed to make about as much (non)sense as anything else.

EDIT:
A first glance, just plugging in the large -9999 dummy values, suggested it might be the cause ACOS[BIGNUM/smallnum] = ACOS[ something >>1].

However, a closer look indicated that all the variables had been changed from their dummy values, by expressions, to values which would not have resulted in an out-of-range argument; which would mean that #PARAM=number is being interpreted by the loader, while #PARAM=[num/num] is not.

Q. Could someone explain what program evaluation, if any, takes place on loading a program?
--
clunc
Last edit: 14 Jan 2014 21:55 by clunc. Reason: add some observations and a question

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 22:00 - 14 Jan 2014 22:01 #42765 by ArcEye
Todd Zuercher wrote:

Maybe you need to preload your variables with dummy values (that would be valid in your acos expression) that will then be over written once the probing occurs.


Todd is exactly right.

The problem is that Axis does not just 'load' a file, it goes through the interpreter as if it was running and the plot is rendered etc.

If you do assignments without any conditional tests that the values in the params are within range, you will get an error, even if those values would be filled in later.

Filling the params used with valid numbers is one way to get over it, but runs the risk of your being unable to differentiate between a return from probing and the default you initialised to

Might be better to test the values and output a warning for out of range values, without halting the program by trying to make the assignment

regards

EDIT I posted as you did but hopefully covers it
Last edit: 14 Jan 2014 22:01 by ArcEye.
The following user(s) said Thank You: clunc

Please Log in or Create an account to join the conversation.

More
14 Jan 2014 22:09 #42766 by clunc
Changing subject line to broaden the question.

Q. Could someone explain what program evaluation, if any, takes place on loading a program?


The program is executed by the "Interpreter" to which there are few operational clues in the G-code and INI file references.

Please Log in or Create an account to join the conversation.

More
15 Jan 2014 01:07 #42775 by andypugh

Q. Could someone explain what program evaluation, if any, takes place on loading a program?


The graphical preview is generated by running a partial copy of the full interpreter (actually completely separate code).

If you are using the Axis GUI then you can just skip preview of troublesome lines. See section 11.7
www.linuxcnc.org/docs/html/gui/axis.html#_axis_preview_control
This probably also works for anything else which uses the same preview widget.
The following user(s) said Thank You: clunc

Please Log in or Create an account to join the conversation.

More
15 Jan 2014 23:55 - 15 Jan 2014 23:57 #42834 by clunc
@Todd Zuercher, @ArcEye, @andypugh

Thank you all. The mist has lifted from my eyes. Following Andy's link, I now put an (AXIS, stop) comment--I interpet that to mean "stop helping" :^)--on the line immediately before the ACOS and the script was read in just fine.

(Just discovered Named Parameters #<localvar>, #<_globalvar>, so I'm doing a complete rewrite, again. "You can always tell a programmer; but you cain't tell him much...")

Big Thanks!
--
clunc
Last edit: 15 Jan 2014 23:57 by clunc. Reason: fix chars which are apparently being interpreted

Please Log in or Create an account to join the conversation.

Time to create page: 0.090 seconds
Powered by Kunena Forum