Passing more than two parameters to an M1nn code?

More
18 Jan 2023 16:43 #262352 by clunc
I've written a script that computes and stores start/stop/elapsed time into a log file.

I call it with M144 P<number> Q<flag> where <number> is a model number and <flag> is 1|0 indicating start or stop mode.

I open the log file after the run and record the times in the head of the G-code program (and sometimes in the name of the file itself to give an idea of what to expect from future runs).

I also include a computation for "tool mileage" in every G-code, and would like to include that in the .log file (and ultimately the program) too, but (and I think I just thought of a way around it[1]) M1nn calls limit the #parameters passed to 2.

Q. Can an M1nn access variables from the G-code that called it? (Guessing no--and maybe even H*L NO!)

[1] Because the second parameter is either 1 or 0, it might be possible to pass the mileage as the 2nd parameter with the flag embedded in it in a less-signficant decimal place.  However I'd like to hear of cleverer ideas.

Thank you.
The following user(s) said Thank You: Lcvette

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

More
19 Jan 2023 16:39 #262426 by clunc
I could also call "M144" in a similar way to how M1nn codes are defined: the range M100-M199 implies user-M-code.

My tools already carry a similar designation: '1' is a square endmill, '2' a roundnose, etc.; e.g., 10500 designates a 0.500" rougher, '20039' a 1mm round nose.

I could add a 'range integer' to a number before passing as a parameter and detect and subtract the same number in M144 to have it, which must now be more sophisticated, access more parameters; e.g.,
P100000000.9876 could indicate "tool mileage" (100000000), 0.9876 miles,
P200567890, line number 567890 (if that's exposed to a post)
P300000000, log current time, etc.

Q offers similar extra passing options.
The following user(s) said Thank You: Lcvette

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

More
20 Jan 2023 13:12 #262485 by andypugh
I was going to suggest something similar to what you have come up with. If the value of each parameter is bounded then you basically have to fit them into the 14 decimal digits that a double-precision float can represent.

Possibly 1000,000 * P1 + 1000 * P2 + P3

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

More
20 Jan 2023 14:26 #262495 by clunc
Just so. Thanks, Andy. (On that other topic , I'm still investigating how Dell shipped OptiPlex 780s with respect to audio out, but your short py code turned on a light: esp. os.system(). )

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

Time to create page: 0.090 seconds
Powered by Kunena Forum