Screw Comp, The Easy Way? (Macro question)

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
phazertwo
Posts: 27
Joined: Tue Dec 26, 2017 11:29 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: No
CPU10 or CPU7: No

Screw Comp, The Easy Way? (Macro question)

Post 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
Attachments
X AXIS TEST.NC
(1.66 KiB) Downloaded 28 times
report_38D2695947E0-1228170418_2023-12-28_21-43-52.zip
(727.78 KiB) Downloaded 27 times


cncsnw
Community Expert
Posts: 4584
Joined: Wed Mar 24, 2010 5:48 pm

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

Post 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.
Last edited by cncsnw on Mon Jan 01, 2024 7:57 pm, edited 1 time in total.
Reason: Corrected variable number to #2380x


phazertwo
Posts: 27
Joined: Tue Dec 26, 2017 11:29 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: No
CPU10 or CPU7: No

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

Post 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


tblough
Community Expert
Posts: 3539
Joined: Tue Mar 22, 2016 10:03 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: 100505
100327
102696
103432
7804732B977B-0624192192
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No
Location: Boston, MA
Contact:

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

Post 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.
Cheers,

Tom
Confidence is the feeling you have before you fully understand the situation.
I have CDO. It's like OCD, but the letters are where they should be.


phazertwo
Posts: 27
Joined: Tue Dec 26, 2017 11:29 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: No
CPU10 or CPU7: No

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

Post 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
Attachments
X AXIS TEST.NC
(396 Bytes) Downloaded 27 times


cncsnw
Community Expert
Posts: 4584
Joined: Wed Mar 24, 2010 5:48 pm

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

Post 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.
Last edited by cncsnw on Mon Jan 01, 2024 7:57 pm, edited 1 time in total.
Reason: Corrected variable number to #2380x


phazertwo
Posts: 27
Joined: Tue Dec 26, 2017 11:29 am
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: none
DC3IOB: No
CNC11: No
CPU10 or CPU7: No

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

Post 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


cncsnw
Community Expert
Posts: 4584
Joined: Wed Mar 24, 2010 5:48 pm

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

Post by cncsnw »

Sorry, typing too fast. The absolute-position-in-encoder-counts variables are #23801 - #23808.


Post Reply