MATLAB: Pcbstack layers not aligned

Antenna ToolboxlayersMATLABoffsetpcbstack

Hi,
When I use pcbstack my top and bottom layers seem to be offset from the dielectric of the board. I tried to make sure they were centered properly and used the MATLAB docs, but I must be missing something. Any help is much appreciated!
Nick
clear all
close all
clc
c = physconst('lightspeed');
f = 2400e6;
lambda = c/f;
% specs
rH = 0.001016; % radiator width
rW = 0.0198628; % radiator length
fW = 0.001016; % feed arm width
sW = fW; % short arm width
sH = 0.0083058; % distance from end of feed to radiator arm
sep = 0.0027686; % separation between feed arm and short arm
fd = 0.0038608; % distance feed arm goes into into ground plane
fo = 0.02379483; % feed offset from left side of ground plane
trSp = 0.00013746; % clearance around feed (trace clearance)
bW = 0.03403599; % board width
bH = 0.010; % board height
bPcbSp = 0.00025897; % ground plane clearance from pcb edge
bAntSp = 0.000508; % antenna clearance from pcb edge
%
% rH = 1; % radiator width
% rW = 10; % radiator length
% fW = 2; % feed arm width
% sW = fW; % short arm width
% sH = 5; % distance from end of feed to radiator arm
% sep = 4; % separation between feed arm and short arm
% fd = 2; % distance feed arm goes into into ground plane
% fo = 12; % feed offset from left side of ground plane
% trSp = 0.5; % clearance around feed (trace clearance)
% bW = 40; % board width
% bH = 50; % board height
% bPcbSp = 1; % ground plane clearance from pcb edge
% bAntSp = 1; % antenna clearance from pcb edge
% rectangle width / length calculations
b1H = bH;
b1W = bW;
b2W = rW + 2*bAntSp;
b2H = sH + rH + bAntSp - bPcbSp;
g1W = bW - 2*bPcbSp;
g1H = bH - 2*bPcbSp;
g2W = fW + 2*trSp;
g2H = fd + trSp;
fH = sH + fd;
% generate metal shape centers: (0,0) is gnd bottom left
g1X = g1W/2;
g1Y = g1H/2;
g2X = fo;
g2Y = g1H - g2H/2;
fX = fo;
fY = g1H - fd + fH/2;
sX = fX + fW/2 + sep + sW/2;
sY = g1H + sH/2;
rX = sX + sW/2 - rW/2;
rY = g1H + sH + rH/2;
% create metal shape
radArm = antenna.Rectangle('Center',[rX,rY],'Width',rH,'Length',rW);
shortArm = antenna.Rectangle('Center',[sX,sY],'Width',sH,'Length',sW);
feedArm = antenna.Rectangle('Center',[fX,fY],'Width',fH,'Length',fW);
gndBtm = antenna.Rectangle('Center',[g1X,g1Y],'Width',g1H,'Length',g1W);
gndNeg = antenna.Rectangle('Center',[g2X,g2Y],'Width',g2H,'Length',g2W);
shapeTop = radArm + shortArm + feedArm + (gndBtm - gndNeg);
gndBtm = translate(gndBtm,[-g1W/2,-(rY+rH/2)/2,0]);
shapeTop = translate(shapeTop,[-g1W/2,-(rY+rH/2)/2,0]);
% create board shape
b1X = b1W/2 - bPcbSp;
b1Y = b1H/2 - bPcbSp;
b2X = rX;
b2Y = b1Y + b1H/2 + b2H/2;
b1 = antenna.Rectangle('Center',[b1X,b1Y],'Width',b1H,'Length',b1W);
b2 = antenna.Rectangle('Center',[b2X,b2Y],'Width',b2H,'Length',b2W);
boardShape = b1 + b2;
boardShape = translate(boardShape,[bPcbSp,bPcbSp,0]);
boardShape = translate(boardShape,[-bW/2,-(b1H+b2H)/2,0]);
figure
show(shapeTop)
figure
show(gndBtm)
figure
show(boardShape)
% boardShape = antenna.Rectangle('Length',0.6,'Width',0.3);
p = pcbStack;
p.BoardShape = boardShape;
p.BoardThickness = 1.61e-3;
d1 = dielectric('FR4');
p.Layers = {shapeTop,d1,gndBtm};
p.FeedDiameter = .02*lambda/2;
p.FeedLocations = [fX fY-fH/2.1 1];
figure
show(p)

Best Answer

This might be related to Bug Report 2066356 as Hyma Harish Vallabhapurapu posted, but it could also be related to Bug Report 2075957. Both those bugs are reported fixed in release R2019b Update 1.
Related Question