Optimizing ATC code for direction

All things related to the Centroid Acorn CNC Controller

Moderator: cnckeith

Post Reply
Obsidian
Posts: 48
Joined: Tue Dec 03, 2019 10:40 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 780473A92571-0930192501
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Optimizing ATC code for direction

Post 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
Allin1Chris
Posts: 132
Joined: Wed Jul 31, 2019 12:53 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: Yes
Oak CNC controller: Yes
CNC Control System Serial Number: none
DC3IOB: Yes
CNC12: Yes
CNC11: Yes
CPU10 or CPU7: Yes

Re: Optimizing ATC code for direction

Post 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
When requesting support READ THIS POST first. http://centroidcncforum.com/viewtopic.php?f=60&t=1043

Please ALWAYS post a FRESH report. To make a report: https://www.youtube.com/watch?v=Ecvg0VJp1oQ.

(We pride ourselves on providing timely solid technical support but, without good information we may not be able to help and/or reply until such information is posted.)

Centroid PLC Tutorial Videos
Obsidian
Posts: 48
Joined: Tue Dec 03, 2019 10:40 pm
Acorn CNC Controller: Yes
Allin1DC CNC Controller: No
Oak CNC controller: No
CNC Control System Serial Number: 780473A92571-0930192501
DC3IOB: No
CNC12: Yes
CNC11: No
CPU10 or CPU7: No

Re: Optimizing ATC code for direction

Post by Obsidian »

That's exactly what it needed thank you!
Post Reply