明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1401|回复: 3

[求助]请高手,大侠帮忙调试一下齿轮的程序!

[复制链接]
发表于 2007-5-20 20:13 | 显示全部楼层 |阅读模式

 小弟初学autolisp,这是本人的第一个自己编的程序,.虽然很烂,方法也很笨,但已经反映了了我目前的水平了.但是,老运行不了,我自己一时也找不到错在哪.      恳请版主,各位高手,大侠帮忙给调试一下,小弟十分感激.

   程序计算校核中的变量都是,取的一些常量,没多大意义.  以下是dcl和lisp的程序,渐开线是取点求出的>

            dcl程序

 clcs:dialog{
  label="普通带式输送机减速器的高速级齿轮传动的小齿轮参数化设计";
  :paragraph{
  label="设计的初始条件";
  :text_part{
  label="减速器为由电动机驱动,输送机工作平稳,转向不变的一般工作机器";
 
  }
  :text_part{
  label="俩班制,每年工作300天,工作寿命15年";
 
  }
  :text_part{
  label="选用7级精度的直齿圆柱齿轮";
 
  }
  :text_part{
  label="小齿轮材料为调质处理的40Cr,硬度为280HBS";
 
  }
  :text_part{
  label="大齿轮材料为调质处理的45号钢,硬度为240HBS";
 
  }
  :text_part{
  label="输入功率P1=10kw,小齿轮转速n1=960r/min";
 
  }
  }
  spacer;
  :boxed_column{
  label="设计参数选择";
  :popup_list{
  label="齿数比u=";
  key=pop1;
  edit_width=10;
  value=2;
  list="3\n3.1\n3.2\n3.3\n3.4\n3.5\n3.6\n3.7\n3.8\n3.9\n4";
  }
  :popup_list{
  label="初选小齿轮齿数z1=";
  key=pop2;
  edit_width=10;
  value=6;
  list="18\n19\n20\n21\n22\n23\n24\n25\n26\n27\n28\n29\n30";
  }
  }
  ok_only;
  }

                        lisp程序

   ;表达示dcl_clcs至此结束。


               ; 计算及作图的程序代码
 
  (defun cljg (/ pt pt0 pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt9 pt10 pt11 pt12 pt13 orig_cmd orig_blip orig_osnap)
  (setq orig_blip (getvar "blipmode"))
  (setq orig_cmd (getvar "cmdecho"))
  (setq orig_osnap (getvar "osmode"))
  (setvar "blipmode" 0)
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)  ;


                   ;按齿面接触强度设计

  (setq ze 189.8 kt 1.3 p1 10 n1 960)  
  (setq t1 (* 955000 (/ p1 n1)))
  (setq ∮d 1 khn1 0.9 khn2 0.95 s 1)
  (setq ∝hlim1 600 ∝hlim2 550)
  (setq ∝h1 (/ (* khn1 ∝hlim1) s))
  (setq ∝h2 (/ (* khn2 ∝hlim2) s))
  (if (< ∝h1 ∝h2) (setq ∝hx ∝h1) (setq ∝hx ∝h2))
  (setq a1 (* (/ ze ∝hx) (/ ze ∝hx)))
  (setq a2 (/ (* kt t1) ∮d))
  (setq a3 (/ (+ u 1) u))
  (setq a4 (* a2 a3 a1))
  (setq d1t (* (expt a4 (/ 1.0 3)) 2.32))  ;求得立方根
  (setq v (/ (* pi d1t n1) (* 60 1000)))
  (setq b (* ∮d d1t))
  (setq mt (/ d1t z1))
  (setq h (* 2.25 mt))
  (setq a5 (/ b h))
  (setq kv 1.12 kha 1.2 kf 1.2 ka 1)
  (setq a6 (* 0.18 (* (* ∮d ∮d) (+ 1 (* 0.6 ∮d ∮d)))))
  (setq a7 (* 0.23 0.001 b))
  (setq khb (+ 1.12 a6 a7))
  (setq kfb 1.35)
  (setq k1 (* ka kv kha khb))
  (setq a8 (/ k1 kt))
  (setq d1 (* d1t (expt a8 (/ 1.0 3.0))))
  (setq m1 (/ d1 z1))    ;

                ;按齿根弯曲强度设计  


   
  (setq ∝fe1 500 ∝fe2 380 kfn1 0.85 kfn2 0.88 s 1.4 kfa 1.2) 
  (setq ∝fe1x (/ (* kfn1 ∝fe1) s))
  (setq ∝fe2x (/ (* kfn2 ∝fe2) s))
  (setq k2 (* ka kv kf kfb))
  (setq yfa1 2.65 yfa2 2.26 ysa1 1.58 ysa2 1.764)
  (setq b1 (/ (* yfa1 ysa1) ∝f1x))
  (setq b2 (/ (* yfa2 ysa2) ∝f2x))
  (if (< b1 b2) (setq b3 b2) (setq b3 b1))
  (setq b4 (* 2 k2 t1) b5 (* ∮d z1 z1))
  (setq b6 (* (/ b4 b5) b3))
  (setq m2 (expt b6 (/ 1.0 3)))
  (if (< m2 m1) (setq m3 m2) (setq m3 m1))
  (setq c1 1 c2 1.25 c3 1.5 c4 2 c5 2.5 c6 3 c7 4 c8 5)
  (setq g1 (abs (- m3 c1))
        g2 (abs (- m3 c2))
        g3 (abs (- m3 c3))
        g4 (abs (- m3 c4))
        g5 (abs (- m3 c5))
        g6 (abs (- m3 c6))
        g7 (abs (- m3 c7))
        g8 (abs (- m3 c8)))
  (setq g (min g1 g2 g3 g4 g5 g6 g7 g8))
  (cond
  ((= g g1) (setq m c1))
  ((= g g2) (setq m c2))
  ((= g g3) (setq m c3))
  ((= g g4) (setq m c4))
  ((= g g5) (setq m c5))
  ((= g g6) (setq m c6))
  ((= g g7) (setq m c7))
  ((= g g8) (setq m c8)))
  (setq z11 (/ d1 m))  ;
  (setq z (fix z11))
  (setq d (* m z))
  (setq ha* 1 c* 0.25)
  (setq ha (* m ha*) hf (* m (+ ha* c*)))
  (setq da (* m (+ z (* 2 ha*))))
  (setq df (* m (- z (+ (* 2 ha*) (* 2 c*)))))
  (setq ay (* pi (/ 20 180)))
  (setq db (* d (cos ay)))   ;ay压力角需设定弧度值
  (setq ra (/ da 2) r (/ d 2) rf (/ df 2) rb (/ db 2))      ;


                 ; 画渐开线的步骤及作图程序


   
  (initget 3)  
  (setq pt (getpoint "\n请指定齿轮中心点的位置:"))
  (setq xx (car pt) yy (cadr pt))
  (setq pt0 (polar pt (/ pi 2) ra))
  (setq invangy 0.01490439 e (/ (* m pi) (* 4 r)))
  (setq rc1 rb)
  (setq angc1 (+ invay e))
  (setq pt1 (list (+ xx (* rc1 (sin angc1))) (+ yy (* rc1 (cos angc1)))))
  (setq f (/ (- ra rb) 10))
  (setq rc2 (+ rc1 f))
   
  (setq f2 (/ rb rc2))
  (if (<= (abs f2) 1)
      (setq angc2y (atan (sqrt (- 1 (* f2 f2))) f2)))
  (setq angc2 (+ e (- invay (- (/ (sin angc2y) (cos angc2y))))))
  (setq pt2 (list (+ xx (* rc2 (sin angc2))) (+ yy (* rc2 (cos angc2)))))
  (setq rc3 (+ rc2 f))
   
  (setq f3 (/ rb rc3))
  (if (<= (abs f3) 1)
      (setq angc3y (atan (sqrt (- 1 (* f3 f3))) f3)))  
  (setq angc3 (+ e (- invay (- (/ (sin angc3y) (cos angc3y))))))
  (setq pt3 (list (+ xx (* rc3 (sin angc3))) (+ yy (* rc3 (cos angc3)))))
  (setq rc4 (+ rc3 f))
   
  (setq f4 (/ rb rc4))
  (if (<= (abs f4) 1)
      (setq angc4y (atan (sqrt (- 1 (* f4 f4))) f4)))  
  (setq angc4 (+ e (- invay (- (/ (sin angc4y) (cos angc4y))))))
  (setq pt4 (list (+ xx (* rc4 (sin angc4))) (+ yy (* rc4 (cos angc4)))))
  (setq rc5 (+ rc4 f))
   
  (setq f5 (/ rb rc5))
  (if (<= (abs f5) 1)
      (setq angc5y (atan (sqrt (- 1 (* f5 f5))) f5)))  
  (setq angc5 (+ e (- invay (- (/ (sin angc5y) (cos angc5y))))))
  (setq pt5 (list (+ xx (* rc5 (sin angc5))) (+ yy (* rc5 (cos angc5)))))
  (setq rc6 (+ rc5 f))
   
  (setq f6 (/ rb rc6))
  (if (<= (abs f6) 1)
      (setq angc6y (atan (sqrt (- 1 (* f6 f6))) f6)))  
  (setq angc6 (+ e (- invay (- (/ (sin angc6y) (cos angc6y))))))
  (setq pt6 (list (+ xx (* rc6 (sin angc6))) (+ yy (* rc6 (cos angc6)))))
  (setq rc7 (+ rc6 f))
   
  (setq f7 (/ rb rc7))
  (if (<= (abs f7) 1)
      (setq angc7y (atan (sqrt (- 1 (* f7 f7))) f7)))  
  (setq angc7 (+ e (- invay (- (/ (sin angc7y) (cos angc7y))))))
  (setq pt7 (list (+ xx (* rc7 (sin angc7))) (+ yy (* rc7 (cos angc7)))))
  (setq rc8 (+ rc7 f))
   
  (setq f8 (/ rb rc8))
  (if (<= (abs f8) 1)
      (setq angc8y (atan (sqrt (- 1 (* f8 f8))) f8)))  
  (setq angc8 (+ e (- invay (- (/ (sin angc8y) (cos angc8y))))))
  (setq pt8 (list (+ xx (* rc8 (sin angc8))) (+ yy (* rc8 (cos angc8)))))
  (setq rc9 (+ rc8 f))
   
  (setq f9 (/ rb rc9))
  (if (<= (abs f9) 1)
      (setq angc9y (atan (sqrt (- 1 (* f9 f9))) f9)))  
  (setq angc9 (+ e (- invay (- (/ (sin angc9y) (cos angc9y))))))
  (setq pt9 (list (+ xx (* rc9 (sin angc9))) (+ yy (* rc9 (cos angc9)))))
  (setq rc10 (+ rc9 f))
   
  (setq f10 (/ rb rc10))
  (if (<= (abs f10) 1)
      (setq angc10y (atan (sqrt (- 1 (* f10 f10))) f10)))  
  (setq angc10 (+ e (- invay (- (/ (sin angc10y) (cos angc10y))))))
  (setq pt10 (list (+ xx (* rc10 (sin angc10))) (+ yy (* rc10 (cos angc10)))))
  (setq rc11 (+ rc10 f))
   
  (setq f11 (/ rb rc11))
  (if (<= (abs f11) 1)
      (setq angc11y (atan (sqrt (- 1 (* f11 f11))) f11)))  
  (setq angc11 (+ e (- invay (- (/ (sin angc11y) (cos angc11y))))))
  (setq pt11 (list (+ xx (* rc11 (sin angc11))) (+ yy (* rc11 (cos angc11)))))
  (command "pline" pt1 pt2 pt3 pt4 pt5 pt6 pt7 pt8 pt9 pt10 pt11 "")
  (setq s ssadd)
  (ssadd (entlast) s)
  (command "arc" pt0 "p" pt11 "r" ra "")
  (ssadd (entlast) s)
  (setq yxd (- (car pt1) yy))
  (setq e1 (* rf rf) e2 (* yxd yxd))
  (setq pt12 (list (car pt1) (sqrt (- e1 e2))))
  (command "line" pt1 pt12 "")
  (setq ang (- (/ (* 2 pi) (* 2 z)) (* pi (/ 0.5 180))))
  (setq pt13 (polar pt ang rf))
  (command "arc" pt12 "p" pt13 "r" rf "")
  (setq rd 1)
  (setvar "filletrad" rd)
  (command "fillet" "p" "l" "")
  (ssadd (entlast) s)
  (command "mirror" s "" pt pt0 "" "y")
  (ssadd (entlast) s)
  (command "array" s "" "p" pt0 z1 "")
  (ssadd (entlast) s)
  (commmand "extrude" s "" b "" "")
  (setvar "blipmode" orig_blip)
  (setvar "cmdecho" orig_cmd)
  (setvar "osmode" orig_osnp)
  
  )

   小子献丑了,请帮帮帮忙!!!!!!!!!!!!!!!!!!

 楼主| 发表于 2007-5-20 21:43 | 显示全部楼层
