How to use Matlab PCBReader objects

Exploring Matlab PCB Toolbox: How-To use Gerber files and PCBComponents


Recently I installed a trial version of the new PCB toolbox from Matlab. From Mathworks website:

RF PCB Toolbox provides functions and apps for designing, analyzing, and visualizing high-speed and RF multi-layer printed circuit boards (PCBs). You can design components with parameterized or arbitrary geometry, including distributed passive structures such as traces, bends, and vias. Using the frequency-domain method of moments and other EM techniques, you can model coupling, dispersion, and parasitic effects.

This is an interesting promise. So I tried some examples and made my own. So far, so good. Today I am exploring importing gerber files and creating a PCB stack from gerber files. I have a few gerbers from my previous KiCad projects so I tried one:

This is an older project of mine, a portable SvxLink node for radio. The images above are captured from KiCad Gerber Viewer application. This comes bundled with KiCad and is installed together with main PCB app.

Now, back to Matlab. One can read a gerber file with gerberRead:

P = gerberRead("RoLink_OPi_4ISC_simplu-Top.gbr");

This creates an Matlab object P of type PCBReader. You can specify multiple gerber files and also a drill file:

P = gerberRead("RoLink_OPi_4ISC_simplu-Top.gbr", "RoLink_OPi_4ISC_simplu-Bottom.gbr", "RoLink_OPi_4ISC_simplu-PTH.drl");

The PCBReader object has several variables

In this example I am creating a PCBReader object with the specified Gerber and drill files, and an FR4 dielectric layer that I will use between top and bottom copper layers:

clc %this clears the screen
topLayer = "RoLink_OPi_4ISC_simplu-Top.gbr";
bottomLayer = "RoLink_OPi_4ISC_simplu-Bottom.gbr";
drillGBR = "RoLink_OPi_4ISC_simplu-PTH.drl";

diel_fr4 = dielectric(Thickness=1.6e-3, Name="FR4", EpsilonR=4.4);

% check if gerber stack is empty
if isempty(P)
    P = gerberRead(topLayer, bottomLayer, drillGBR);

Exploring the PCBReader object in Matlab, we can see it has a StackUp property that contains the layers:

PCBObject.StackUp command (terminal or m file) shows the components of the PCB stack:

>> P.StackUp
ans =
stackUp with properties:
NumLayers: 5
Layer1: [1×1 dielectric]
Layer2: “RoLink_OPi_4ISC_simplu-Top.gbr”
Layer3: [1×1 dielectric]
Layer4: “RoLink_OPi_4ISC_simplu-Bottom.gbr”
Layer5: [1×1 dielectric]

You can explore each layer’s properties. Creating a StackUp object and exploring each layer in terminal or code is simple. For example for Layer3:

>> S = P.StackUp;
>> S.Layer3
ans =
dielectric with properties:
Name: ‘FR4’
EpsilonR: 4.4000
LossTangent: 0
Thickness: 0.0016
For more materials see catalog

Each layer has several properties accesible via a dot format. For example, Layer3.Name displays the name etc.

>> S.Layer3.Name
ans =
>> S.Layer3.EpsilonR
ans =

Next step would be to create a pcbComponent object. Use the pcbComponent object to create a multiport PCB component consisting of metal and dielectric layers out of PCBReader object and display it:

% make a pcbComponent
pcb = pcbComponent(P);

pcbComponent object displayed in Matlab. Although one can change the individual properties of the pcbComponent object, figure needs to be reset and redrawn to display the updated properties. Next step would be to assign a feed point and create some RF excitation parameters to simulate RF behaviour of the board.

Next I will try to create a feedpoint and use the pcb object to simulate current distribution, crosstalk and S params. This new toolbox is very promising. Opens a lot of opportunities for hobbyists too, also because Matlab home license is extremely attractive price-wise. I really wonder if I can use it to evaluate the RF performance of some boards I create. Stay tuned. More to come.

Have a great day and thanks for passing by.


Harris 300W UHF Pallet

A couple of days ago I received from a friend of mine a Harris RF power pallet salvaged from a scrapped equipment. This pallet would be able to dissipate apx 300W PEP (black) on a 50 ohm load on ∼800 Mhz. Unfortunately I have no documentation for this. I do have the schematic but is […]

Harris 300W UHF pallet — how good could this be as a QRO for 70cm amateur radio band ?

RF Proto Board v2.0 — arrived from JLCPCB !

RF prototype boards arrived today from JLCPCB. The service was, as always, very fast and flawless. Seems they have a direct arrangements with Customs because I was not required to pay anything. I ordered 100 pcs for a total amount of 157 euros, apx 1.57 euro per piece. This includes manufacturing and shipment via DHL. […]

Leave a Reply

Your email address will not be published. Required fields are marked *