Home > Community > Forums > PCB SKILL > etch length-measuring functions

Email

* Required Fields

Recipients email * (separate multiple addresses with commas)

Your name *

Your email *

Message *

Contact Us

* Required Fields
First Name *

Last Name *

Email *

Company / Institution *

Comments: *

 etch length-measuring functions 

Last post Wed, Dec 13 2006 10:18 AM by archive. 0 replies.
Started by archive 13 Dec 2006 10:18 AM. Topic has 0 replies and 1266 views
Page 1 of 1 (1 items)
Sort Posts:
  • Wed, Dec 13 2006 10:18 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,930
    etch length-measuring functions Reply

    Greetings all,

    In the past I've had need of  getting the length of a trace, whether that trace be a segment (CLINESEG), path (CLINE) or of an entire net. "show elements" on the trace yields the desired value but I want the value to be available within a SKILL routine.  So I wrote my own set of functions to calculate the value for me.  Here they are:

    ;----------------------------------------
    ; length-finding utility functions
    ; written by: Chris Walters
    ;
    ;
    ; These functions will find the length of an etch trace
    ; for a given segment, path, or entire net, respectively
    ;
    ; Revision History
    ; 2006/12/13 Chris Walters
    ; Initial release
    ;----------------------------------------
    procedure( cdw_findSegLength( seg_db)
    prog((seglength pt1 pt2 pt3 chordlength rradius aangle xproduct)

    seglength = 0.0

    pt1 = car( seg_db->startEnd)
    pt2 = cadr( seg_db->startEnd)

    pt1.x = xCoord( pt1)
    pt1.y = yCoord( pt1)
    pt2.x = xCoord( pt2)
    pt2.y = yCoord( pt2)

    if( seg_db->objType == "arc" then
    pt3 = seg_db->xy
    pt3.x = xCoord( pt3)
    pt3.y = yCoord( pt3)
    chordlength = sqrt( (pt2.x - pt1.x)*(pt2.x - pt1.x) + (pt2.y - pt1.y)*(pt2.y - pt1.y) )
    rradius = seg_db->radius

    ;determine angle formed by pt1 and pt2 with center at rradius
    aangle = 2 * asin( chordlength / (2 * rradius)) ; in radians

    ;determine whether arc is major or minor
    xproduct = (pt2.x - pt1.x)*(pt3.y - pt1.y) - (pt3.x - pt1.x)*(pt2.y - pt1.y) ; 2D cross-product

    cond(
    ( !seg_db->isClockwise && xproduct < 0.0 ; major arc
    seglength = (6.283185 - aangle) * rradius
    )
    ( !seg_db->isClockwise && xproduct >= 0.0 ; minor arc
    seglength = aangle * rradius
    )
    ( seg_db->isClockwise && xproduct < 0.0 ; minor arc
    seglength = aangle * rradius
    )
    ( seg_db->isClockwise && xproduct >= 0.0 ; major arc
    seglength = (6.283185 - aangle) * rradius
    )
    );end-cond
    else
    seglength = sqrt( (pt2.x - pt1.x)*(pt2.x - pt1.x) + (pt2.y - pt1.y)*(pt2.y - pt1.y) )
    );end-if

    return( seglength)

    );end-prog
    );end-procedure

    ;----------------------------------------
    procedure( cdw_findPathLength( path_db)
    prog(( pathlength)

    pathlength = 0.0

    foreach( seg_db path_db->segments
    pathlength = pathlength + cdw_findSegLength( seg_db)
    );end-foreach

    return( pathlength)

    );end-prog
    );end-procedure

    ;----------------------------------------
    procedure( cdw_findNetLength( net_db)
    prog(( netlength)

    netlength = 0.0

    foreach( net_br net_db->branches
    foreach( child_db net_br->children
    if( child_db->objType == "path" then
    netlength = netlength + cdw_findPathLength( child_db)
    );end-if
    );end-foreach
    );end-foreach

    return( netlength)

    );end-prog
    );end-procedure


    Merry Christmas!


    Chris Walters
    local Cadence guru
    ()


    Originally posted in cdnusers.org by kerchunk
    • Post Points: 0
Page 1 of 1 (1 items)
Sort Posts:
Started by archive at 13 Dec 2006 10:18 AM. Topic has 0 replies.