Introduction This application note describes the procedures used for a simple automatic tool changer. In this ATC, the tools are loaded in a horizontal turret, and are taken directly from there, with Z-axis motion. This type of ATC can be found on Fadal and Haas vertical milling machines. The actuators are electric motors. The turret counting is done with a single sensor (not A-B encoder). The turret is driven by Geneva mechanisms, which moves the turret intermittently between the stations. The turret has no home position so it is up to the operator to decide which station is number one. M6 Sequence When a program needs to change a tool M6 is called with the desired tool number. G0 x... y... z... m6 t2 XYZ is a convenient position relative to the work piece. M6 sequence is as follows: If no new tool is programmed then exit Cancel dynamic offset Spindle stop and low gear for oriented stop Prepare oriented stop in the background Change to machine coordinate (g-53) Move to Z-zero (tool change position) Tool change sequence Error handling If necessary, wait for manual tool change or CS. Update tool table Tool Change Sequence The tool change sequence is as follows: M19 Oriented stop (repeat check) M80 Turret slide in (tool return) M81 Tool unclamp M82 Z-up to clear the tool M83 Turret turn to new tool M84 Z-down to pick up the tool M85 Tool Clamp M86 Turret slide out To save time, oriented stop is executed in the background while Z moves to zero. This isn't a big saving on these machines since Z has a short distance to go and the gear should be in Low for oriented stop. When Z reaches zero, oriented stop is tested, and completed if necessary, in the foreground. Before the sequence begins all of its operations are displayed on the screen in blue on white. While it runs the current step flashes with white on blue. If it ends successfully it turns to white on blue, otherwise it flashes white on red. The tool changing routine is written as a sequence of m-functions, which let the operator run them one by one from MDI. Each mf performs one operation, checks its completion, sets the error conditions, and returns. The automatic sequencer also uses these m-functions but it checks the error conditions before advancing to the next step. In case of error (missing completion signal) the sequencer stops and lets the operator continue manually. The operator then can backup the failed operation(s) and try again. At any moment the automatic sequence can be resumed by pressing CS. The operator can backup all the way up or proceed down the sequence by the up/down arrow-keys. If the beginning or the end of the sequence is reached manually, a Manual tool change option lets the tool be changed manually. In that case the program waits until CS is pressed, then completes the m6 cycle. Cnx parameters: #170 sequencer #180 stop automatic sequence #190 completion ok #103 last key (to detect up-arrow code 1072) #169 current tool in turret #199 new tool Plc regiters: #135 turret stop timer #293 current tool in spindle #186, #187 oriented stop, Plc sequence Design steps Write simulations to all steps. List outputs and inputs If possible, check the machine that all steps work in I/O test Write M-function for each step and test it. Write the whole sequence. Test with various conditions, simulate errors Write operating instructions I/O List This I/O list is in use on all Fadal machines installed before Mar-19-1999. Because of unreliable sensors, on some machines there is more code to ensure that operations were completed successfully (particularly Turret slide out). OUTPUT INPUT Turret slide: Direction: out 6,$20 On 5,$08 Pos out 5,$08 Pos in (Rest) 5,$10 Tool unclamp 5,$01 Unclamped 6,$08 Collision Check while Z moves 5,$40 Turret ccw 6,$04 On 5,$04 Count 5,$20 Oriented stop 5,$02 Stopped 6,$02 M80 cycles \for m80 to m89 ---- caller should check #190<>0 [80] Turret slide out out(6,$20,on) delay(.1) out(5,$8,on) delay(1.2) skip(5,$8,on) delay(4) out(5,$8,off) out(6,$20,off) Mend [81] tool unclamp out(5,$1,on) skip(6,$8,on) delay(6) delay(.6) Mend [82] tool release g-53 g1 z101.6 f8000 skip(5,$40,on) \tool release if getplc(59)==6 then g53 endif \if in MDI g #190=not #190 Mend [83] Turret CW/CCW \#199= tool number if getplc(59)==6 then #199=T endif \if in MDI use T #169=getplc(293) \use #169 for current tool if #199==#169 or #199==0 or #199>21 then Mend endif if getplc(23)<101 and iport(5)&$10==0 then putstr('Could not turn Turret') gosub 19900 endif if (#199-#169)%21<=10 then \21 tools #104=0 #105=off \CW else #104=-2 #105=on \CCW endif if oport(6)&$4==4 xor #105 then \if direction change out(6,4,#105) skip(135,0,all) delay(1) \Wait for turret stop delay(0.05) endif out(5,$4,on) #102=$20 openwindow(30,14,50,18,white,red) title 'Turret' cursor($2000) format(3,0) locate(1,3) pr 'Target ',#199; locate(3,3) pr 'Current',#169; repeat \wait for positive going count if (#101=iport(5)&$20)>#102 then #169=(#169+#104)%21+1 endif locate(3,3) pr 'Current',#169; #102=#101 delay(.01) until #169==#199 out(5,$4,off) delay(.5) closewindow Mend [84] tool pickup g-53 g1 z f8000 skip(5,$40,on) \tool pickup if getplc(59)==6 then g53 endif g #190=not #190 mend [85] tool clamp out(5,$1,off) skip(6,$8 ,off) delay(1) delay(.6) Mend [86] Turret slide home out(6,$20,off) delay(.1) out(5,$8,on) delay(1.2) skip(5,$10,on) delay(4) out(5,$8,off) Mend CNX program [6] Tool Change #199=T \#199 holds new tool if #199==0 or #199==getplc(293) or getplc(63)&2<>0 then g40 t#199 \set tool-length comp Mend end \no new tool or test mode \***************************************\Ready to start gosub 19100 \Check power-on mf(50) \clear dynamic offset mf(45) mf(41) \low gear, coolant off putplc(186,8) \begin background oriented spindle stop #111=x #112=y \Save current XY g-53 \machine coordinates g z \change-tool position Z=0 openwindow(15,7,65,18,blue,7) title 'M6 Tool Change' format(2,0) cursor($2000) print ' 1. Wait for Spindle stop' print ' 2. M80 Turret in' print ' 3. M81 Tool unclamp' print ' 4. M82 Tool release' print ' 5. M83 Wait for Tool #',#199 print ' 6. M84 Tool pickup' print ' 7. M85 Tool clamp' print ' 8. M86 Turret out' print ' 9. Manual tool change' print '10. Done'; #103=0 \holds the last key if #170>0 then #170-=1 endif \#170 is the sequencer for #100=1 to #170 bar(#100,white,blue) next #100 \if we are in the middle gosub 695 \start sequence repeat \do it if not getplc(57) then #180=1 endif \stop on feed=0 subtitle str$(#170) \current sequence if #103<>1072 then \if forward on #170 gosub 601,602,603,604,605,606,607,608,609 else \if backward on #170 gosub 696,608,607,606,605,604,603,602,609 endif until #170>9 \end of sequence \***************************************\Update tool table open r,#10,cpldir$+'tool.002',48 segofs @(101) seek#10 getplc(293) \old tool gets its previous pocket get#10 @(101) poke(19,getplc(293)) seek#10 getplc(293) put#10 @(101) seek#10 #199 \new tool gets pocket #0 get#10 @(101) poke(19,0) seek#10 #199 put#10 @(101) close #10 closewindow \success #180=#170=0 \no errors putplc(293,#199) \update new tool g40 t#199 g53 \Resume offset g \x#111 y#112 \Resume XY format(10,4) locate(13,66) pr 'TL',tl; locate(0,0) Mend \M6 End \M6 ************ subroutines *********\ n601 skip(187,0,~all) delay(6) \Check PLC done, oriented stop if #190 then skip(6,2,on) delay(1) endif if not #190 then putplc(186,0) putplc(176,0) endif goto 690 n602 mf(80) goto 690 \turret in n603 mf(81) goto 690 \tool unclamp n604 mf(82) goto 690 \tool release n605 mf(83) goto 690 \turret to new tool n606 mf(84) goto 690 \tool pickup n607 mf(85) goto 690 \tool clamp n608 mf(86) putplc(186,0) goto 690 \turret out, cancel oriented stop n609 if #180 then \manual tool change subtitle 'Change tool to #'+str$(#199)+', press CS when done' repeat if getplc(89)==27 then \tool unclamp/clamp PB out(5,1,toggle) putplc(89,0) endif until inkey==1112 \CS #180=0 #190=1 \no errors endif \fall thru to 690 \Subroutine, operation completed n690 if #190 then \if no error if #103<>1072 then bar(#170,white,blue) \Fwd Done else bar(#170,blue,7) \Backup done endif else \error if #103<>1072 then bar(#170,white,lightred)\Fwd error else bar(#170,red,white) \Backup endif #180=1 \error flag endif if #180 then \if error while inkey wend if #103==1072 then #170-=1 endif \if Up backup counter repeat \wait for Up/Dn/Cs until (#103=readkey)==1072 or #103==1080 or #103==1112 if #103==1112 then #180=0 endif \CS, cancel error flag if #103==1072 then \Backup if #170>=2 then bar(#170,blue,white) return \flash - in backup else bar(1,blue,7) #170=8 #180=1 endif \goto manual tool change endif endif \end error n695 #170+=1 \next op bar(#170,white,lightblue) \flash - in process n696 return \***********************************************\M6 End PLC program [1] PLC interrupt \turret stop timer, used in m83 when change direction if #105&4<>0 then #135=20 endif if #135>0 then #135-=1 endif \Stop Turret if not in m83 if #29<>83 then #105&=~$4 endif \Stop Slide at both ends if #105&$8<>0 then \if slide on if #5&$08<>0 and #106&$20<>0 then #105&=~$8 endif \slide in if #5&$10<>0 and #106&$20==0 then #105&=~$8 endif \slide home endif \***************************************\ \ [M6 ATC] \ background oriented spindle stop \ to begin #186=n --> n/18 sec \ stopped #187<>0 \ to end #186=0 \***************************************\ if #186==#187 then if #186==0 then #105&=~$2 endif \cancel oriented stop else if #187>#186 then \if not time up #105&=~$2 \cancel oriented stop #187-=1 \oriented stop timer count down else \oriented stop begin #172=0 \M5 #176=25*(#171)/1000 \25 RPM - LOW gear if #175==#176 then \stable RPM #105|=$2 \oriented stop if #6&$2<>0 then #176=0 #175=-1 \RPM=0 putiop(13,0) \immediate stop #187=#186 \flag done endif endif endif endif