Page 1 of 1

PCB123's Coordinate display and precision calculation.

PostPosted: Wed Sep 19, 2012 9:46 am
by Chuan Liu
First, the "resolution of the coordinate display" problem results when the grid is set to a value which suggests the number of decimal places to display when showing grid coordinates. The complaint is that when the grid value suggests a resolution of two decimal places that coordinate values sometimes show more fractional digits when using millimeters for units. This problem is addressed by deliberately rounding coordinate values to the resolution of the grid even if the unrounded value is more precise (which it is as will be explained below). Using the example in the description of the problem, before if "G=0.01mm" then PCB123 showed "X:40.8315mm, Y:3.7829 ..2 additional digits of resolution..which alternates between 1 or 2 digits", now, PCB123 will always round to the suggested numeric resolution, if "G=0.01mm" then "X:40.83mm, Y:3.78mm".

For various software engineering reasons specific to CAD and printed circuit board problems, PCB123 computes with 32 bit integers rather than IEEE floating point numbers. The "world" that you see in the PCB123 layout view in not really the continuous image seemingly displayed on the screen, but is actually coordinate field of roughly 4 billion points in each the x and y directions. There are no points between these defined points. Computers and PCB123 by extension must do discrete math.

Thus, internally PCB123 computes with what it generically refers to as UNITS (32 bit integers) and it defines one inch = 10,000,000 UNITS. Thus the layout view is composed of about 4 billion points squared (16*10^18 discrete points) and has an extent of about 36 square feet. Since PCB123 defines the UNIT as a multiple of an INCH, the program computes with absolute precision within this 36 square foot area when units are set to "INCHES" or "MILS" down to seven decimal places (0.0000001", or a ten thousandth of a MIL).

Since PCB123 defines its UNIT in terms of discrete parts of an inch, and since metric measurements do not exactly convert to inches (i.e. 25.4 mm = 1 inch), PCB123 necessarily is less precise in displaying metric units. For instance, if the customer sets his/her grid to a resolution of "0.0002 mm" (0.2 microns), PCB123 must internally approximate this metric number by the closest number of UNITS to "0.0002 mm", which is 79 UNITS (0.00020066mm). Thus a grid set at 0.0002mm will find its first gridline at the origin, the second gridline at 0.00020066mm, the third at 0.00040132mm, the fourth at 0.00060198mm, etc. The extra digits displaying in PCB123 when using metric units are a correct consequence of this approximation of metric units within a CAD world defined in discrete parts of an inch.