現在進入主題--錐面軸向直孔的倒角,倒角之前首先得要瞭解市售的45度外倒角刀,如下圖所示。
由於軸向直孔壁與錐面兩者之間的夾角是不固定的,所以倒角帶的高度也不固定,如下圖中的C1及C2所示,C1是最淺的倒角帶高度,而C2則是最深的倒角帶高度,故使用者輸入之倒角深度hk必需大於C2才行。
倒角方法 :
原本想用省事的方法,以直孔和錐面所形成的交線為基準,然後垂直往外倒0.3C的倒角,不過,此法經仔細推敲之後,發現會造成倒角尺寸不穩定,如下圖所示,原本上圖中的C1是最淺的倒角帶高度,但經此法倒角之後反成最深的倒角帶高度。
因此,倒角的方法還是要先在上視圖的地方先畫出倒角圓,並以此倒角圓投影下來到錐面上,以求得錐面上的倒角圓曲線上的各個座標,最後再以這些座標向內及向下偏置,以求得銑刀底圓中心的座標,這樣才能得到CNC程式所需的座標點。
AutoLISP的寫法 :
(defun c:bt()
(command "color" "bylayer" "")
(setq r1 5.0 r2 15.0 h1 5.0 r3 4.0 r0 1.0 h0 3.0 c0 0.5)
(setq r1 (/ (getreal "\nEnter the top diameter : ") 2 ))
(setq r2 (/ (getreal "\nEnter the bottom diameter : ") 2 ))
(setq h1 (getreal "\nEnter the height : "))
(setq r3 (/ (getreal "\nEnter the diameter of the hole : ") 2 ))
(setq r0 (/ (getreal "\nEnter the bottom diameter of the chamfer tool : ") 2 ))
(setq h0 (abs (getreal "\nEnter the chamfering height of the chamfer tool : ")) )
(setq c0 (getreal "\nEnter the chamfering size : ") 2 )
(setq x2 0 y2 0 x22 0 y22 0 )
(setq i1 1 cta (/ 3.1415926 180.0) ctaWk 0 h1 (* -1 (abs h1)) )
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (* r1 (cos ctaWk)) y2 (* r1 (sin ctaWk )) )
(setq x22 (* r2 (cos ctaWk)) y22 (* r2 (sin ctaWk )) )
(command "line" (list x2 y2 0) (list x22 y22 h1) "" )
(setq i1 (+ 1 i1))
)
(command "zoom" "e" "")
(command "vpoint" "1,-1,1" "")
(setq delR (- r2 r1) z2 0 x1 0 y1 0 x2 0 y2 0)
(setq x11 0 y11 0 z11 0 x22 0 y22 0 z22 0)
(setq c1 (/ (+ r1 r2) 2) s1 (/ (* r1 h1) delR) )
(setq tanValue (/ h1 delR ))
(setq i1 0 ctaWk 0 )
(command "color" "red" "")
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (+ c1 (* r3 (cos ctaWk))) y2 (+ 0 (* r3 (sin ctaWk))) )
(setq z2 (- (* (sqrt (+ (* x2 x2) (* y2 y2))) tanValue) s1))
(setq x22 (+ c1 (* (+ r3 c0) (cos ctaWk))) y22 (+ 0 (* (+ r3 c0) (sin ctaWk))) )
(setq z22 (- (* (sqrt (+ (* x22 x22) (* y22 y22))) tanValue) s1))
(if (> i1 0 )
(progn
(command "color" "red" "")
(command "line" (list x1 y1 z1) (list x2 y2 z2) "" )
(command "line" (list x11 y11 z11) (list x22 y22 z22) "" )
(command "line" (list x1 y1 10) (list x2 y2 10) "" )
(command "line" (list x11 y11 10) (list x22 y22 10) "" )
(if (= (rem i1 6 ) 0 )
(progn
(command "color" "green" "")
(command "line" (list x22 y22 10) (list x22 y22 z2) "" ) ))))
(setq x1 x2 y1 y2 z1 z2 x11 x22 y11 y22 z11 z22)
(setq i1 (+ 1 i1))
)
)
啟動AutoLISP後AutoCAD便可自動畫出如下之圖,圖中紅色內圓是直孔,紅色外圓是倒角用的,有了外圓這些座標後向內及向下偏置,就可求得銑刀底圓中心的座標。
將上述程式修改一下,如下所示,把倒角畫出來,啟動AutoLISP後則可得到下列圖形
(defun c:bt()
(command "color" "bylayer" "")
(setq r1 5.0 r2 15.0 h1 5.0 r3 4.0 r0 1.0 h0 3.0 c0 0.5)
(setq r1 (/ (getreal "\nEnter the top diameter : ") 2 ))
(setq r2 (/ (getreal "\nEnter the bottom diameter : ") 2 ))
(setq h1 (getreal "\nEnter the height : "))
(setq r3 (/ (getreal "\nEnter the diameter of the hole : ") 2 ))
(setq r0 (/ (getreal "\nEnter the bottom diameter of the chamfer tool : ") 2 ))
(setq h0 (abs (getreal "\nEnter the chamfering height of the chamfer tool : ")) )
(setq c0 (getreal "\nEnter the chamfering size : ") 2 )
(setq x2 0 y2 0 x22 0 y22 0 )
(setq i1 1 cta (/ 3.1415926 180.0) ctaWk 0 h1 (* -1 (abs h1)) )
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (* r1 (cos ctaWk)) y2 (* r1 (sin ctaWk )) )
(setq x22 (* r2 (cos ctaWk)) y22 (* r2 (sin ctaWk )) )
(command "line" (list x2 y2 0) (list x22 y22 h1) "" )
(setq i1 (+ 1 i1))
)
(command "zoom" "e" "")
(command "vpoint" "1,-1,1" "")
(setq delR (- r2 r1) z2 0 x1 0 y1 0 x2 0 y2 0)
(setq x11 0 y11 0 z11 0 x22 0 y22 0 z22 0 x3 0 y3 0 z3 0)
(setq c1 (/ (+ r1 r2) 2) s1 (/ (* r1 h1) delR) )
(setq tanValue (/ h1 delR ))
(setq i1 0 ctaWk 0 )
(command "color" "red" "")
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (+ c1 (* r3 (cos ctaWk))) y2 (+ 0 (* r3 (sin ctaWk))) )
(setq z2 (- (* (sqrt (+ (* x2 x2) (* y2 y2))) tanValue) s1))
(setq x22 (+ c1 (* (+ r3 c0) (cos ctaWk))) y22 (+ 0 (* (+ r3 c0) (sin ctaWk))) )
(setq z22 (- (* (sqrt (+ (* x22 x22) (* y22 y22))) tanValue) s1))
(if (> i1 0 )
(progn
(command "color" "red" "")
(command "line" (list x1 y1 (- z11 c0)) (list x2 y2 (- z22 c0)) "" )
(command "line" (list x11 y11 z11) (list x22 y22 z22) "" )
(command "line" (list x2 y2 (- z22 c0)) (list x22 y22 z22) "" )
(command "line" (list x11 y11 10) (list x22 y22 10) "" )
(if (= (rem i1 6 ) 0 )
(progn
(command "color" "green" "")
(command "line" (list x22 y22 10) (list x22 y22 z22) "" ) ))))
(setq x1 x2 y1 y2 z1 z2 x11 x22 y11 y22 z11 z22)
(setq i1 (+ 1 i1))
)
)
最後得將倒角刀底圓中心的路徑角畫出來驗証看看,再來用AutoLISP寫CNC程式,啟動AutoLISP後則可得到下列圖形 :
AutoLISP程式如下:
(defun c:bt()
(command "color" "bylayer" "")
(setq r1 5.0 r2 15.0 h1 5.0 r3 4.0 r0 1.0 h0 3.0 c0 0.5)
(setq r1 (/ (getreal "\nEnter the top diameter : ") 2 ))
(setq r2 (/ (getreal "\nEnter the bottom diameter : ") 2 ))
(setq h1 (getreal "\nEnter the height : "))
(setq r3 (/ (getreal "\nEnter the diameter of the hole : ") 2 ))
(setq r0 (/ (getreal "\nEnter the bottom diameter of the chamfer tool : ") 2 ))
(setq h0 (abs (getreal "\nEnter the chamfering height of the chamfer tool : ")) )
(setq c0 (getreal "\nEnter the chamfering size : ") )
(setq x2 0 y2 0 x22 0 y22 0 )
(setq i1 1 cta (/ 3.1415926 180.0) ctaWk 0 h1 (* -1 (abs h1)) )
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (* r1 (cos ctaWk)) y2 (* r1 (sin ctaWk )) )
(setq x22 (* r2 (cos ctaWk)) y22 (* r2 (sin ctaWk )) )
(command "line" (list x2 y2 0) (list x22 y22 h1) "" )
(setq i1 (+ 1 i1))
)
(command "zoom" "e" "")
(command "vpoint" "1,-1,1" "")
(setq delR (- r2 r1) z2 0 x1 0 y1 0 x2 0 y2 0 x3 0 y3 0 z3 0 x4 0 y4 0)
(setq x11 0 y11 0 z11 0 x22 0 y22 0 z22 0 x33 0 y33 0 z33 0 x44 0 y44 0)
(setq c1 (/ (+ r1 r2) 2) s1 (/ (* r1 h1) delR) )
(setq tanValue (/ h1 delR ))
(setq i1 0 ctaWk 0 )
(command "color" "red" "")
(while (< i1 361)
(setq ctaWk (* cta i1))
(setq x2 (+ c1 (* r3 (cos ctaWk))) y2 (+ 0 (* r3 (sin ctaWk))) )
(setq z2 (- (* (sqrt (+ (* x2 x2) (* y2 y2))) tanValue) s1))
(setq x22 (+ c1 (* (+ r3 c0) (cos ctaWk))) y22 (+ 0 (* (+ r3 c0) (sin ctaWk))) )
(setq z22 (- (* (sqrt (+ (* x22 x22) (* y22 y22))) tanValue) s1))
(setq x33 (+ c1 (* (- (+ r3 c0) h0) (cos ctaWk))) y33 (+ 0 (* (- (+ r3 c0) h0 ) (sin ctaWk))) )
(setq x44 (+ c1 (* (- (+ r3 c0) r0 h0) (cos ctaWk))) y44 (+ 0 (* (- (+ r3 c0) r0 h0) (sin ctaWk))) )
(setq z33 (- z22 h0) )
(if (> i1 0 )
(progn
(command "color" "red" "")
(command "line" (list x1 y1 (- z11 c0)) (list x2 y2 (- z22 c0)) "" )
(command "line" (list x11 y11 z11) (list x22 y22 z22) "" )
(command "line" (list x2 y2 (- z22 c0)) (list x22 y22 z22) "" )
(command "line" (list x3 y3 z33) (list x33 y33 z33) "" )
(command "line" (list x4 y4 z33) (list x44 y44 z33) "" )
(if (= (rem i1 5 ) 0 )
(progn
(command "color" "green" "")
(command "line" (list x33 y33 z33) (list x22 y22 z22) "" ) ))))
(setq x1 x2 y1 y2 z1 z2 x11 x22 y11 y22 z11 z22 x3 x33 y3 y33 x4 x44 y4 y44)
(setq i1 (+ 1 i1))
)
)
篇幅所限,下篇文章再來寫如何用AutoLISP寫CNC程式。
http://tw.myblog.yahoo.com/cu01joe/article?mid=1997&prev=2091&next=1970
留言
張貼留言