Page 1 of 1

Screw Comp, The Easy Way? (Macro question)

Posted: Fri Dec 29, 2023 1:03 am
by phazertwo
I was inspired by Uwe to finally get my scales finished up so that I could run a screw comp... I have already mapped the X screw, but am unhappy with it and want to do some testing of the mapping itself (map it at different speeds/distances and what not).

I made a cable to connect the read head of the X scale to the encoder port on my Acorn, set axis 5 to M and set the turns/rev and rev/in properly. Worked flawlessly, now the "M" axis reads the "actual" position of the X axis from the read head on the scale.

Next wrote I a program that utilized M124 to wire the /X/M axis to a file... this is where things got hung up... The below program works fine, simply let it run until it hits a travel error and then change the "G0X-0.5" to "G0X0.5". The values printed out in the file line up nicely.

(G59 WCS SET TO 0,0,0 OR IN OTHER WORDS, SET TO MCS)
N100
M121 "C:\cncm\ncfiles\BL and COMP\X AXIS\x axis comp.dat"
M124 /X/M
G91
G59
G0X-0.5
M102

BUT... I want this to be more automated, for reasons. But as soon as I replace the M102 with "GOTO 100" the values in file are wrong. X is always right, but M is always zero. I've tried running the M121 and M124 as a sub program, but the results are the same... For some reason it's like the M axis data only updates at the beginning of the program...

Ideally I can use this run the comp test several times to create an average, and do some other fun things like create graphs to see trends in error. See the attached program for where I am trying to get.

Any help would be awesome!

PZ

Re: Screw Comp, The Easy Way? (Macro question)

Posted: Fri Dec 29, 2023 2:11 pm
by cncsnw
You could try using M223 instead of M124, so that you can insert CNC variable values; then use variable #23805, or a value calculated from #23805, instead of the 'M' axis position.

Re: Screw Comp, The Easy Way? (Macro question)

Posted: Fri Dec 29, 2023 11:13 pm
by phazertwo
I didn't try M223, but I did try M123 P#5025, with the same result.

I also tried to have the machine do something else with that variable before it went and grabbed it to write with the M124, the only thing I could think of was a G92 H0. However this gave me an error that didn't stop the program it that just said "no coordinates" ... For reference I switched to G58 before the G92 as to not disturb my DRO.

Not giving up yet!

PZ

Re: Screw Comp, The Easy Way? (Macro question)

Posted: Sat Dec 30, 2023 8:17 am
by tblough
It's been a while, but if I remember correctly, M123, M223 and the other prompt M-codes don't like high number variables. The work around is to assign your value to a lower number variable (in the #100 range), and then use that variable in your output statement.

I had a post on spring winding back a-ways where I had some more documentation about this issue.

Re: Screw Comp, The Easy Way? (Macro question)

Posted: Sat Dec 30, 2023 5:33 pm
by phazertwo
tblough wrote: Sat Dec 30, 2023 8:17 am It's been a while, but if I remember correctly, M123, M223 and the other prompt M-codes don't like high number variables. The work around is to assign your value to a lower number variable (in the #100 range), and then use that variable in your output statement.

I had a post on spring winding back a-ways where I had some more documentation about this issue.
I tried that... Still doesn't change.

I ended up writing the it with an M102 instead of using "GOTO" to go back to the top and it worked. Some changes were needed to the variables so they didn't re-wire each time the program re-started.

See attached.

PZ

EDIT: updated the attachment to replace M30 with M2

Re: Screw Comp, The Easy Way? (Macro question)

Posted: Sat Dec 30, 2023 9:47 pm
by cncsnw
the M102 solution is entirely reasonable.

The #502x and #504x variables are set at the beginning of the program cycle, and then are updated when (and only when) the axis makes a commanded move. Since the 'M' axis never makes a commanded move, it never gets updated.

Arguably, CNC12 should be smart enough to recognize that a manual axis could move at any time by any amount; and therefore CNC12 should read the encoder and update the position whenever the #50xx variable for such an axis is read.

Until that time, you can still get mid-cycle updates using the #2380x encoder-position variables. Those variables are updated mid-cycle for manual axes.

Re: Screw Comp, The Easy Way? (Macro question)

Posted: Mon Jan 01, 2024 6:47 pm
by phazertwo
cncsnw wrote: Sat Dec 30, 2023 9:47 pm the M102 solution is entirely reasonable.

The #502x and #504x variables are set at the beginning of the program cycle, and then are updated when (and only when) the axis makes a commanded move. Since the 'M' axis never makes a commanded move, it never gets updated.

Arguably, CNC12 should be smart enough to recognize that a manual axis could move at any time by any amount; and therefore CNC12 should read the encoder and update the position whenever the #50xx variable for such an axis is read.

Until that time, you can still get mid-cycle updates using the #2810x encoder-position variables. Those variables are updated mid-cycle for manual axes.
I do not see an #2810x encoder position variable in the manual... am I looking in the correct place?

PZ

Re: Screw Comp, The Easy Way? (Macro question)

Posted: Mon Jan 01, 2024 7:55 pm
by cncsnw
Sorry, typing too fast. The absolute-position-in-encoder-counts variables are #23801 - #23808.