PCB SLOT槽孔数量计算方法,同CAM350孔数一致 实现方法

Posted pcbren

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PCB SLOT槽孔数量计算方法,同CAM350孔数一致 实现方法相关的知识,希望对你有一定的参考价值。

最近有好几个写脚本的朋友问我,SLOT槽孔孔的如何计算的,要求孔数与CAM350孔数保持一致。

前几年通过在CAM350里面不断测试,结果是:CAM 350中SLOT槽孔,孔与孔之间最高位,凸位高度值为0.0127mm

这里将计算方法分享一下,下次有同样的问题可以看此篇文章即可得到答案了。哈。。。。

技术分享图片

通过这个凸位值就很好的计算出SLOT槽孔数了,弧型SLOT槽的原理也是同样的。

 

一.SLOT槽为线段,求解SLOT槽孔数  (Mod类在后面代码中)

/// <summary>
/// 求线Line slot槽孔数 (同CAM350一致)
/// </summary>
/// <param name="l"></param>
/// <param name="tol_">凸位高度值</param>
/// <returns></returns>
public int l_2hole_count(gL l, double tol_ = 0.0127)
{
    double r, center_L, hole_L;
    r = l.width / 1000 * 0.5;
    center_L = p2p_di(l.ps, l.pe);
    hole_L = Math.Sqrt(Math.Pow(r, 2) - Math.Pow(r - tol_, 2)) * 2;
    return (int)Math.Abs(Math.Floor(-center_L / hole_L)) + 1;
}
/// <summary>
/// 返回两点之间欧氏距离
/// </summary>
/// <param name="p1"></param>
/// <param name="p2"></param>
/// <returns></returns>
public double p2p_di(gPoint p1, gPoint p2)
{
    return Math.Sqrt((p1.x - p2.x) * (p1.x - p2.x) + (p1.y - p2.y) * (p1.y - p2.y));
}

 

 

二.SLOT槽为弧段,求解SLOT槽孔数  (Mod类在后面代码中)

/// <summary>
/// 求弧Arc slot槽孔数 (同CAM350一致)
/// </summary>
/// <param name="a"></param>
/// <param name="tol_">凸位高度值</param>
/// <returns></returns>
public int a_2hole_count(gA a, double tol_ = 0.0127)
{
    double r, center_L, hole_L;
    r = a.width / 1000 * 0.5;
    center_L = a_Length(a);
    hole_L = Math.Sqrt(Math.Pow(r, 2) - Math.Pow(r - tol_, 2)) * 2;
    return (int)Math.Abs(Math.Floor(-center_L / hole_L)) + 1;
}
/// <summary>
/// 求弧Arc长度
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
public double a_Length(gA a)
{
    return pi / 180 * p2p_di(a.pc, a.ps) * a_Angle(a);
}
/// <summary>
/// 求弧Arc圆心角 //后续改进 用叉积 与3P求角度求解 验证哪个效率高
/// </summary>
/// <param name="a"></param>
/// <returns></returns>
public double a_Angle(gA a)
{
    double angle_s, angle_e, angle_sum;
    if (a.ccw)
    {
        angle_s = p_ang(a.pc, a.pe);
        angle_e = p_ang(a.pc, a.ps);
    }
    else
    {
        angle_s = p_ang(a.pc, a.ps);
        angle_e = p_ang(a.pc, a.pe);
    }
    if (angle_s == 360) { angle_s = 0; }
    if (angle_e >= angle_s)
        angle_sum = 360 - Math.Abs(angle_s - angle_e);
    else
        angle_sum = Math.Abs(angle_s - angle_e);
    return angle_sum;
}

 

 

 

 

