Page 4 of 9

Re: ATC Macro / PLC Help please

Posted: Thu Feb 22, 2018 5:04 pm
by Threedj16
Thanks again. You and this forum have been a great resource.

Now to just get my lathe here and buy my Acorn..... ;)

Re: ATC Macro / PLC Help please

Posted: Sun Mar 04, 2018 11:37 am
by Chaz
After being fairly ill for a few weeks and sub zero temps, Ive tried again. No joy, it doesnt seem to follow the correct logic. Ive packed up so cant access the PC now but will paste the code I am try and all the report bits.

Re: ATC Macro / PLC Help please

Posted: Sun Mar 04, 2018 11:38 am
by Chaz
I would love to be able to run this on my home PC and get the code working. But without a board, it cant be done :-( One of the few advantage Mach 3 seems to have.

Re: ATC Macro / PLC Help please

Posted: Sun Mar 04, 2018 11:41 am
by Chaz
Can I also just check.

This comment.

; Notes: Turns/rev must be configured 1 = 1 turret position change

I take it this assumes that moving from A1 to A2 is one tool step move? So T08 = A08, it doesnt matter how I get this to work as long as I use the correct parameters in the motor setup and get the ratio working?

Re: ATC Macro / PLC Help please

Posted: Tue Mar 06, 2018 7:51 am
by diycncscott
Yes that is correct. If you command A1 it goes to turret position 1, A2 = 2 etc..

Yes, you can often "crowbar" the steps/rev and revs/unit back and forth and achieve the similar positioning results but I would strongly suggest setting the steps per/rev to what your drive is configured to (and can handle). Then adjust only revs/unit (or units/rev if metric) as needed.

Also, for positioning a turret, you will want to set A as a linear axis in the Wizard.

Re: ATC Macro / PLC Help please

Posted: Thu Mar 08, 2018 8:49 am
by Chaz
diycncscott wrote: Tue Mar 06, 2018 7:51 am Yes that is correct. If you command A1 it goes to turret position 1, A2 = 2 etc..

Yes, you can often "crowbar" the steps/rev and revs/unit back and forth and achieve the similar positioning results but I would strongly suggest setting the steps per/rev to what your drive is configured to (and can handle). Then adjust only revs/unit (or units/rev if metric) as needed.

Also, for positioning a turret, you will want to set A as a linear axis in the Wizard.
Thanks. I dont think mine is set up as Linear, I wonder if that is causing problems. Will try again this weekend.

Re: ATC Macro / PLC Help please

Posted: Sat Mar 10, 2018 1:23 pm
by Chaz
Finally working. I swapped my numbers to increment to make it easier but it wasnt that.

Its the format of the IF THEN ELSE statement. So simple in the end. Ill copy / paste it later, hopefully it can help someone else.

Re: ATC Macro / PLC Help please

Posted: Sat Mar 10, 2018 3:17 pm
by Chaz
Working Macro.


;------------------------------------------------------------------------------
; 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 3rd axis, positions are in machine position.
; Requires: Machine home must be set prior to use.
;
;#100 = 8 ;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-#5023] < .002] THEN GOTO 1000

; Notes: Turns/rev must be configured 1 = 1 turret position change
; Turret is on 3rd 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 #5023 > #4120 THEN #101 = [8 + #4120] ELSE #101 = #4120

G53 A[#101 + 0.5]
G53 A[#101 - 0.5]

M26 /A L[#4120*#20603]

N1000 ;Macro finished

Re: ATC Macro / PLC Help please

Posted: Sat Mar 10, 2018 3:18 pm
by Chaz
The +0.5 and -0.5 on the G53 movements is to get past a pawl and then lock against it by reversing.

Re: ATC Macro / PLC Help please

Posted: Tue Mar 13, 2018 7:50 am
by diycncscott
Good job. To prevent unexpected behavior, you should place:

IF #50001

The line before any line that assigns a value to a variable to prevent look-ahead from assigning the value prematurely.
It doesn't do anything except stop parsing beyond the IF #50001 line until the program is actually at that line.