Main Content

PCBReader

R2026b

Import and update Gerber files

Description

Use the PCBReader object to create a printed circuit board (PCB) reader to import Gerber files and create a PCB model. A Gerber file is a set of manufacturing files used to describe a PCB. A Gerber file uses an ASCII vector format to describe 2-D binary images.

Creation

You can create a PCBReader object using the following methods:

  • gerberRead — Create a PCBReader object with the specified Gerber and drill files.

  • The PCBReader function described here.

Description

B = PCBReader(S) creates a PCBReader object that imports multilayer PCB design files described in S.

Note

example

B = PCBReader(PropertyName=Value) sets Properties using name-value arguments. Name is the property name and Value is the corresponding value. You can specify several name-value arguments in any order as Name1,Value1,...,NameN,ValueN. Properties not specified retain their default values. For example, B = PCBReader('StackUp',S,'Drillfile','ant.txt') imports the layer and drill files into the PCBReader.

Input Arguments

expand all

PCB stackup definition, specified as a stackUp object. The stackUp object can define multiple metal layers.

Example: S = stackUp; B = PCBReader(S)

Example: B = PCBReader('StackUp',S)

Properties

expand all

PCB stackup definition, specified as a stackUp object.

Example: S = stackUp; B.StackUp = S;

Example: B = PCBReader('StackUp',S)

Name of Excellon drill file, specified as a character vector for a single drill file or a cell array of character vectors for multiple drill files. You can specify drill files with either a .drl or a .txt extension. When specifying drill files for a multilayer board, provide the names in a cell array and set DrillLayerPairs before assigning DrillFile. Supplying a plain character vector uses a default connectivity of [1 2] (first to second metal layer).

Example: B.DrillFile = 'ant.drl'

Since R2026b

Connectivity between metal layers, specified as a N-by-2 matrix of metal-layer ordinals. N is the number of drill files. Each row represents a pair of metal-layer ordinals, not absolute stackUp layer numbers, that are electrically connected through vias described in the corresponding drill file. For example, in a 3-metal-layer stackUp (layers 2, 4, 6), use [1 3] to connect the first metal layer to the third. The resulting ViaLocations in the pcbStack object reports the corresponding absolute stackUp layer numbers. The ordering of rows must match the order of drill files specified in the input.

Example: [1 3]

Data Types: double

Discretization points on curved segments, specified as a positive scalar.

Example: B.NumPointsOnCurves = 80

Examples

collapse all

Create a PCB stack up definition object using default properties.

S = stackUp;

Set the thickness of the dielectric Air in layer 1 to 0.1 mm.

S.Layer1.Thickness = 0.1e-3;

Import a top layer Gerber file to layer 2.

S.Layer2 = 'interdigital_Capacitor.gtl';

Create a PCBReader object using the stackUp object, S.

p = PCBReader('StackUp',S);

To update the Gerber file, convert the PCBReader object to a pcbComponent object.

pcbcapacitor = pcbComponent(p);
pcbcapacitor.FeedDiameter = 0.001
pcbcapacitor = 
  pcbComponent with properties:

              Name: 'interdigital_Capacitor'
          Revision: 'v1.0'
        BoardShape: [1×1 antenna.Rectangle]
    BoardThickness: 0.0061
            Layers: {[1×1 dielectric]  [1×1 antenna.Polygon]  [1×1 dielectric]  [1×1 dielectric]}
        FeedFormat: 'FeedLocations'
     FeedLocations: [0 0 2]
      FeedDiameter: 1.0000e-03
      ViaLocations: []
       ViaDiameter: []
      FeedViaModel: 'square'
         Conductor: [1×1 metal]
              Tilt: 0
          TiltAxis: [0 0 1]
              Load: [1×1 lumpedElement]
        SolverType: 'MoM'
        IsShielded: 0

View the PCB component in the Gerber file.

show(pcbcapacitor)

Figure contains an axes object. The axes object with title pcbComponent element, xlabel x (mm), ylabel y (mm) contains 6 objects of type patch, surface. These objects represent PEC, feed, FR4.

This example will show how to translate the symmetrical polygon imported from the Gerber file to the respective co-ordinates.

Create a PCB stackup and import rectangular patch on it.

S = stackUp;
S.Layer2 = 'PatchRectangular.gtl';
S.Layer3 = dielectric('Teflon');

Use a PCB Reader to read the polygon shape from the stackup.

p1 = PCBReader ('StackUp',S);
figure; show(p1.shapes);

Figure contains an axes object. The axes object with xlabel x (mm), ylabel y (mm) contains 2 objects of type patch. These objects represent PEC, mypolygon.

Translate the shape with center (0,0) using the centriod function from MATLAB®.

s = p1.shapes
s = 
  Polygon with properties:

        Name: 'mypolygon'
    Vertices: [4×3 double]

polygon = s;
[x,y] = centroid(polygon);
translate(polygon,[-x, -y, 0]);

Figure contains an axes object. The axes object with xlabel x (mm), ylabel y (mm) contains 2 objects of type patch. These objects represent PEC, mypolygon.

This example shows how to translate the asymmetrical polygon imported from the Gerber file to the respective co-ordinates.

Create a PCB stackup and import rectangular patch on it.

S = stackUp;
S.Layer2 = 'RightAngleBend.gtl';
S.Layer3 = dielectric('Teflon');

Use a PCB Reader to read the polygon shape from the stackup.

p1 = PCBReader ('StackUp',S);
figure; show(p1.shapes);

Figure contains an axes object. The axes object with xlabel x (mm), ylabel y (mm) contains 2 objects of type patch. These objects represent PEC, mypolygon.

Translate the shape's bottom left corner to (0,0). Use the boundingbox function from MATLAB to convert the shape to polyshape and find the upper and lower bounds of the shape.

s = p1.shapes
s = 
  Polygon with properties:

        Name: 'mypolygon'
    Vertices: [6×3 double]

ver = s.Vertices(:,1:2);
polygon = polyshape(ver);
[xlim, ylim] = boundingbox(polygon);
translate(s,[-xlim(1), -ylim(1), 0]);

Figure contains an axes object. The axes object with xlabel x (mm), ylabel y (mm) contains 2 objects of type patch. These objects represent PEC, mypolygon.

Version History

Introduced in R2021b

expand all