Create the User Interface
- Launch LabVIEW and open a new VI.
- Right-click on the front panel to add a Numeric >> Knob control. You will use this control to set the size and wavelength of the RF antenna.
- Change the name of the Knob control to Amplitude/lambda.
- Right-click on the front panel to add a Graph >> XY Graph.
- Right-click on the front panel to add a Graph >> Controls >> Polar Plot Indicator. You will use this indicator to show the RF antenna pattern as a function of the angle.
- Switch to the block diagram and locate the controls and indicators you created on the front panel. Organize the block diagram with the control (knob) on the left side and the indicators (the polar plot indicator and the XY graph) to the right side of the block diagram.
Add the MathScript Node
- Right-click on the block diagram to add a Structures >> MathScript Node.
- Copy and paste the following script into the MathScript Node. This script processes the gain of the antenna at different angles.
% Create angle vector in radians
theta = linspace(-pi/2,pi/2,1000);
u = 2*pi*a*sin(theta);
% initialize matrix
E = ones(size(u));
% Get index of non-zero values
i = find(u);
% Evaluate Antenna pattern equation
E(i) = pi*a^2*abs(2*besselj(1,u(i))./(u(i)));
% change theta to degrees units for polar plot
Out=theta.*180./pi;
- Right-click the left border of the MathScript Node and select Add Input from the shortcut menu.
- Add a to the input label, creating the a variable for the script.
- Connect the Amplitude/lambda control to the a input.
- Right-click the right border of the MathScript Node and select Add Output from the shortcut menu.
- From the output list available, select Out. This variable represents the angle vector for plotting purposes.
- Right-click the Out output terminal and select Choose Data Type >> 1D-Array >> DBL 1D from the shortcut menu to specify the data type of the Out output variable.
- Repeat the steps 12 through 14 for the E variable. This variable represents the gain output at different angles.
- Right-click to add a Cluster, Class, & Variant >> Bundle function to the block diagram.
- Add Out and E respectively to the Bundle function; then wire the output of Bundle of the XY graph. This becomes the X and Y components of the XY graph as shown in the following block diagram.
Configure the Polar Plot
- Add a Structures >> For Loop to the block diagram.
- Place a Bundle function inside the For Loop.
- Connect the Output and E inputs to the input terminals of Bundle.
- The squares in the border of the For Loop indicate the loop is set to auto index, or process each input element separately.
- Wire the Bundle output to the data array input of the Polar Plot with Point Options VI.
- On the Polar Plot VI, right-click the Polar attributes input and select Create Control from the shortcut menu.
- Switch to the front panel and set the Amplitude/lambda control to 2.
- Configure the parameters of the polar plot:
- Show a Log scale by pressing the log? button which is False by default
- Display only the right half of the plot in visible section input.
At this point, you can test your VI by pressing
Run. You will see the XY graph and polar plot data appear, and the VI will stop.
To run continuously, add a
While Loop with Button around your block diagram code.