Can someone help me understand this line in the bold code below? I didn't write the code, but I believe "8" should actually be #100
;------------------------------------------------------------------------------
; Filename: cnctch.mac
; Description: Axis driven tool change macro for Lathe
; Notes: Turns/rev must be configured 1 = 1 turret position change
; Turret is on 4th axis, positions are in machine position.
; Requires: Machine home must be set prior to use.
;
;#100 = Number turret positions
;#101 = Calculated position to move to when requested position < current position.
;#4120 = requested tool
;#20601-#20604 = Counts per unit for axes1-4
;#5021-#5024 is the current machine position for axes 1(#5021) through 4(#5024)
;------------------------------------------------------------------------------
;follow with a block that skips if graphing or searching
IF #50001 ;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 ;Skip macro if graphing or searching
;If not searching or graphing, check to make sure the turret is not already
;at the requested position. If it is, skip the macro
IF [ABS[#4120-#5024] < .002] THEN GOTO 1000
; Notes: Turns/rev must be configured 1 = 1 turret position change
; Turret is on 4th axis, positions are in machine position.
; Requires: Machine home must be set prior to use.
;
;#101 = ;Calculated position to move to when requested position < current position
;#20601-#20604 = Counts per unit for axes1-4
;#5021-#5024 is the current machine position for axes 1(#5021) through 4(#5024)
;#4120 = requested turret position from g code
IF #5024 > #4120 THEN #101 = [8 + #4120] ELSE #101 = #4120
G53 A[#101] ;originally was +.5
;G4 P1 ; added pause 1 second
;G53 A[#101 - .005] ;removed -.5
M26 /A L[#4120*#20604]
N1000 ;Macro finished
Lathe Turret/ATC macro code question
Moderator: cnckeith
-
- Posts: 595
- Joined: Tue Sep 12, 2017 10:03 pm
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: 1030090099
- DC3IOB: Yes
- CNC12: Yes
- CNC11: Yes
- CPU10 or CPU7: No
- Location: Outside Winston-Salem, NC
- Contact:
Lathe Turret/ATC macro code question
Last edited by frijoli on Sun Feb 23, 2020 10:37 am, edited 1 time in total.
Clay
near Winston-Salem, NC
unofficial ACORN fb group https://www.facebook.com/groups/897054597120437/
near Winston-Salem, NC
unofficial ACORN fb group https://www.facebook.com/groups/897054597120437/
Re: Lathe Turret/ATC macro code question
Perhaps, but only if #100 then gets assigned to have that value somewhere, either at the top of the cnctch macro, or before the macro is called. Since #100 is a general-purpose user variable, it will start every new job with a value of zero.
I would instead use variable #9161, which retrieves the current value of Machine Parameter 161, which is customarily used to store the number of available tool positions.
I would instead use variable #9161, which retrieves the current value of Machine Parameter 161, which is customarily used to store the number of available tool positions.
-
- Posts: 595
- Joined: Tue Sep 12, 2017 10:03 pm
- Acorn CNC Controller: Yes
- Allin1DC CNC Controller: No
- Oak CNC controller: No
- CNC Control System Serial Number: 1030090099
- DC3IOB: Yes
- CNC12: Yes
- CNC11: Yes
- CPU10 or CPU7: No
- Location: Outside Winston-Salem, NC
- Contact:
Re: Lathe Turret/ATC macro code question
Good point, Thanks.cncsnw wrote: ↑Sun Feb 23, 2020 2:58 am Perhaps, but only if #100 then gets assigned to have that value somewhere, either at the top of the cnctch macro, or before the macro is called. Since #100 is a general-purpose user variable, it will start every new job with a value of zero.
I would instead use variable #9161, which retrieves the current value of Machine Parameter 161, which is customarily used to store the number of available tool positions.
This was a macro written by Centroid for an axis driven turret changer. Fortunately I have 8 positions which is why it was indexing correctly.
Clay
near Winston-Salem, NC
unofficial ACORN fb group https://www.facebook.com/groups/897054597120437/
near Winston-Salem, NC
unofficial ACORN fb group https://www.facebook.com/groups/897054597120437/