Page 1 of 1

Optimizing ATC code for direction

Posted: Thu May 13, 2021 5:51 pm
by Obsidian
I have been using my current atc setup with great success but needed to optimize my turret code to determine which direction to turn the axis based on the requested tool number so I can cut down the tool change time. Here's code that handles this.

Code: Select all

IF (#100 < #4120) THEN M106 /A P-70015 F80 ELSE M105 /A P-70015 F80
I feel it could be optimized a little more to address tool changes between the first tool and the last. With this code you will get forward and reverse directions depending on if the requested tool is less than or greater than the current tool. The problem here is handling tool changes that go from ie tool 8 to tool 2. The shortest path here would obviously be 8..1.. 2 instead of going 8..7..6..5.. ect

Any ideas how you could handle this?


Code: Select all

;------------------------------------------------------------------------------
; Filename: cnctch.mac
; Description: Tool change request macro
; Notes: Mori Seiki SL1 Axis Based Turret
; Requires: 
; I/O:

;------------------------------------------------------------------------------
#100 = #96007


IF #50001                        		;Prevent lookahead from parsing past here
IF #4201 || #4202 THEN GOTO 1000 		;Skip macro if graphing or searching
IF (#4120 == #100) THEN GOTO 1000      	;Skip macro if already at position
N100                             		;Insert your code between N100 and N1000  


M107                                    ;Send requested Tool number to PLC Program
G4 P1                                   ;Dwell for 1 Second
M94 /11                                 ;Turn on Open Tool Turret Output
G4 P0.5                                 ;Dwell time to Open Turret Output
M101 /70016                             ;Wait for Turret Open Checking if MEM16 bit is active.
G4 P0.5                    		        ;Wait 0.5 seconds
IF (#100 < #4120) THEN M106 /A P-70015 F80 ELSE M105 /A P-70015 F80             ;Rotate Turret depending on the current tool location less than or greater than requested tool @ 80IPM unit MEM15 bit is active.
M26/A
G4 P0.5                                 ;Dwell for 0.5 seconds
;G0 A .1                                ;Optional axis move to correct turret position
G4 P0.5                                 ;Dwell for 0.5 seconds
M95 /11                                 ;Turn Off Open Tool Turret Output
G4 P1                                   ;Dwell for 0.5 seconds
M94 /12                                 ;Turn On Output to Close Turret
G4 P0.5                                 ;Wait 0.5 seconds
M95 /12                                 ;Turn off Output to Close Turret
IF #50001								;Prevent lookahead from parsing past here
#101 = #96007							;Get current turret position
G10 P1950 R[#101]						;Set parameter 950 to current turret position





N1000                            		;End of Macro

Re: Optimizing ATC code for direction

Posted: Fri May 14, 2021 2:13 pm
by Allin1Chris
Hello Obsidian,

You need to handle the rollover. So will need to add an additional Parameter 161 to the macro that we can use to determine the max tools your turret has (and can then roll over).

Then will need to do some calculations to figure out shortest path, each direction has 2 cases. The case where it does not roll over and the case that it does in both directions. You can do something similar to our Umbrella turret Roll over logic from the plc in your macro.

Try adding the following into your macro and let us know how it works out.

Code: Select all

#100 = #96007
#101 = #9161 ;Parameter 161 to #101 Max Tools in Turret

#102 = ABS[#4120 - #100] ;Calculated Distance
#103 = #101 / 2 ;HalfPoint for the Turret


IF [[#4120 > #100] && [#102 <= #103]] || [[#4120 < #100] && [#102 > #103]] THEN M106 /X P-70015 F80 ELSE M105 /X P-70015 F80

Re: Optimizing ATC code for direction

Posted: Fri May 14, 2021 3:11 pm
by Obsidian
That's exactly what it needed thank you!