Page 1 of 1

macro to write point to file in cnc12 with Acorn

Posted: Mon Jul 31, 2023 3:29 pm
by Timothy Clement
Hello all,
I want to use a laser mounted in the non-rotating spindle as a pointer for digitizing where a probe cannot do the job (with my Acorn controlled mill). I move the spindle to the point with jogging and want to write the point to a file, move to the next point and write to file, etc. I have tried using the macro "probe_write_point_to_file.cnc" that is included with CNC12 v5.04but without success.
Does anyone have an example of a successful macro implementation of writing a point to a file?
Thanks
Tim

Re: macro to write point to file in cnc12 with Acorn

Posted: Mon Jul 31, 2023 5:14 pm
by centroid467
probe_write_point_to_file.cnc is only used for internal probing routines and requires some extra setup if you were going to call it yourself.

You should probably write your own for this one. The macro should be pretty simple: open/create the file in append mode with M121 and write positions to it with M122. If you need formatting other than M122 provides then you can access the position variables (X is #26101, Y is #26102, etc) and print them to the file with M123 or M223 calls. You'll have to change the filename in the macro every time you do a different job if you go this simple route.

Something like this:

Code: Select all

M121 "my_file_name.cnc"	; Create or open file
M122 ; This comment will be written to the file
or this:

Code: Select all

M121 "my_file_name.cnc"	; Create or open file
M223 "X distance: %9.6f Y distance: %9.6f Z height: %9.6f" #26101 #26102 #26103
should do what you want.

Re: macro to write point to file in cnc12 with Acorn

Posted: Mon Jul 31, 2023 8:07 pm
by Timothy Clement
Thanks for the reply centroid467. That was just the information I needed to get a macro working properly.

Tim

Re: macro to write point to file in cnc12 with Acorn

Posted: Tue Aug 01, 2023 10:17 am
by centroid467
No problem, happy to help!