跳到主要內容

四軸銑削(二)

文章日期:2008-03-22 17:30







三軸連動銑削加工(X+Y+A)

在工件為圓柱的前題下要用圓柱表面上,使用直徑較小的銑刀(以直徑20mm為例),銑出較大圓溝(溝寬64mm),基本上只要兩軸連動及G41G42補正就可以,不過,如果要用較小直徑20mm銑刀銑出較大圓溝直徑64mm,並要求此圓溝的溝壁如同64mm銑刀銑出的效果就得以三軸連動(X+Y+A)的方式來加工才行

三軸連動加工要訣是先找出圓溝的每一處外形是以直徑64mm銑刀圓周邊的哪一個部位所銑出來的,然後透過移動XY軸的方法,將直徑20mm銑刀圓周邊移到該位置,如下圖所示,並將A軸如同二軸連動那樣旋轉,即可用直徑20mm銑刀銑出像直徑64mm銑刀所銑出的圓溝。

 
 



用AutoLisp模擬較小的銑刀來銑出像直徑64mm銑刀所銑出的圓溝,並輸出CNC程式:
(defun c:kk() ;;for variable diameter of r1
  (setq r1 10.0 xc 0.0 yc 0.0 d 0.0)
  (setq r1 (/ (getreal "Enter the dia of finishing milling : ") 2))
  (setq r0 32.0  x1 0.0 y1 0.0  x2 0.0 y2 0.0  z2 0.0  xp 0.0 yp 0.0 zp 0.0 )
  (setq xp 121.205 yp 0  zp 110.)
  (setq file01 (open "C://test.nc" "w"))
  (princ "%\n" file01)
  (princ "O0005\n" file01)
  (princ "G0X121.205 Y0. Z110. A0. F600\n" file01)
  (princ "S800 M03\n" file01)
  (princ "M08  F70\n" file01)
  (setq x2 121.205   y2 0.0  z2 75.0 ctype 1)
  (princ "G1 " file01)
  (pp1)
  (setq y2 (- r0 r1) )
  (princ "  " file01)
  (pp1)
  (setq x2 90.)
  (princ "  " file01)
  (pp1)
  (setq y2 (* -1 y2)  ctype 3 ppr (- r0 r1) )
  (princ "G3 " file01)
  (pp1)

  (setq x2 121.205  ctype 1)
  (princ "G1 " file01)
  (pp1)
  (setq radChg (/ 180.0 3.1415926) angChg (/ 3.1415926 180.0))
  (setq cosCta (cos angChg) sinCta (sin angChg))
  (setq iniCta 0.0  cta0 0.0  cta1 0.0  ctaTatal 0.0  iniAxial 0.0 wkAxial 0.0)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  (setq xp 121.2051 yp -32  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 i1 1   x1wk (- xp xc)  y1wk (- yp yc))
  (setq x2mem x2  y2mem y2  a2 0.0)
  (while (< i1 ctaTatal)
    (setq x2wk (+ (* x1wk cosCta) (* y1wk sinCta) ))
    (setq y2wk (- (* y1wk cosCta) (* x1wk sinCta) ))
    (setq ycc (+ yc (* (+ r0 ppr) (/ y2wk ppr))) )
    (setq x2 (+ xc (* (+ r1 ppr) (/ x2wk ppr))) )
    (setq y2 (+ yc (* (+ r1 ppr) (/ y2wk ppr))) )
    (if (= i1 1)
       (princ "G1 " file01)
       (princ "   " file01) )
    (setq y2 (- y2 ycc) a2 (* 360 (/  ycc pillarDia)) )
    (ppAxial)
    (setq i1 (+ i1 1) x1wk x2wk y1wk y2wk) )

;;;;;;;;;the last endpoint of Arc
  (setq ycc (+ yc (* (+ 32 ppr) (/ (- y2mem yc) ppr))) )
  (setq x2 (+ xc (* (+ r1 ppr) (/ (- x2mem xc) ppr))) )
  (setq y2 (- (+ yc (* (+ r1 ppr) (/ (- y2mem yc) ppr))) ycc) )
  (setq a2  (* 360 (/  ycc pillarDia)) )
  (ppAxial)

;;;;;;;;; ;for slant line
  (setq mem y2   x2 254.4931  y2 -184.3234)
  (setq d12 (sqrt (+ (* (- x2 x2mem)(- x2 x2mem)) (* (- y2 y2mem)(- y2 y2mem)) )))
  (setq x3 (- x2 (* r1 (/ (- y2 y2mem) d12) )))
  (setq y3 (+ y2 (* r0 (/ (- x2 x2mem) d12) )))
  (setq x2 x3  y2 mem)
  (setq a2 (* 360 (/ y3  pillarDia)))
  (ppAxial)

;;;;;;;;;; milling a hole
  (setq x2 254.4931  y2 -184.3234 ctype 3 ppr (- r0 r1))
  (setq x3 (- x2 (* (- (+ r0 r0) r1) (/ (- y2 y2mem) d12) )))
  (setq y2 (abs mem) x2 x3)
  (princ "G3 " file01)
  (pp1)
;;;;;;;;;;;;revering
;;;;;;;;;;;;obtain arc data
  (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)
;;;;;;;;; ;for revering slant line
  (setq x2 (+ xc (* (- ppr r1) (/ (- xp xc) ppr))) )
  (setq y2 (abs mem) a2 (* 360 (/ ycc pillarDia)))
  (ppAxial)
;;;;;;;;;;milling revering arc
  (setq x2 121.205  y2 r0  xp 200.9143   yp -7.6142)
  (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 (* (- ppr r0) (/ y2wk ppr))) )
    (setq x2  (+ xc (* (- ppr r1) (/ x2wk ppr))) )
    (setq y2  (* (- r0 r1) (/ y2wk ppr)) )
    (if (= i1 1)
       (princ "G1 " file01)
       (princ "   " file01) )
    (setq a2 (* 360 (/  ycc pillarDia)) )
    (ppAxial)
    (setq i1 (+ i1 1) x1wk x2wk y1wk y2wk) )

;;;;;;;;;the last endpoint of Arc
  (setq ycc (+ yc (* (- ppr r0) (/ (- y2mem yc) ppr))) )
  (setq y2  (* (- r0 r1) (/ (- y2mem yc) ppr)) )
  (setq x2 x2mem  a2  (* 360 (/  ycc pillarDia)) )
  (ppAxial)
  (princ "G0 Z150.\n" file01)           ;raising tool
  (princ "M99\n" file01)
  (princ "%\n" file01)
  (close file01)
  (setvar "osmode" 1)
)
;;;;;;;;;;;;;;;;;;;;;;;以下是子程式;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(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 ppAxial()
  (setq pxs(rtos x2 2 3) pys(rtos y2 2 3) pzs(rtos a2 2 3))
  (setq pxl(strlen pxs) pyl(strlen pys) pzl(strlen pzs))
  (setq pxn(- 7 pxl) pyn(- 7 pyl) pzn(- 7 pzl))
  (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))
  (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 " A" file01)  (princ pzs file01)
  (if ( or (< (abs (- (fix a2) a2)) 0.001) (< (- 1 (abs (- (fix a2) a2))) 0.001) ) (princ "." file01) )
  (princ "\n" file01)
)


(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)))  )))
  (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) )))))
)
請看續文
http://tw.myblog.yahoo.com/cu01joe/article?mid=807&prev=1615&next=795&l=f&fid=5

留言