跳到主要內容

四軸銑削(三)

文章日期:2008-03-26 09:35



四軸連動(X+Y+ Z+A)
想要在圓筒上的圓溝周邊稜線加以倒角,以去除毛邊,這就需四軸連動(X軸+Y+ Z+A),才能達成的加工,下圖的綠色線條是球銑刀倒角時的刀具路徑,由於CNC程式是控制球銑刀的中心最低點,所以倒角的刀具路徑看起來是在圓溝周邊稜線的上方內側。


四軸連動倒角刀具路徑的計算
如前所敘,圓筒上的這個圓溝最初是以直徑64mm銑刀所銑出,待這個圓溝銑好之後,要用直徑較小的球銑刀(以直徑12mm為例),銑出這個圓溝周邊的稜線的倒角,加工要訣也是要先找出圓溝的每一處稜線是以直徑64mm銑刀圓周邊的哪一個部位所銑出來的,然後透過移動X及Y軸及Z軸的方法,將直徑較小的球銑刀的刀球圓周邊移到該位置,並以過切的手法來達到倒角的目的,如下圖所示,至於A軸則如同前述之二軸連動那樣旋轉,即可用直徑較小的球銑刀銑出圓溝周邊的稜線的倒角。





球銑刀倒角的刀具路徑側視圖


球銑刀倒角的刀具路徑端視圖



四軸連動Autolisp程式
(defun c:kk() ;;chamfering by variable diameter of r1;; including the other groove
  (setq r0 32.0 r1 10.0 xc 0.0 yc 0.0 d 0.0)
  (setq r1 (/ (getreal "Enter the dia of the ball-endmilling: ") 2))
  (setq chm (getreal "Enter the size of chamfer: "))
  (setq delr (/ r1 1.414)   xp 99.0  yp 99.0   zp 99.0)
  (setq file01 (open "C://test.nc" "w"))
  (princ "%\n" file01)
  (princ "O0005\n" file01)
  (princ "G0X121.205 Y0. Z120. A0. F600\n" file01)
  (princ "S800 M03\n" file01)
  (setq r1 (- r1 (/ chm 1.414)))
  (setq x2 121.205  y2 (- r0 r1)  z2 (+ 105.0 r1) ctype 1)
  (princ "G1 " file01)
  (pp1)

  (princ "     F70\n" file01)

  (setq x2Pre x2  y2Pre r0   z2Pre (sqrt (-  (* 105 105) (* y2Pre y2Pre))) )
  (setq y2 (- y2Pre delr)  z2 (+ z2Pre delr))
  (princ "   " file01)
  (pp1)

  (setq x2 90.0 )
  (princ "G1 " file01)
  (pp1)

;;;;;;;;;setting variables////////////////////////////////
  (setq radChg (/ 180.0 3.1415926) angChg (/ 3.1415926 180.0))
  (setq cosCta (cos (* 2 angChg)) sinCta (sin (* 2 angChg)))
  (setq iniCta 0.0  cta0 0.0  cta1 0.0  ctaTatal 0.0  iniAxial 0.0 wkAxial 0.0)

;;;;;;;;;chamfering the half circle ;;;;;;;;;;;;;;;;;;;
  (setq i1 1  xp 90.0  yp r0   x2 90.0  y2 (* -1 r0) ppr r0)
  (scir)  ;obtain xc, yc, iniCta, cta0, cta1,
  (setq x2mem x2  y2mem y2  a2 0.0 x1wk (- xp xc)  y1wk (- yp yc) )
  (while (< i1 91)
    (setq x2wk (- (* x1wk cosCta) (* y1wk sinCta) ))
    (setq y2wk (+ (* y1wk cosCta) (* x1wk sinCta) ))
    (setq y2Pre (+ yc y2wk))
    (setq x2Pre (+ xc x2wk))
    (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre))))
    (setq x2 (- x2Pre (* delr (/ (- x2Pre xc) ppr))))
    (setq y2 (- y2Pre (* delr (/ (- y2Pre yc) ppr))))
    (setq z2 (+ z2Pre delr))
    (princ "   " file01)
    (pp1)
    (setq i1 (+ i1 1)  x1wk x2wk y1wk y2wk xp x2 yp y2 zp z2) )

;;;;;;;;;chamfering a horizontal line;;;;;;;;;;;;;;;;;;;
  (setq x2 121.205 )
  (princ "   " file01)
  (pp1)