里面错误挺多的,我自己都感到不好意思了,我也从里面发现了一些错误.
 楼主| 发表于 2007-5-20 21:58 | 显示全部楼层

我刚刚已经在lisp源码里面,找到了直齿圆柱齿轮的源码了.非常感谢明经社区的无私,也感谢各位版主和高手的无私帮助.   我现在是怀着一种喜悦的感激之情.                   

          谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢谢!!!!!!!!!!!!!!!!!!!!!!!!!!

 楼主| 发表于 2007-5-21 08:31 | 显示全部楼层
lisp程序加漏了一段话,
   (defun c:clcs() (setq dcl_id (load_dialog "c:/clcs.dcl"))
  (new_dialog "clcs" dcl_id)
  (action_tile "pop1" "(setq u (get_tile \"pop1\"))")
  (action_tile "pop2" "(setq z1 (get_tile\"pop2\"))")
  (action_tile "accept" "(cljg)(done_dialog)")
  (start_dialog) (unload_dialog dcl_id)
  (prin1)
  )

  主要是请高手,大侠看看这俩句与dcl 相联结的语句有问题吗?
(action_tile "pop1" "(setq u (get_tile \"pop1\"))")
  (action_tile "pop2" "(setq z1 (get_tile\"pop2\"))")
怎么老是与dcl联不上啊
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-19 06:07 , Processed in 0.305998 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表