Home > Community > Forums > PCB SKILL > Calculation/precision issue with arc radius

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: *

 Calculation/precision issue with arc radius 

Last post Fri, Jun 16 2006 4:36 AM by archive. 4 replies.
Started by archive 16 Jun 2006 04:36 AM. Topic has 4 replies and 1919 views
Page 1 of 1 (5 items)
Sort Posts:
  • Fri, Jun 16 2006 4:36 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,910
    Calculation/precision issue with arc radius Reply

    Hi,

    I've got the following problem with some skill code I've written that should export more than one place bound per component to IDF.
    The code so far seems stable, but I have issues with calculating the arc radius if it is not between 10 and 170 degrees or 0/180 degrees.

    I've created a test case that exhibits the issue. It is attached as boards.zip it contains 2 board files. Case2.brd which is the original board in millimeters and micron_2decimals.brd which is a conversion of case2.brd with 2 decimal points. Looking at this there should be precisely a factor 1000 in difference, this is however not the case, I can get better precision after the translation. Here's the arc data that I can get out using the attached skill program

    Arc data        millimeters        microns
    Center x        -1.06                -1059.77
    Center y        -0.122                -122.36
    Radius            0.151                150.52
    x1                 -0.98                 -980.0
    y1                  -0.25                -250.0
    x2                -1.14                -1140.0             
    y2                0.005                5.0
    Load the skill program and run ns_idf to get files named boardname.emp/emn and temp_ptc.emp/emn (the last is the Cadence IDF output)
    Look in the boardname.emp file to see the data above, they're listed just below the line with the arc radius in the boardnameemp file.
    The boards.zip also contains an Excel spreadsheet that shows the calculation method. This is also written in the skill code, but in a rather complex system due to the fact that the angles has to be correct with respect to sign and degree. I've had customers looking at the output and this should be the only issue left to get the correct results.

    Now using mathematics I can calculate the arc radius to the following
    In millimeters (case2.brd) I get the angle to be -170.86
    And in microns I get the angle to be -179.89

    The weird thing here is that using the Cadence built in IDF export functionality gives the same figure in both cases, namely -179.798

    So I'm looking for a  way to get more precision out of the board using millimeters.
    Does anyone have any idea whats going on here? I'm just very curious as to how the built in Cadence IDF export can get the precision from the case2.brd to calculate the angle whereas I cannot do the same

    Best regards,
    Ole


    Originally posted in cdnusers.org by ejlersen
    • Post Points: 0
  • Mon, Jun 19 2006 8:56 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,910
    RE: Calculation/precision issue with arc radius Reply

    Hi Ole,

    Your code is quite complex - and involves lots of floating point maths - so you will probably get lots of floating point rounding errors. See the discussion about that problem in this forum.

    I have written a similar routine for exporting IDF and get the same results as Cadence.
    See attached.

    Cheers, Dave


    Originally posted in cdnusers.org by Dave Elder
    • Post Points: 0
  • Tue, Jun 20 2006 5:35 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,910
    RE: Calculation/precision issue with arc radius Reply

    Hi Dave,

    Thanks very much for the code, although I've got problems figuring out how you actually calculate the angle. I've looked all over the documentation for the atan2 function but I cannot find anything about it, except that it takes 2 arguments but how will that help me?

    Another thing is the sign of the angle, it is consequently the wrong sign compared to running this on a larger board with several arcs. It may be easy to change, but as written above I've got some problems figuring out exactly what you do and why?
    I know my code is also pretty complex and this is due to the fact that getting the correct angle when using normal atan is dependent on the start and end points position relatively (depending on the quadrant of the coordinate system). I can see that you get the correct angle each time, only issue is the sign, so maybe you've got another approach than I have?

    I've attached an example that exhibits this issue so you can see it for your self. The angle figure is the same but the sign in your case is negative whereas it is positive in the Cadence case.

    Best regards,
    Ole


    Originally posted in cdnusers.org by ejlersen
    • Post Points: 0
  • Tue, Jun 27 2006 4:59 PM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,910
    RE: Calculation/precision issue with arc radius Reply

    Hi Ole,

    I'll take a look at the angle sign issue. I have had problems with that in the past and possibly need to improve my code for it to work in every case.

    atan2 gets around the problem with atan where the adjacent line length is 0.
    i.e. atan(o / a) returns an "Attempted to divide by zero" error if a is 0. atan2(o a) correctly returns pi / 2 if a is 0.

    I don't know why atan2 isn't documented. I never use atan.

    Cheers, Dave


    Originally posted in cdnusers.org by Dave Elder
    • Post Points: 0
  • Wed, Jun 28 2006 12:54 AM

    • archive
    • Top 75 Contributor
    • Joined on Fri, Jul 4 2008
    • Posts 88
    • Points 4,910
    RE: Calculation/precision issue with arc radius Reply

    Hi Dave,

    Thanks for the explanation. This problem was actually one of the reasons I had to make the code more complex.


    Best regards,
    Ole


    Originally posted in cdnusers.org by ejlersen
    • Post Points: 0
Page 1 of 1 (5 items)
Sort Posts:
Started by archive at 16 Jun 2006 04:36 AM. Topic has 4 replies.