%% Use PCB Antenna Designer App to Design 4.65 GHz 1-by-2 H-Notch Linear Antenna Array
% This example shows how to design, validate, and export a 1-by-2 H-notch linear antenna array resonating at 4.65 GHz using the PCB Antenna Designer app.
%% Design Unit Element
% To design an array you must create an unit element.
%% Open New Session
% Type this command at the command line to open the PCB Antenna Designer app.
% pcbAntennaDesigner
% The PCB Antenna Designer app opens a new blank canvas. Select the New Session button in the Design tab to start a new session. The new session opens a blank canvas.
% The default units for the canvas are in mm. The units can be changed using the Canvas Settings button. The app uses global units and this units are applied to all the dimensional properties of the shapes.
%% Define Board Shape
% To design a PCB stack you must define a board shape. To define a board shape, select one of the shapes from the Shapes section. This example uses a rectangle board shape. Select Rectangle from the Shapes section. An instructional text appears," Click and drag to create a rectangle". Drag on the canvas to create a rectangle,
% The properties of the rectangle, Rectangle1 can be changed from the Properties panel. This panel is visible when a shape is selected from the canvas or from the tree.
%
% Drag the square and circle markers to resize and rotate the Rectangle1, respectively.
%
% Right click the Rectangle1 and select Fit to View from the context menu to fit the canvas to the objects on the screen.
%
% Change the properties of the Rectangle1 under Properties pane:
%  Center — [0,0]
% Length — 25
% Width — 25
%
%% Add Metal Layer
% Select the Add Layer button and select Metal Layer to add a metal layer.
%
% The board shape is represented as a dotted line on the canvas.
%
% Set the Name of the metal layer to GroundPlane.
%% Add Dielectric Layer
% Select the Add Layer button and select Dielectric Layer to add a dielectric layer DielectricLayer1.
%
%
% Add an another metal layer. Set the name of this layer to HNotchLayer.
%
%% Move Layers
% You can move the layers using Move Up and Move Down button.
%
%% Create H-Notch
% Select the HNotchLayer and select a Rectangle from the shapes section and drag on the canvas to add a rectangle.
%
% Change the properties of the Rectangle2:
% Name — HPatch
% Center — [0,0]
% Length — 20
% Width — 20
%
% Select the Snap to grid checkbox from the Canvas Settings button to draw a shape accurately at first instance and then set the Grid Size of 0.5 mm to set the size of the grid.
%
% HPatch is displayed as shown.
%
%% Create Top Notch
% Select a Rectangle from the shapes section and drag that rectangle at the top of the HPatch.
% Set the properties of the Rectangle3:
% Name — TopNotch
% Center — [0,7]
% Length — 6
% Width — 6
%
%% Create Bottom Notch
% Select the TopNotch from the canvas and select the Copy button from the Actions section. Select the Paste button to paste an another copy of TopNotch. This creates a rectangle shape TopNotch_Copy_1 which has the same dimensions as TopNotch.
%
% Set the properties of TopNotch_Copy_1:
% Name — BottomNotch
% Center — [0,-7]
%% Subtract Top and Bottom Notch Layer from Metal Patch
% Select the Hpatch and the TopNotch in order and then select the Subtract button to subtract both rectangles.
%
%
% The HPatch layer gets updated as shown below.
%
% Select Hpatch and BottomNotch in order and then select the Subtract button to subtract both rectangles.
%
%% Define Dimensions for Ground Plane
% The ground plane must be same size of the HNotchLayer. To make the ground plane the same size as the Hnotch, right click the HPatch and select the Copy button.
%
% Right click on the ground plane and select the Paste button to paste in the GroundPlane .
%
% A rectangle will be copied in the ground plane layer, HPatch_Copy(1). The HPatch_Copy(1) and Hpatch are of same dimensions.
%
% Set the properties of the HPatch_Copy(1):
% Name — GroundPlaneRect
% Center — [0,7]
% Length — 23
% Width — 23
%
%% Add Feed
% Select the HNotchLayer metal layer and select the Add Feed button under the Feed Via section. Feed can be added only on the metal layer.
%
% The feed is added on the HNotchLayer and this is reflected on the tree with Feed1 added under the Feed node.
%
%% Change Properties of  Feed
% Select the parent Feed node on the tree, and set the FeedDiameter to 1 and FeedViaModel to Strip.. The FeedDiameter is a global property that is when the feed diameter is changed all the feeds in the canvas are updated with the diameter specified.
%
%% Change Position of Feed
% Select the Feed1 from the tree and under Properties panel set the Center to [-3,-3].
%
% From the 3D-View you can see that the feed is available only on the HnotchLayer.
%
%% Change Start Layer and Stop Layer
% To connect the feed from the GroundPlane to the HnotchLayer StartLayer and StopLayer of Feed1 must be updated.
% Set the StartLayer of GroundPlane and StopLayer to HNotchLayer.
%
%% Change Metal Properties
% Select Layers node in the tree and  in the properties pane set the Type of the metal layer to Copper.
%
%% Validate Design
% Select the Validate Design button to check for issues in the design.
%
%% Analyse H-Notch Element
% In the Analysis tab set the Center Frequency to 4.65 GHz and  Frequency Range to 4:0.1:5 GHz .
%%
%% Memory Estimate
% Select the Memory Estimate button to estimate the memory required to run the analysis. To run this design a memory of 750 MB (RAM) is required. By changing the mesh settings memory required for analysis can be altered. This can be done by selecting the Mesh button.
%
%% Analysis Settings
% Select the Analysis Settings button to verify the Ref Impedance(Z0), Az Range and El Range for the polar plots and mesh parameters.
%
% Select OK to save the settings.
%% Run Analysis
% Select the Impedance button to plot the impedance plot. The impedance plot shows that the designed PCB stack antenna resonates at 4.6 GHz.
%
% Select the 3D Pattern button to plot the 3-D far field radiation pattern of the designed antenna.
%
%% Update Plots
% Select the DielectricLayer1 and set the DielectricType to TMM10i under properties pane.
%
% Select the Update Plots button in the Analysis tab to update the analysis results. The resonant frequency is shifted to 4.4 GHz in the impedance plot.
%
%% Export Your Design to Gerber Files
% Select the Export button in the Analysis tab and Export to Gerber to export the design as Gerber files.
% In the Gerber Export dialog, select Browse in the PCB Writer tab to select the directory in which the Gerber files are to be stored.
%
% In the PCB Service tab select the select the MayHewWriter from the Services dropdown. The selected service is used by the PCB writer to create the Gerber files
%
% In the PCB Connector tab, deselect UseDefaultConnector.
%
% Set SMA in the Connectors and SMA_Cinch in the Connectors' Type as connectors and connectors stub type, respectively. This connector is used to feed the PCB stack.
%
% The PinHoleDiameter is the same measurement as the FeedDiameter. Select OK to generate Gerber files.
%
% Open mayhewlabs.com/webGerber from your browser. Drag and drop the Gerber files generated from the directory and select OK.
%
% Select Done.
% The Gerber files are displayed in the Gerber viewer. You can use this Gerber file for fabrication of your antennas.
%
% You can also export your design to MATLAB workspace or script by selecting Export to MATLAB Workspace or Export to MATLAB Script dropdowns under Export button in the Analysis tab.
%% Design 1-by-2 H-Notch Linear Antenna Array
% Select the HNotchLayer and drag the axes to create a selection box. Drag the axes until the selection box encloses the Feed and the HNotchLayer.
%
% Select the Copy and Paste button to create HPatch_Copy(1) layer.
%
% Select the HPatch_Copy(1) layer and drag them to place this element to adjacent of the HPatch.
%
%% Validate Design for Errors
% Select the Validate Design button to check for issues in the design. The Check Layers and Check Feed validation failed because HNotchLayer and Feed1_Copy(1) lies outside the BoardShape and GroundPlane, respectively.
%
%% Overlay Layers
% To validate Check Layers and Check Feed make the BoardShape encloses the HNotchLayer. To do this, select the HNotchLayer and select the Overlay in the properties pane.
%
% This creates an image of the HNotchLayer in the canvas. Select the Rectangle1 under BoardShape on the canvas and use the marker on the right to change the shape of the BoardShape to enclose the image of the HNotch.
%
% Repeat the procedure with the GroundPlane layer.
%
% You can also fine tune the dimensions using the property panel.
%% Validate Design for Errors
% Select the Validate Design button again to check for issues in the design. The design is validated with no errors.
%
%% Run Analysis
% Select the Update Plots in the Analysis tab to update the analysis results. This updates all the analysis plots in the app for the array design of 1-by-2 H-notch linear array.
% Copyright 2020 The MathWorks, Inc.