### Where To Find This Example

Select **Help > Open Examples...** from the menus and type either the example name listed above or one of the keywords below.

Or in Version 13 or higher you can open the project directly from this page using this button. Make sure to select the **Enable Guided Help** before clicking this button.

### Design Notes

**Phase Shifter Simulation using Swept Variables and Output Equations**

This project demonstrates several techniques that can be used to do a phase shifter design in the AWR Design Environment. This circuit helps demonstrate some of the advanced features of Applied Wave Research products. Swept variables are used in this example to sweep over the bit states for the phase shifter. Output equations are used to calculate the a phase shift relative to a reference phase shift and also “unwrap” the -180 to 180 phase transitions that happen when dealing with the phase complex numbers. Also, the measurement can unwrap these phase shifts automatically where previously this had to be done with equations. This is done by selecting the **AngleU** from the **Complex Modifier** section of the measurement dialog.

When plotting phase, simulators do the math to convert from complex to an angle. This will cause the phase jumps from 180 to -180 as when the real part of the complex number is negative and the imaginary part switches from negative to positive. In phase shifters, this transition makes displaying phase results difficult. The phase needs to be unwrapped to get the cumulative phase shift. Additionally, the phase should be displayed relative to some reference phase, so you can see the effective phase shift for each state of the circuit. This is discussed in more detail at the end of these notes.

** Phase_shifter schematic** - This is an ideal 6 bit phase shifter. The subcircuits in the chain have an ideal switch and ideal transmission lines to generate the phase shift. Each subcircuit has a different phase shift that, when properly combined, give all 64 possible phase states. Each subcircuit has its bit parameter exposed so it can be passed in from the top level schematic. In the schematic there are various ways that the current state is chosen and these will be explained in more detail later. In each subcircuit, the

**SPDT**can decode a state number into individual bits and choose the proper bit to control the switch. For example, in this 6 bit shifter, there are 64 possible states. If you decode this base 10 number to a base 2 number you have 6 bit locations (E.g, 0 in base 10 is 000000 is base 2, 1 In base 10 is 000001 in base 2, and 63 in base 10 is 111111 in base 2). On the

**SPDT**model, you specify a base 10 state number and then which bit in this number. Each shift section is getting the same state number but the bit setting on each switch is different for each subcircuit.

** Phase Shift graph**- A graph showing the results from output equations. The output equations are used to show the most meaningful results to a designer and will be explained shortly.

** Output Equations** - There are a series of output equations in this project used to generate the data on the “Phase Shift” graph. The output equations are documented to explain what each section does.

__The Reason for the Output Equations__

The phase shifter simulation can be run in two modes, the swept mode and the tune mode. In the swept mode (the starting mode of this project), all of the phase shifter states are visible on the “Phase Shift” graph. In the tune mode, the tuner can be used to display only one of the possible phase shifter states.

**1. Swept Mode. **

** **The change to the different modes is done by the first output equation that is getting the phase information from the phase shifter. This output equation has its swept variable setting to **Plot all traces**. To see this, open up the **Modify Measurement Equation** for the **phase **output equation by selecting the equation, right clicking and selecting **Properties …** or by holding down the **ctrl** key and double clicking on the equation. Notice that the **SWPVAR.SWP1 **is set to **Plot all traces. **This measurement will return a matrix that is 21 by 64. There are 21 frequency points and 64 swept variable states.

The next part of the output equations is getting the reference phase information. The output equation is setup to only return the first swept variable state, which is chosen to be the reference state. Please see the output equation settings to see how this is done. Notice that the **SWPVAR.SWP1 **is set to **state=0. **This measurement will return a matrix that is 21 by 1.

To be able to calculate a phase difference, the two matrices (the circuit and the reference) must be the same size. Currently this is not the case. The next group of equations is used to calculate the size of the original phase data.

Now the size of the original phase data is used to make the reference data be the same size. The **stack** function will make a copy of the input vector and repeat it the set number of times. This now makes the reference data the same size as the circuit data.

The next group of equations is used to calculate the difference between the circuit phase and the reference.

The last equation converts from radians to degrees.

**2. Tune Mode. **

To change to tune mode, open up the **Modify Measurement Equation** for the **phase **output equation by selecting the equation, right clicking and selecting **Properties …** or by holding down the **Ctrl** key and double clicking on the equation. Change the **SWPVAR.SWP1 **box to **Select with Tuner. **Now when you run the simulation, you will only see one trace on the **Phase Shift** graph. Now open up the tuner and notice that you can select between the 64 possible states. Change the tuner and watch the results change.

The output equations work the same way to calculate the phase shift. The only difference now is that the **phase** matrix is 21 by 1. The reference is the same so the stack command isn’t necessary. However it was necessary for the swept mode and will still make everything work in tune mode.

__Phase Shifter Difficulties__

Phase shifters can be difficult to plot results because of how the angle of s-parameters is calculated. You can think of the center of the smith chart like the origin of a complex plane. Then each s-parameter on the smith chart is plotting its real and imaginary parts. When you have a complex number with a large negative real part and small imaginary part (positive or negative), the angle that gets calculated is approximately 180 degrees. When the imaginary part is positive and increasing, the angle will decrease from 180. When the imaginary part is an increasingly negative number, the angle will increase from -180. When the imaginary part is 0 is where the transition occurs from 180 to -180 degrees. To demonstrate, run the simulation and look at the graph “Reference Phase Smith”. The marker on the graph shows that the transition from the lower half of the smith chart (negative imaginary s-parameter) to the top half of the smith chart (positive imaginary s-parameters) occurs at 10 GHz. Then look at the graph “Reference Phase” and you will see that indeed the phase jump from -180 to 180 occurs at 10 GHz. Now modify the measurement on the "Phase Reference" graph to use the **AngleU **modifier instead of the **Angle **modifier.