;;;;;;;;;;;chamfering arc 36 ;;;;;;;;;;;;;;;;;;;
  (setq x2mem 121.205 y2mem y2 z2mem z2 xp 121.2051 yp -32.0 zp z2  x2 149.9004 y2 -46.2611)
  (setq ctype 2 ppr 36.0)
  (scir)  ;obtain xc, yc, iniCta, cta0, cta1,
  (setq pillarDia (* 3.1415926 210) )
  (setq x2mem x2  y2mem y2  a2 0.0 )
  (setq i1 1   x1wk (- xp xc)  y1wk (- yp yc))
  (while (< i1 ctaTatal)
    (setq x2wk (+ (* x1wk cosCta) (* y1wk sinCta) ))
    (setq y2wk (- (* y1wk cosCta) (* x1wk sinCta) ))
    (setq ycc (+ yc (* (+ r0 ppr) (/ y2wk ppr))) )
    (setq xcc (+ xc (* (+ r0 ppr) (/ x2wk ppr))) )
    (setq a2 (* 360 (/  ycc pillarDia)))
    (setq y2Pre (- 0   (* r0  (/ y2wk ppr))))
    (setq x2pre (- xcc (* r0  (/ x2wk ppr))))
    (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre))))
    (setq x2 (- x2Pre (* delr (/ (- x2Pre xcc) r0))))
    (setq y2 (- y2Pre (* delr (/ (- y2Pre   0) r0))))
    (setq z2 (+ z2Pre delr))
    (princ "   " file01)
    (ppAxial4)
    (setq i1 (+ i1 2)  x1wk x2wk y1wk y2wk xxmem x2  yymem yy   zzmem  zz) )

;;;;;;;;;chamfering the last endpoint of Arc 32;;;;;;;;;;;;;;;;;;;
    (setq ycc (+ yc (* (+ r0 ppr) (/ (- -46.2611 yc) ppr))) )
    (setq xcc (+ xc (* (+ r0 ppr) (/ (- 149.9004 xc) ppr))) )
    (setq a2 (* 360 (/  ycc pillarDia)))
    (setq y2Pre (- 0   (* r0  (/ (- -46.2611 yc) ppr))))
    (setq x2pre (- xcc (* r0  (/ (- 149.9004 xc) ppr))))
    (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre))))
    (setq x2 (- x2Pre (* delr (/ (- x2Pre xcc) r0))))
    (setq y2 (- y2Pre (* delr (/ (- y2Pre   0) r0))))
    (setq z2 (+ z2Pre delr))
    (princ "   " file01)
    (ppAxial4)

;;;;;;;;;chamfering slant line ;;;;;;;;;;;;;;;;;;;
  (setq x2mem x2  y2mem y2)
  (setq xxmem x2  yymem yy   zzmem zz )
  (setq d12 (sqrt (+ (* (- 254.4931 149.9004)(- 254.4931 149.9004)) (* (- -184.3234 -46.2611)(- -184.3234 -46.2611)) )))
 (setq i1 2  xdel (/ (- 254.4931 149.9004) d12)   ydel (/ (- -184.3234  -46.2611) d12) )
  (setq x2 254.4931)
  (setq y2 -184.3234)
  (setq xcc (- x2 (* r0 ydel)))
  (setq ycc (+ y2 (* r0 xdel)))
  (setq a2 (* 360 (/  ycc pillarDia)))
  (setq x2pre (+ xcc (* ydel r0)))
  (setq y2Pre (- 0   (* xdel r0)))
    (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre))))
    (setq x2 (- x2Pre (* delr (/ (- x2Pre xcc) r0))))
    (setq y2 (- y2Pre (* delr (/ (- y2Pre   0) r0))))
    (setq z2 (+ z2Pre delr))
    (princ "   " file01)
    (ppAxial4)

;;;;;;;;;;chamfering the lower circle;;;;;;;;;;;;;;;;;;;
  (setq x2mem x2  y2mem y2Pre  xp x2Pre   yp y2Pre    ctype 3   ppr  r0)
  (setq x2 (- x2Pre (* ydel 2 r0)))
  (setq y2 (abs y2Pre))
  (scir)  ;obtain xc, yc, iniCta, cta0, cta1,
  (setq i1 2   x1wk (- xp xc)  y1wk (- yp yc) ctype 1)
  (while (< i1 181)
    (setq x2wk (- (* x1wk cosCta) (* y1wk sinCta) ))
    (setq y2wk (+ (* y1wk cosCta) (* x1wk sinCta) ))
    (setq x2Pre (+ xc x2wk) )
    (setq y2Pre (+ yc y2wk) )
    (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre)) ))
    (setq x2 (- x2Pre (* delr (/ (- x2Pre xc) r0))))
    (setq y2 (- y2Pre (* delr (/ (- y2Pre   0) r0))))
    (setq z2 (+ z2Pre delr))
    (princ "   " file01)
    (pp1)
    (setq i1 (+ i1 2) x1wk x2wk y1wk y2wk xxmem x2Pre  yymem yy   zzmem  zz) )