三.使用的Mod类

     线 mod类型

    /// <summary>
    /// Line 数据类型
    /// </summary>
    public struct gL
    {
        public gL(double ps_x, double ps_y, double pe_x, double pe_y, double width_)
        {
            this.ps = new gPoint(ps_x, ps_y);
            this.pe = new gPoint(pe_x, pe_y);
            this.negative = false;
            this.symbols = "r";
            this.attribut = string.Empty;
            this.width = width_;
        }
        public gL(gPoint ps_, gPoint pe_, double width_)
        {
            this.ps = ps_;
            this.pe = pe_;
            this.negative = false;
            this.symbols = "r";
            this.attribut = string.Empty;
            this.width = width_;
        }
        public gL(gPoint ps_, gPoint pe_, string symbols_, double width_)
        {
            this.ps = ps_;
            this.pe = pe_;
            this.negative = false;
            this.symbols = symbols_;
            this.attribut = string.Empty;
            this.width = width_;
        }
        public gPoint ps;
        public gPoint pe;
        public bool negative;//polarity-- positive  negative
        public string symbols;
        public string attribut;
        public double width;
        public static gL operator +(gL l1, gPoint move_p)
        {
            l1.ps += move_p;
            l1.pe += move_p;
            return l1;
        }
        public static gL operator +(gL l1, gPP move_p)
        {
            l1.ps += move_p.p;
            l1.pe += move_p.p;
            return l1;
        }
        public static gL operator +(gL l1, gP move_p)
        {
            l1.ps += move_p.p;
            l1.pe += move_p.p;
            return l1;
        }
        public static gL operator -(gL l1, gPoint move_p)
        {
            l1.ps -= move_p;
            l1.pe -= move_p;
            return l1;
        }
        public static gL operator -(gL l1, gPP move_p)
        {
            l1.ps -= move_p.p;
            l1.pe -= move_p.p;
            return l1;
        }
        public static gL operator -(gL l1, gP move_p)
        {
            l1.ps -= move_p.p;
            l1.pe -= move_p.p;
            return l1;
        }
    }

 

     弧 mod类型

    /// <summary>
    /// ARC 数据类型
    /// </summary>
    public struct gA
    {
        public gA(double ps_x, double ps_y, double pc_x, double pc_y, double pe_x, double pe_y, double width_, bool ccw_)
        {
            this.ps = new gPoint(ps_x, ps_y);
            this.pc = new gPoint(pc_x, pc_y);
            this.pe = new gPoint(pe_x, pe_y);
            this.negative = false;
            this.ccw = ccw_;
            this.symbols = "r";
            this.attribut = string.Empty;
            this.width = width_;
        }
        public gA(gPoint ps_, gPoint pc_, gPoint pe_, double width_, bool ccw_=false)
        {
            this.ps = ps_;
            this.pc = pc_;
            this.pe = pe_;
            this.negative = false;
            this.ccw = ccw_;
            this.symbols = "r";
            this.attribut = string.Empty;
            this.width = width_;
        }
        public gPoint ps;
        public gPoint pe;
        public gPoint pc;
        public bool negative;//polarity-- positive  negative
        public bool ccw; //direction-- cw ccw
        public string symbols;
        public string attribut;
        public double width;
        public static gA operator +(gA arc1, gPoint move_p)
        {
            arc1.ps += move_p;
            arc1.pe += move_p;
            arc1.pc += move_p;
            return arc1;
        }
        public static gA operator +(gA arc1, gPP move_p)
        {
            arc1.ps += move_p.p;
            arc1.pe += move_p.p;
            arc1.pc += move_p.p;
            return arc1;
        }
        public static gA operator +(gA arc1, gP move_p)
        {
            arc1.ps += move_p.p;
            arc1.pe += move_p.p;
            arc1.pc += move_p.p;
            return arc1;
        }
        public static gA operator -(gA arc1, gPoint move_p)
        {
            arc1.ps -= move_p;
            arc1.pe -= move_p;
            arc1.pc -= move_p;
            return arc1;
        }
        public static gA operator -(gA arc1, gPP move_p)
        {
            arc1.ps -= move_p.p;
            arc1.pe -= move_p.p;
            arc1.pc -= move_p.p;
            return arc1;
        }
        public static gA operator -(gA arc1, gP move_p)
        {
            arc1.ps -= move_p.p;
            arc1.pe -= move_p.p;
            arc1.pc -= move_p.p;
            return arc1;
        }

    }

     点 mod类型

    /// <summary>
    /// 点  数据类型 (XY)
    /// </summary>
    public struct gPoint
    {
        public gPoint(gPoint p_)
        {
            this.x = p_.x;
            this.y = p_.y;
        }
        public gPoint(double x_val, double y_val)
        {
            this.x = x_val;
            this.y = y_val;
        }
        public double x;
        public double y;
        public static gPoint operator +(gPoint p1, gPoint p2)
        {
            p1.x += p2.x;
            p1.y += p2.y;
            return p1;
        }
        public static gPoint operator -(gPoint p1, gPoint p2)
        {
            p1.x -= p2.x;
            p1.y -= p2.y;
            return p1;
        }
    }

 

以上是关于PCB SLOT槽孔数量计算方法,同CAM350孔数一致 实现方法的主要内容,如果未能解决你的问题,请参考以下文章

PCB genesis连孔加除毛刺孔(槽孔与槽孔)实现方法

genesis2000 怎样做槽

PCB genesis短槽加引导孔实现方法

Protel99转Gerber文件导入到CAM350中看为啥钻孔层偏位?在PCB外面好远的地方,如下图

PCB genesis自制孔点 Font字体实现方法

PCB Genesis 外形加内角孔实现方法