;;;;;;;;;;;;revering;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;chamfering the revering slant line ;;;;;;;;;;;;;;;;;;;
  (setq d12 (sqrt (+ (* (- 254.4931 149.9004)(- 254.4931 149.9004)) (* (- -184.3234 -46.2611)(- -184.3234 -46.2611)) )))
  (setq i1 2  xdel (/ (- 149.9004 254.4931) d12)   ydel (/ (-  -46.2611 -184.3234) d12) )
    (setq x2 299.8698)
    (setq y2  -110.2882)
    (setq xcc (- x2 (* r0 ydel)))
    (setq ycc (+ y2 (* r0 xdel)))
    (setq a2 (* 360 (/  ycc pillarDia)) )
    (setq x2Pre (+ xcc (* r0 ydel)))
    (setq y2Pre (- 0   (* r0 xdel)))
    (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre)) ))
    (setq x2 (- x2Pre (* delr (/ (- x2Pre xcc) r0))))
    (setq y2 (- y2Pre (* delr (/ (- y2Pre   0) r0))))
    (setq z2 (+ z2Pre delr))
    (princ "   " file01)
    (ppAxial4)

;;;;;;;;;;;;obtain the data of the revering arc 100
  (setq x2 121.205  y2 r0 )
  (setq xp 200.9143   yp -7.6142  ctype 3  ppr (+ 36. (* 2 r0)) )
  (scir)  ;obtain xc, yc, iniCta, cta0, cta1,
  (setq x2mem x2  y2mem y2  a2 0.0)

;;;;;;;;;;chamfering the revering arc 100;;;;;;;;;;;;;;;;;;;
  (setq x2 121.205  y2 r0  xp 200.9143   yp -7.6142)
  (setq i1 1   x1wk (- xp xc)  y1wk (- yp yc))
  (setq cosCta (cos (* 1 angChg)) sinCta (sin (* 1 angChg)))
  (while (< i1 ctaTatal)
    (setq x2wk (- (* x1wk cosCta) (* y1wk sinCta) ))
    (setq y2wk (+ (* y1wk cosCta) (* x1wk sinCta) ))
    (setq xcc (+ xc (* (- ppr r0) (/ x2wk ppr))) )
    (setq ycc (+ yc (* (- ppr r0) (/ y2wk ppr))) )
    (setq a2 (* 360 (/  ycc pillarDia)))
    (setq y2Pre (+ 0   (* r0  (/ y2wk ppr))))
    (setq x2pre (+ xcc (* r0  (/ x2wk ppr))))
    (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre))))
    (setq x2 (- x2Pre (* delr (/ (- x2Pre xcc) r0))))
    (setq y2 (- y2Pre (* delr (/ (- y2Pre   0) r0))))
    (setq z2 (+ z2Pre delr))
    (princ "   " file01)
    (ppAxial4)
    (setq i1 (+ i1 1) x1wk x2wk y1wk y2wk xxmem x2  yymem yy   zzmem  zz) )

  (setq xcc 121.205)
  (setq ycc 0)
  (setq a2 (* 360 (/  ycc pillarDia)))
  (setq y2Pre r0)
  (setq x2pre 121.205)
  (setq z2Pre (sqrt (- (* 105 105) (* y2Pre y2Pre))))
  (setq x2 (- x2Pre (* delr (/ (- x2Pre xcc) r0))))
  (setq y2 (- y2Pre (* delr (/ (- y2Pre   0) r0))))
  (setq z2 (+ z2Pre delr))
  (princ "   " file01)
  (ppAxial4)

  (princ "G0 Z150.\n" file01)           ;raising tool
  (princ "M99\n" file01)
  (princ "%\n" file01)
  (close file01)
  (setvar "osmode" 1)
)

;;;;;;;;;;;;;;;;;;;;;;;以下是AutoLisp之子程式;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 
(defun pp1()
  (setq pxs(rtos x2 2 3) pys(rtos y2 2 3) pzs(rtos z2 2 3))
  (setq pxl(strlen pxs) pyl(strlen pys) pzl(strlen pzs))
  (setq pxn(- 7 pxl) pyn(- 7 pyl) pzn(- 7 pzl))

  (if (> (abs (- xp x2))  0.001)
    (progn
      (princ " X" file01)   (princ pxs file01) 
      (if ( or (< (abs (- (fix x2) x2)) 0.001) (< (- 1 (abs (- (fix x2) x2))) 0.001) ) (princ "." file01) )
      (repeat pxn (princ " " file01))  ))

  (if (> (abs (- yp y2))  0.001)
    (progn
      (princ " " file01)  (princ "Y" file01)  (princ pys file01)
      (if ( or (< (abs (- (fix y2) y2)) 0.001) (< (- 1 (abs (- (fix y2) y2))) 0.001) ) (princ "." file01) )
      (repeat pyn (princ " " file01)) ))

  (if (> (abs (- zp z2)) 0.001)
    (progn
      (princ " " file01)  (princ "Z" file01)  (princ pzs file01)
      (if ( or (< (abs (- (fix z2) z2)) 0.001) (< (- 1 (abs (- (fix z2) z2))) 0.001) ) (princ "." file01) )))

  (if (> ctype 1 )
       (progn
          (float ppr)
          (princ " " file01)  (princ "R" file01)  (princ ppr file01)  ))

  (princ "\n" file01)
  (setq xp x2 yp y2  zp z2)
)

(defun ppAxial4()
  (setq pxs(rtos x2 2 3) pys(rtos y2 2 3) pzs(rtos z2 2 3) pas(rtos a2 2 3))
  (setq pxl(strlen pxs) pyl(strlen pys) pzl(strlen pzs) pal(strlen pas))
  (setq pxn(- 7 pxl) pyn(- 7 pyl) pzn(- 7 pzl) pan(- 7 pal))

  (princ " X" file01)   (princ pxs file01) 
  (if ( or (< (abs (- (fix x2) x2)) 0.001) (< (- 1 (abs (- (fix x2) x2))) 0.001) )  (princ "." file01) )
  (repeat pxn (princ " " file01)) 
  (if (> (abs (- yp y2))  0.001)
    (progn
      (princ " Y" file01)   (princ pys file01) 
      (if ( or (< (abs (- (fix y2) y2)) 0.001) (< (- 1 (abs (- (fix y2) y2))) 0.001) ) (princ "." file01) )
      (repeat pyn (princ " " file01)) ))

  (princ " Z" file01)   (princ pzs file01) 
  (if ( or (< (abs (- (fix z2) z2)) 0.001) (< (- 1 (abs (- (fix z2) z2))) 0.001) ) (princ "." file01) )
  (repeat pyn (princ " " file01))

  (princ " A" file01)  (princ pas file01)
  (if ( or (< (abs (- (fix a2) a2)) 0.001) (< (- 1 (abs (- (fix a2) a2))) 0.001) ) (princ "." file01) )
  (princ "\n" file01)
  (setq yp y2)
)

(defun scir ()
  (setq d (/ (distance (list xp yp) (list x2 y2)) 2))
  (if (> d 0)
    (progn
      (setq k1 (sqrt (- (* ppr ppr) (* d d))) )
      (if (< ctype 2.5)
           (setq xc (+ (/ (+ xp x2) 2) (/ (* k1 (- y2 yp)) d 2))
                 yc (- (/ (+ yp y2) 2) (/ (* k1 (- x2 xp)) d 2)))
           (setq xc (- (/ (+ xp x2) 2) (/ (* k1 (- y2 yp)) d 2))
                 yc (+ (/ (+ yp y2) 2) (/ (* k1 (- x2 xp)) d 2)))  )))

  (if(< k1 0.001)
    (setq ctaTatal 90.0 )
    (setq ctaTatal (* radChg (atan (/ d k1)) 2)) )

  (setq x0 xp iniCta 0.0 cta0 0.0)
  (if (< (abs (- xc xp )) 0.01)   
      (if (> yp yc)
           (setq iniCta 90.0)
           (setq iniCta 270.0) )
      (if (< (abs (- yc yp )) 0.01) 
         (if (> xp xc)
           (setq iniCta 0.0)
           (setq iniCta 180.0) )
         (progn
           (setq cta0 (* radChg (atan (abs (/ (- yp yc) (- xp xc))))))
           (if (> xp xc )
              (if (> yp yc )
                 (setq iniCta cta0)
                 (setq iniCta (- 360.0 cta0)  cta0 iniCta) )
              (if (> yp yc )
                 (setq iniCta (- 180.0 cta0)  cta0 iniCta)
                 (setq iniCta (+ 180.0 cta0)  cta0 iniCta) )))))
)

留言